How to create and connect PJSIP Endpoints using Asterisk on Rocky Linux 9.4
- 00:36 Cat /etc/os-release
- 00:57 systemctl status asterisk
- 01:18 cd /etc/asterisk
- 01:30 vim pjsip.conf
- 02:19 vim extensions.conf
- 02:47 systemctl stop firewalld
- 03:05 asterisk -rvvvvvvvvvvvvvvvvv
- 03:16 core reload
- 03:29 pjsip show endpoints
- 03:49 pjsip show auths
- 04:05 pjsip show aors
- 04:14 dialplan reload
- 06:08 pjsip show endpoints
To Create And Connect PJSIP Endpoints Using Asterisk On Rocky Linux 9.4
Introduction:
A SIP endpoint is simply a configuration profile for a device such as a phone or a remote server. Asterisk Dialplan context, which handles calls originating from the endpoint, and the audio codecs allowed for the endpoint are defined here.
Procedure:
Step 1: Check the OS version by using the below command
[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.4 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.4"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.4"
Step 2: Verify the status of the Asterisk by using the below command
[root@Linuxhelp ~]# systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
Active: active (running) since Sun 2024-06-23 23:24:59 IST; 2h 15min ago
Docs: man:systemd-sysv-generator(8)
Main PID: 1224
Tasks: 38 (limit: 48597)
Memory: 62.4M
CPU: 3.305s
CGroup: /system.slice/asterisk.service
├─1221 /bin/sh /usr/sbin/safe_asterisk
└─5288 /usr/sbin/asterisk -f -vvvg -c
Jun 23 23:24:59 Linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Jun 23 23:24:59 Linuxhelp asterisk[1140]: Starting asterisk:
Jun 23 23:24:59 Linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet?) >
Jun 23 23:24:59 Linuxhelp systemd[1]: asterisk.service: Supervising process 1224 which is not our child. We'll>
Jun 23 23:24:59 Linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Jun 23 23:25:54 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references a p>
Jun 23 23:26:17 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references a p>
Step 3: Change the directory to the Asterisk configuration location by using the below command
[root@Linuxhelp ~]# cd /etc/asterisk/
Step 4: Add the following lines in pjsip.conf file by using vim text editor
[root@Linuxhelp asterisk]# vim pjsip.conf
[tcp_transport]
type=transport ; Must be of type 'transport'
protocol=tcp
bind=0.0.0.0
tos=cs3
cos=3
allow_reload=false
[udp_transport]
type=transport ; Must be of type 'transport'
protocol=udp
bind=0.0.0.0
tos=cs3
cos=3
allow_reload=false
[167]
auth_type=userpass
type=auth
username=167
password=123456
[167]
type=aor
qualify_frequency=60
max_contacts=1
remove_existing=yes
qualify_timeout=3.0
authenticate_qualify=no
[167]
context=internal
language=en
deny=0.0.0.0/0.0.0.0
trust_id_inbound=yes
send_rpid=no
rtcp_mux=no
call_group=
pickup_group=
disallow=all
allow=ulaw,alaw,g722,gsm,vp9,vp8,h264,opus
;dtls_auto_generate_cert=yes
;webrtc=yes
permit=0.0.0.0/0.0.0.0
ice_support=no
use_avpf=no
dtls_cert_file=
dtls_private_key=
dtls_ca_file=
dtls_setup=actpass
dtls_verify=no
media_encryption=no
message_context=
subscribe_context=
allow_subscribe=yes
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
direct_media=no
media_use_received_transport=no
auth=167
aors=167
type=endpoint
mailboxes=63121@63
callerid="User" <167>
[168]
auth_type=userpass
type=auth
username=168
password=123456
[168]
type=aor
qualify_frequency=60
max_contacts=1
remove_existing=yes
qualify_timeout=3.0
authenticate_qualify=no
[168]
context=internal
language=en
deny=0.0.0.0/0.0.0.0
trust_id_inbound=yes
send_rpid=no
rtcp_mux=no
call_group=
pickup_group=
disallow=all
allow=ulaw,alaw,g722,gsm,vp9,vp8,h264,opus
;dtls_auto_generate_cert=yes
;webrtc=yes
permit=0.0.0.0/0.0.0.0
ice_support=no
use_avpf=no
dtls_cert_file=
dtls_private_key=
dtls_ca_file=
dtls_setup=actpass
dtls_verify=no
media_encryption=no
message_context=
subscribe_context=
allow_subscribe=yes
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
direct_media=no
media_use_received_transport=no
auth=168
aors=168
type=endpoint
mailboxes=63121@63
callerid="User" <168>
Step 5: Add the following lines in extensions.conf for dialplan by using the vim editor
[root@Linuxhelp asterisk]# vim extensions.conf
[internal]
exten => 167,1,Dial(PJSIP/167)
exten => 168,1,Dial(PJSIP/168)
Step 6: Stop the firewall service by using the below command
[root@Linuxhelp asterisk]# systemctl stop firewalld
Step 7: Login to Asterisk Console by using below command
[root@Linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvvvvv
Asterisk 20.8.1, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.8.1 currently running on Linuxhelp (pid = 5288)
Linuxhelp*CLI>
Step 8: Reload the pjsip by using below command
Linuxhelp*CLI> core reload
-- Reloading module 'extconfig' (Configuration)
-- Reloading module 'logger' (Logger)
Asterisk Queue Logger restarted
-- Reloading module 'cdr' (CDR Engine)
[Jun 24 01:47:29] NOTICE[6466]: cdr.c:4568 cdr_toggle_runtime_options: CDR simple logging enabled.
-- Reloading module 'cel' (CEL Engine)
-- CEL logging disabled.
-- Reloading module 'dnsmgr' (DNS Manager)
-- Reloading module 'dsp' (DSP)
-- Reloading module 'enum' (ENUM Support)
-- Reloading module 'features' (Call Features)
-- Reloading module 'http' (Built-in HTTP Server)
-- Reloading module 'indications' (Indication Tone Handling)
-- Reloading module 'acl' (Named ACL system)
-- Reloading module 'manager' (Asterisk Manager Interface)
-- Reloading module 'plc' (PLC)
-- Reloading module 'udptl' (UDPTL)
-- Reloading module 'res_pjproject.so' (PJPROJECT Log and Utility Support)
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Jun 24 01:47:29] ERROR[6467]: res_pjsip/config_transport.c:992 transport_apply: Transport 'udp_transport' could not be started: Address already in use
[Jun 24 01:47:29] ERROR[6467]: res_sorcery_config.c:422 sorcery_config_internal_load: Could not create an object of type 'transport' with id 'udp_transport' from configuration file 'pjsip.conf'
[Jun 24 01:47:29] NOTICE[6467]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
== Endpoint dcs-endpoint is now Unreachable
== Contact dcs-aor/sip:sip.digiumcloud.net has been deleted
-- Reloading module 'res_pjsip_authenticator_digest.so' (PJSIP authentication resource)
-- Reloading module 'res_pjsip_endpoint_identifier_ip.so' (PJSIP IP endpoint identifier)
-- Reloading module 'res_musiconhold.so' (Music On Hold Resource)
-- Reloading module 'res_rtp_asterisk.so' (Asterisk RTP Stack)
-- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
-- Reloading module 'res_pjsip_mwi.so' (PJSIP MWI resource)
-- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
-- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
-- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)
-- Reloading module 'app_confbridge.so' (Conference Bridge Application)
-- Reloading module 'cdr_custom.so' (Customizable Comma Separated Values CDR Backend)
-- Reloading module 'app_playback.so' (Sound File Playback Application)
-- Reloading module 'app_voicemail.so' (Comedian Mail (Voicemail System))
-- Reloading module 'pbx_config.so' (Text Extension Configuration)
> Time to scan old dialplan and merge leftovers back into the new: 0.000027 sec
> Time to restore hints and swap in new dialplan: 0.000002 sec
> Time to delete the old dialplan: 0.000031 sec
> Total time merge_contexts_delete: 0.000060 sec
> pbx_config successfully loaded 13 contexts (enable debug for details).
-- Reloading module 'app_queue.so' (True Call Queueing)
[Jun 24 01:47:29] NOTICE[6466]: app_queue.c:9607 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
Step 9: Show the Endpoints details by using below command
Linuxhelp*CLI> pjsip show endpoints
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
I/OAuth: <AuthId/UserName...........................................................>
Aor: <Aor............................................> <MaxContact>
Contact: <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
Transport: <TransportId........> <Type> <cos> <tos> <BindAddress..................>
Identify: <Identify/Endpoint.........................................................>
Match: <criteria.........................>
Channel: <ChannelId......................................> <State.....> <Time.....>
Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......>
==========================================================================================
Endpoint: 167/167 Unavailable 0 of inf
InAuth: 167/167
Aor: 167 1
Endpoint: 168/168 Unavailable 0 of inf
InAuth: 168/168
Aor: 168 1
Objects found: 2
Step 10: Show the Authendicaton details by using below command
Linuxhelp*CLI> pjsip show auths
I/OAuth: <AuthId/UserName.............................................................>
==========================================================================================
Auth: 167/167
Auth: 168/168
Objects found: 2
Step 11: Show the AORs (Address Of Records) Details by using below command
Linuxhelp*CLI> pjsip show aors
Aor: <Aor..............................................> <MaxContact>
Contact: <Aor/ContactUri............................> <Hash....> <Status> <RTT(ms)..>
==========================================================================================
Aor: 167 1
Aor: 168 1
Objects found: 2
Step 12: Reload the dialplan by using the below command
Linuxhelp*CLI> dialplan reload
Dialplan reloaded.
> Time to scan old dialplan and merge leftovers back into the new: 0.000002 sec
> Time to restore hints and swap in new dialplan: 0.000002 sec
> Time to delete the old dialplan: 0.000002 sec
> Total time merge_contexts_delete: 0.000006 sec
> pbx_config successfully loaded 1 contexts (enable debug for details).
Step 13: Open Zoiper Software and click continue as a free user as shown in below image
Step 14: Enter Username and Password which is configured in the pjsip.cof file then Click Login as shown in below image
Step 15: Here enter the server ip address as shown in below image
Step 16: Zoiper5 Dashboard Will Open as shown in below image
Step 17: Open Microsip and configure endpoint details as shown in below image
Step 18: After configured two endpoint on Zoiper and Microsip then go to asterisk cli and again view the Endpoints details by using below command. It shows the endpoint is in available state
Linuxhelp*CLI> pjsip show endpoints
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
I/OAuth: <AuthId/UserName...........................................................>
Aor: <Aor............................................> <MaxContact>
Contact: <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
Transport: <TransportId........> <Type> <cos> <tos> <BindAddress..................>
Identify: <Identify/Endpoint.........................................................>
Match: <criteria.........................>
Channel: <ChannelId......................................> <State.....> <Time.....>
Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......>
==========================================================================================
Endpoint: 167/167 Not in use 0 of inf
InAuth: 167/167
Aor: 167 1
Contact: 167/sip:167@192.168.6.102:50415;transport= 2d06f1f119 Avail 3.338
Endpoint: 168/168 Not in use 0 of inf
InAuth: 168/168
Aor: 168 1
Contact: 168/sip:168@192.168.6.102:64058;ob 0af434c468 Avail 0.397
Objects found: 2
Step 19: Finally make a call from one extension to another extension as shown in below image
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to create and connect PJSIP Endpoints using Asterisk on Rocky Linux 9.4. Your feedback is much welcome.
Comments ( 0 )
No comments available