How to Create PJSIP Endpoints with Templates on Debian 12
To Create PJSIP Endpoints With Templates On Debian 12
Introduction:
PJSIP is a free and open-source multimedia communication library based on C language that implements standard-based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. Configuration templates are means to avoid repetitive sections in Asterisk configuration files, such as extensions.conf, sip.conf, or iax.conf.
Installation Procedure:
Step 1: Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
Step 2: Check the status of the Asterisk by using the below command
root@linuxhelp:~# systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/init.d/asterisk; generated)
Active: active (running) since Wed 2023-08-30 16:59:36 IST; 1 day 14h ago
Docs: man:systemd-sysv-generator(8)
Process: 822 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SU>
Tasks: 72 (limit: 3408)
Memory: 140.0M
CPU: 14.687s
CGroup: /system.slice/asterisk.service
└─931 /usr/sbin/asterisk
Aug 30 16:59:36 debian systemd[1]: Starting asterisk.service - LSB: Asterisk PB>
Aug 30 16:59:36 debian asterisk[822]: Starting Asterisk PBX: asterisk.
Aug 30 16:59:36 debian systemd[1]: Started asterisk.service - LSB: Asterisk PBX.
Aug 30 16:59:40 debian asterisk[931]: radcli: rc_read_config: rc_read_config: c>
Aug 30 16:59:40 debian asterisk[931]: radcli: rc_read_config: rc_read_config: c>
Step 3: Edit the pjsip.conf file to add the templates for endpoints by using the below command
root@linuxhelp:~# vim /etc/asterisk/pjsip.conf
[167](customtemplate)
auth_type=userpass
type=auth
username=167
password=123456
type=aor
qualify_frequency=60
max_contacts=1
remove_existing=yes
qualify_timeout=3.0
authenticate_qualify=no
[customtemplate](!)
context=internal
type=endpoint
language=en
deny=0.0.0.0/0.0.0.0
trust_id_inbound=yes
send_rpid=no
transport=tcp_transport
rtcp_mux=no
call_group=
pickup_group=
disallow=all
allow=ulaw,alaw,gsm
mailboxes=300
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
[168](customtemplate)
auth_type=userpass
type=auth
username=168
password=123456
type=aor
qualify_frequency=60
max_contacts=1
remove_existing=yes
qualify_timeout=3.0
authenticate_qualify=no
[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
Step 4: Login to the Asterisk CLI mode by using the below command
root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.0, 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.4.0 currently running on linuxhelp (pid = 931)
linuxhelp*CLI>
Step 5: Reload the pjsip.conf file by running the below command
linuxhelp*CLI> pjsip reload
Module 'res_pjsip.so' reloaded successfully.
Module 'res_pjsip_authenticator_digest.so' reloaded successfully.
Module 'res_pjsip_endpoint_identifier_ip.so' reloaded successfully.
Module 'res_pjsip_mwi.so' reloaded successfully.
Module 'res_pjsip_notify.so' reloaded successfully.
Module 'res_pjsip_outbound_publish.so' reloaded successfully.
Module 'res_pjsip_publish_asterisk.so' reloaded successfully.
Module 'res_pjsip_outbound_registration.so' reloaded successfully.
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Sep 1 08:16:35] NOTICE[2965]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
-- 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_pjsip_mwi.so' (PJSIP MWI resource)
-- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
-- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
-- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
-- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)
Step 6: Show the endpoints by using the 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 Not in use 0 of inf
InAuth: 167/167
Aor: 167 1
Contact: 167/sip:167@192.168.6.102:57232;transport= 3c1e740b65 Avail 4.857
Transport: tcp_transport tcp 3 96 0.0.0.0:5060
Endpoint: 168/168 Unavailable 0 of inf
InAuth: 168/168
Aor: 168 1
Transport: tcp_transport tcp 3 96 0.0.0.0:5060
Objects found: 2
Step 7: Check the endpoints by Using Softwares as shown in below image
Step 8: Now create 2 templates by editing the pjsip.conf file
root@linuxhelp:~# vim /etc/asterisk/pjsip.conf
[167](customtemplate)(customtemplate2)
auth_type=userpass
type=auth
username=167
password=123456
type=aor
qualify_frequency=60
max_contacts=1
remove_existing=yes
qualify_timeout=3.0
authenticate_qualify=no
[customtemplate](!)
context=internal
type=endpoint
language=en
deny=0.0.0.0/0.0.0.0
trust_id_inbound=yes
send_rpid=no
transport=tcp_transport
rtcp_mux=no
call_group=
pickup_group=
disallow=all
[customtemplate2](!)
allow=ulaw,alaw,gsm
mailboxes=300
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
[168](customtemplate)(customtemplate2)
auth_type=userpass
type=auth
username=168
password=123456
type=aor
qualify_frequency=60
max_contacts=1
remove_existing=yes
qualify_timeout=3.0
authenticate_qualify=no
[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
Step 9: Login to the Asterisk CLI mode and Reload PJSIP by using the below commands
root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.0, 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.4.0 currently running on linuxhelp (pid = 931)
linuxhelp*CLI>
linuxhelp*CLI> pjsip reload
Module 'res_pjsip.so' reloaded successfully.
Module 'res_pjsip_authenticator_digest.so' reloaded successfully.
Module 'res_pjsip_endpoint_identifier_ip.so' reloaded successfully.
Module 'res_pjsip_mwi.so' reloaded successfully.
Module 'res_pjsip_notify.so' reloaded successfully.
Module 'res_pjsip_outbound_publish.so' reloaded successfully.
Module 'res_pjsip_publish_asterisk.so' reloaded successfully.
Module 'res_pjsip_outbound_registration.so' reloaded successfully.
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Sep 1 08:20:58] NOTICE[2965]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
-- 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_pjsip_mwi.so' (PJSIP MWI resource)
-- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
-- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
-- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
-- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)
Step 10: Show endpoints by running the 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 Not in use 0 of inf
InAuth: 167/167
Aor: 167 1
Contact: 167/sip:167@192.168.6.102:57232;transport= 3c1e740b65 Avail 8.047
Transport: tcp_transport tcp 3 96 0.0.0.0:5060
Endpoint: 168/168 Unavailable 0 of inf
InAuth: 168/168
Aor: 168 1
Transport: tcp_transport tcp 3 96 0.0.0.0:5060
Objects found: 2
Step 11: Check the endpoints by Using Softwares as shown in below image
[Sep 1 08:23:42] NOTICE[2965]: res_pjsip_session.c:4022 new_invite: 167: Call (TCP:192.168.6.102:57232) to extension '168' rejected because extension not found in context 'internal'.
-- Executing [167@internal:1] Dial("PJSIP/168-0000000a", "PJSIP/167") in new stack
-- Called PJSIP/167
-- PJSIP/167-0000000b is ringing
== Spawn extension (internal, 167, 1) exited non-zero on 'PJSIP/168-0000000a
Conclusion
We have reached the end of this article. In this guide, we have walked you through the steps required to Create PJSIP Endpoints with Templates on Debian 12. Your feedback is much welcome.
Comments ( 0 )
No comments available