...
| Code Block |
|---|
swamidas@swamidas-HP-Laptop-14q-cs0xxx:/etc/asterisk$ cat extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no
[internal]
exten => 1001,1,Dial(SIP/1001)
exten => 1002,1,Dial(SIP/1002)
[default]
exten => _X.,1,NoOp(Unhandled call to ${EXTEN})
exten => _X.,n,Playback(vm-nobodyavail)
exten => _X.,n,Hangup()
exten => 1001,1,Dial(SIP/1001,20)
exten => 1001,n,NoOp(Dial status for 1001: ${DIALSTATUS})
exten => 1001,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1001,n(busy),Playback(all-circuits-busy-now)
exten => 1001,n(busy),Hangup()
exten => 1001,n(unavail),Playback(vm-nobodyavail)
exten => 1001,n(unavail),Hangup()
exten => 1002,1,Dial(SIP/1002,20)
exten => 1002,n,NoOp(Dial status for 1002: ${DIALSTATUS})
exten => 1002,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1002,n(busy),Playback(all-circuits-busy-now)
exten => 1002,n(busy),Hangup()
exten => 1002,n(unavail),Playback(vm-nobodyavail)
exten => 1002,n(unavail),Hangup()
exten => 500,1,Echo()
exten => 500,n,Hangup() |
| Code Block |
|---|
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip reload Reloading SIP swamidas-HP-Laptop-14q-cs0xxx*CLI> dialplan reload Dialplan reloaded. [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1001' priority 5 in 'default', label 'busy' already in use at priority 4 [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1001' priority 7 in 'default', label 'unavail' already in use at priority 6 [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1002' priority 5 in 'default', label 'busy' already in use at priority 4 [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1002' priority 7 in 'default', label 'unavail' already in use at priority 6 -- Including switch 'DUNDi/e164' in context 'ael-dundi-e164-switch' |
...
| Code Block |
|---|
root@Filogic-GW:/etc/asterisk# cat extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no
[from-internal]
exten => 1001,1,Dial(PJSIP/1001,20)
exten => 1002,1,Dial(PJSIP/1002,20) |
5)
...
Run the asterisk server in the board and reload both the configuration files in the asterisk CLI
| Code Block |
|---|
root@Filogic-GW:/etc/asterisk# asterisk -rvvv
Asterisk 18.15.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 |
5) Run the asterisk server in the board and reload both the configuration files in the asterisk CLI
| Code Block |
|---|
root@Filogic-GW:/etc/asterisk# asterisk -rvvv Asterisk 18.15.1, Copyrightcurrently (C)running 1999on Filogic-GW 2022,(pid 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 18.15.1 currently running on Filogic-GW (pid = 4177657) Filogic-GW*CLI> Filogic-GW*CLI> module reload res_pjsip.so Module 'res_pjsip.so' reloaded successfully. -- Reloading module 'res_pjsip.so' (Basic SIP resource) Filogic-GW*CLI> dialplan reload Dialplan reloaded. [Apr 28 17:43:14] WARNING[3460]: pbx.c:7126 add_priority: Extension '1001' priority 7 in 'default', label 'unavail' already in use at priority 6 [Apr 28 17:43:14] WARNING[3460]: pbx.c:7126 add_priority: Extension '1002' priority 5 in 'default', label 'busy' already in use at priority 4 [Apr 28 17:43:14] WARNING[3460]: pbx.c:7126 add_priority: Extension '1002' priority 7 in 'default', label 'unavail' already in use at priority 6 -- Time to scan old dialplan and merge leftovers back into the new: 0.000048 sec -- Time to restore hints and swap in new dialplan: 0.000012 sec -- Time to delete the old dialplan: 0.000034 sec -- Total time merge_contexts_delete: 0.000094 sec -- pbx_config successfully loaded 6 contexts (enable debug for details). Filogic-GW*CLI> |
6) Verify the clients are successfully registered with the asterisk server
= 4177657)
Filogic-GW*CLI>
Filogic-GW*CLI> module reload res_pjsip.so
Module 'res_pjsip.so' reloaded successfully.
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
Filogic-GW*CLI> dialplan reload
Dialplan reloaded.
[Apr 28 17:43:14] WARNING[3460]: pbx.c:7126 add_priority: Extension '1001' priority 7 in 'default', label 'unavail' already in use at priority 6
[Apr 28 17:43:14] WARNING[3460]: pbx.c:7126 add_priority: Extension '1002' priority 5 in 'default', label 'busy' already in use at priority 4
[Apr 28 17:43:14] WARNING[3460]: pbx.c:7126 add_priority: Extension '1002' priority 7 in 'default', label 'unavail' already in use at priority 6
-- Time to scan old dialplan and merge leftovers back into the new: 0.000048 sec
-- Time to restore hints and swap in new dialplan: 0.000012 sec
-- Time to delete the old dialplan: 0.000034 sec
-- Total time merge_contexts_delete: 0.000094 sec
-- pbx_config successfully loaded 6 contexts (enable debug for details).
Filogic-GW*CLI>
|
6) If we are facing any database errors, please follow below steps
| Code Block |
|---|
systemctl stop asteriskcd /var/lib/asteriskmv astdb.sqlite3 /tmp/astdb.sqlite3.corruptedcorrect dialplan configuration
Restart asterisk and Re-register endpoints
systemctl start asterisk |
7) Verify the clients are successfully registered with the asterisk server
| Code Block |
|---|
Filogic-GW*CLI> pjsip show endpoints
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
I/OAuth: <AuthId/UserName...........................................................>
Aor: <Aor......... |
| Code Block |
Filogic-GW*CLI> pjsip show endpoints Endpoint: <Endpoint/CID.....................................> <State.....><MaxContact> <Channels.> I/OAuthContact: <AuthId<Aor/UserNameContactUri..........................> <Hash....> <Status> <RTT(ms)..> Transport: <TransportId.........> <Type> <cos> <tos> <BindAddress..................> AorIdentify: <Aor<Identify/Endpoint.........................................................> <MaxContact> ContactMatch: <Aor/ContactUri.<criteria.........................> <Hash....> <Status> <RTT(ms)..> Transport Channel: <TransportId<ChannelId.............> <Type> <cos> <tos> <BindAddress..................> Identify: <Identify/Endpoint.......> <State.......................> <Time...........................> MatchExten: <criteria.........<DialedExten................> ChannelCLCID: <ChannelId<ConnectedLineCID......................................> <State.....> <Time.....> Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......> ========================================================================================== Endpoint: 1001 UnavailableNot in use 0 of inf InAuth: 1001/1001 Aor: 1001 10 Contact: 1001/sip:1001@192.168.1.2:42418;transport= f6b203c8e8 NonQual nan Transport: udp-transport udp 0 0 0.0.0.0:5060 Endpoint: 1002 Not in use Unavailable 0 of inf InAuth: 1002/1002 Aor: 1002 10 Contact: 1002/sip:1002@192.168.1.5:48383;transport= 0d95a96184 NonQual nan Transport: udp-transport udp 0 0 0.0.0.0:5060 Objects found: 2 Filogic-GW*CLI> |
8) 7) Make sure that both clients and Banana PI R4 board are in the same network.
89) Add firewall rules to allow sip and rtp ports to make communication between two clients using asterisk server. Flush any rules which are blocking the clients traffic.Add rules on the top place of the chain
| Code Block |
|---|
root@Filogic-GW:~# iptables -F root@Filogic-GW:~# iptables -AI INPUT -p udp --dport 5060 -j ACCEPT root@Filogic-GW:~# iptables -AI INPUT -p udp --dport 10000:20000 -j ACCEPT root@Filogic-GW:~# iptables -nL Chain INPUT (policy DROP) target prot opt source destination ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 0.0.0.0/0 udp dpt:5060 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:10000:20000 |
10) For any debug regarding the logs please set pjsip logger to on.
| Code Block |
|---|
pjsip set logger on |
11) Now initiate a call in between two clients and verify the logs in asterisk CLI. Voice call will be generated and two way communication in between two clients can be happened successfully.
| Code Block |
|---|
-- Executing [1002@from-internal:1] Dial("PJSIP/1001-00000000", "PJSIP/1002,20") in new stack
-- Called PJSIP/1002
-- Removed contact 'sip:1001@192.168.1.4:45167;transport=UDP;rinstance=34df73ee3b3522b6' from AOR '1001' due to expiration
== Contact 1001/sip:1001@192.168.1.4:45167;transport=UDP;rinstance=34df73ee3b3522b6 has been deleted
-- PJSIP/1002-00000001 is ringing
-- PJSIP/1002-00000001 answered PJSIP/1001-00000000
-- Channel PJSIP/1002-00000001 joined 'simple_bridge' basic-bridge <d8b6ecbe-8d28-4684-84d6-ec19d2a31361>
-- Channel PJSIP/1001-00000000 joined 'simple_bridge' basic-bridge <d8b6ecbe-8d28-4684-84d6-ec19d2a31361>
-- Channel PJSIP/1001-00000000 left 'native_rtp' basic-bridge <d8b6ecbe-8d28-4684-84d6-ec19d2a31361>
== Spawn extension (from-internal, 1002, 1) exited non-zero on 'PJSIP/1001-00000000'
-- Channel PJSIP/1002-00000001 left 'native_rtp' basic-bridge <d8b6ecbe-8d28-4684-84d6-ec19d2a31361>
Filogic-GW*CLI> [185515.936263] mt7996e 0000:01:00.0: mt7996_hw_scan: trigger scan on mt76 band 0
[185516.136513] mt7996e 0000:01:00.0: mt7996_hw_scan: trigger scan on mt76 band 1
[185516.336706] mt7996e 0000:01:00.0: mt7996_hw_scan: trigger scan on mt76 band 2
-- Executing [1001@from-internal:1] Dial("PJSIP/1002-00000002", "PJSIP/1001,20") in new stack
-- Called PJSIP/1001
-- PJSIP/1001-00000003 is ringing
-- PJSIP/1001-00000003 answered PJSIP/1002-00000002
-- Channel PJSIP/1001-00000003 joined 'simple_bridge' basic-bridge <c0d89774-dbea-4c65-a1e2-ecbe5d8e567e>
-- Channel PJSIP/1002-00000002 joined 'simple_bridge' basic-bridge <c0d89774-dbea-4c65-a1e2-ecbe5d8e567e>
-- Channel PJSIP/1002-00000002 left 'native_rtp' basic-bridge <c0d89774-dbea-4c65-a1e2-ecbe5d8e567e>
-- Channel PJSIP/1001-00000003 left 'native_rtp' basic-bridge <c0d89774-dbea-4c65-a1e2-ecbe5d8e567e>
== Spawn extension (from-internal, 1001, 1) exited non-zero on 'PJSIP/1002-00000002' |
Registering Asterisk as client with external SIP server and making call using external sip server trunk
1) Register with the external sip server by creating an account in sip.linphone.org and add both username, password in the existing pjsip.conf which are used as authentication credentials.
| Code Block |
|---|
[linphone_freesip_auth]
type=auth
auth_type=userpass
password=password
username=2931 |
2) Make the outbound SIP registration by adding in the pjsip.conf file
| Code Block |
|---|
[linphone_freesip_registration]
type=registration
transport=udp-transport
server_uri=sip:sip.linphone.org
client_uri=sip:2931@sip.linphone.org
outbound_auth=linphone_freesip_auth
retry_interval=60
expiration=3600 |
3) Add the contact information of the remote SIP server for outbound trunk in pjsip.conf file
| Code Block |
|---|
[linphone_freesip_aor]
type=aor
contact=sip:sip.linphone.org:5060
max_contacts=1
qualify_frequency=30 |
4) Define the SIP endpoint for your connection to the Linphone freesip server in pjsip.conf file
| Code Block |
|---|
[linphone_freesip_trunk]
type=endpoint
transport=udp-transport
context=from-linphone
disallow=all
allow=ulaw
allow=alaw
allow=gsm
auth=linphone_freesip_auth
outbound_auth=linphone_freesip_auth
aors=linphone_freesip_aor
direct_media=no
force_rport=yes
rewrite_contact=yes
rtp_symmetric=yes |
5) Do nslookup for the sip.linphone.org from the board and add the IP in the identify section in the pjsip.conf file.
| Code Block |
|---|
root@Filogic-GW:/etc/asterisk# nslookup sip.linphone.org
Server: 192.168.1.1
Address 1: 192.168.1.1 _gateway
Name: sip.linphone.org
Address 1: 5.135.215.43 sip12.linphone.org
Address 2: 2001:41d0:203:7fe2::4
[linphone_identify]
type=identify
endpoint=linphone_freesip_trunk
match=5.135.215.43/32 |
6) Add dialplan configuration in extensions.conf to route outgoing calls through this PJSIP trunk. Assuming users to dial '9' followed by the number to call externally.
| Code Block |
|---|
[from-external]
exten => 2931,1,Dial(PJSIP/1001&PJSIP/1002)
[from-internal]
exten => 1001,1,Dial(PJSIP/1001)
exten => 1002,1,Dial(PJSIP/1002)
exten => _X.,1,Dial(PJSIP/${EXTEN}@linphone_freesip_trunk) |
7) After updating the configurations, reload both the configurations from asterisk CLI.
| Code Block |
|---|
Filogic-GW*CLI> module reload res_pjsip.so
Module 'res_pjsip.so' reloaded successfully.
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
Filogic-GW*CLI> dialplan reload
Dialplan reloaded.
[Jul 17 12:20:40] WARNING[1027809]: pbx.c:7126 add_priority: Extension '1001' priority 7 in 'default', label 'unavail' already in use at priority 6
[Jul 17 12:20:40] WARNING[1027809]: pbx.c:7126 add_priority: Extension '1002' priority 5 in 'default', label 'busy' already in use at priority 4
[Jul 17 12:20:40] WARNING[1027809]: pbx.c:7126 add_priority: Extension '1002' priority 7 in 'default', label 'unavail' already in use at priority 6
-- Time to scan old dialplan and merge leftovers back into the new: 0.000062 sec
-- Time to restore hints and swap in new dialplan: 0.000018 sec
-- Time to delete the old dialplan: 0.000046 sec
-- Total time merge_contexts_delete: 0.000126 sec
-- pbx_config successfully loaded 6 contexts (enable debug for details). |
8) Verify that the endpoints are registered successfully or not.
| Code Block |
|---|
Filogic-GW*CLI> pjsip show registrations
<Registration/ServerURI..............................> <Auth....................> <Status.......>
==========================================================================================
linphone_freesip_registration/sip:sip.linphone.org linphone_freesip_auth Registered (exp. 68882s ago)
Objects found: 1
Filogic-GW*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: 1001 Not in use 0 of inf
InAuth: 1001/1001
Aor: 1001 10
Transport: udp-transport udp 0 0 0.0.0.0:5060
Endpoint: 1002 Unavailable 0 of inf
InAuth: 1002/1002
Aor: 1002 10
Transport: udp-transport udp 0 0 0.0.0.0:5060
Endpoint: linphone_freesip_trunk Not in use 0 of inf
OutAuth: linphone_freesip_auth/2931
InAuth: linphone_freesip_auth/2931
Aor: linphone_freesip_aor 1
Contact: linphone_freesip_aor/sip:sip.linphone.org: 8248a8908d Avail 187.774
Transport: udp-transport udp 0 0 0.0.0.0:5060
Identify: linphone_identify/linphone_freesip_trunk
Match: 5.135.215.43/32
Objects found: 3
Filogic-GW*CLI> |
9) Add firewall rules to allow sip and rtp ports.
| Code Block |
|---|
root@Filogic-GW:~# iptables -I INPUT -p udp --dport 5060 -j ACCEPT
root@Filogic-GW:~# iptables -I INPUT -p udp --dport 10000:20000 -j ACCEPT
root@Filogic-GW:~# iptables -nL
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:5060
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:10000:20000 |
10) Now initiate an outbound call from internal extension to the external sip server(2931).
| Code Block |
|---|
-- Executing [92931@from-internal:1] NoOp("PJSIP/1001-00000001", "") in new stack
-- Executing [92931@from-internal:2] Dial("PJSIP/1001-00000001", "PJSIP/2931@linphone_freesip_trunk,60") in new stack
-- Called PJSIP/2931@linphone_freesip_trunk
-- PJSIP/linphone_freesip_trunk-00000002 is ringing
-- Added contact 'sip:1001@192.168.1.9:36312;transport=UDP;rinstance=faa99161e70850c2' to AOR '1001' with expiration of 60 seconds
[Jul 16 11:20:45] WARNING[1830]: db.c:316 db_execute_sql: Error executing SQL (COMMIT): database is locked
> 0x7f940598d0 -- Strict RTP learning after remote address set to: 5.135.215.43:18034
-- PJSIP/linphone_freesip_trunk-00000002 answered PJSIP/1001-00000001
> 0x7f94049790 -- Strict RTP learning after remote address set to: 192.168.1.9:36687
-- Channel PJSIP/linphone_freesip_trunk-00000002 joined 'simple_bridge' basic-bridge <97c41ec6-e3f4-45e8-ad94-f2f8763abff7>
-- Channel PJSIP/1001-00000001 joined 'simple_bridge' basic-bridge <97c41ec6-e3f4-45e8-ad94-f2f8763abff7>
-- Channel PJSIP/linphone_freesip_trunk-00000002 left 'simple_bridge' basic-bridge <97c41ec6-e3f4-45e8-ad94-f2f8763abff7>
-- Channel PJSIP/1001-00000001 left 'simple_bridge' basic-bridge <97c41ec6-e3f4-45e8-ad94-f2f8763abff7>
== Spawn extension (from-internal, 92931, 2) exited non-zero on 'PJSIP/1001-00000001'
-- Added contact 'sip:1001@192.168.1.9:36312;transport=UDP;rinstance=faa99161e70850c2' to AOR '1001' with expiration of 60 seconds |
SIP registration commands after adding the code changes:
1) By default inbound call configuration will be updated in the device.
2) Please take two clients install an application which supports voice calls and register those clients with the configuration in the "/etc/asterisk" folder.
As per current configuration,
Client1:
Host: <erouter IP>
Username: 601
Password: 601
Client2:
Host: <erouter IP>
Usename: 602
Password: 602
3) Please set below commands from the console to update the outbound configuration.
dmcli eRT setv Device.Services.VoiceService.1.VoiceProfile.1.Line.1.Enable string Enabled
dmcli eRT setv Device.Services.VoiceService.1.VoiceProfile.1.SIP.OutboundProxy string sip.linphone.org
dmcli eRT setv Device.Services.VoiceService.1.VoiceProfile.1.SIP.OutboundProxyPort uint 5060
dmcli eRT setv Device.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthUserName string <username>
dmcli eRT setv Device.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthPassword string <password>
dmcli eRT getv Device.Services.VoiceService.1.VoiceProfile.1.Line.1.Status
4) Please take some other client and create an account in sip.linphone.org
5) Provide the username and password in the data models as per the data used for account creation using linphone.
6) Added below logs for the reference.
| Code Block |
|---|
root@Filogic-GW:~# asterisk -x "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: 2931_trunk Not in use 0 of inf OutAuth: 2931_auth/2931 Aor: 2931_aor 0 Contact: 2931_aor/sip:sip.linphone.org e53c3ca51a NonQual nan Transport: udp-transport udp 0 0 0.0.0.0:5060 Identify: 2931_identify/2931_trunk Match: 5.135.215.43/32 Match: 2001:41d0:203:7fe2::4/128 Match: 176.31.149.179/32 Match: 2001:41d0:303:b0d2::4/128 Endpoint: 601 Not in use 0 of inf InAuth: 601/601 Aor: 601 10 Contact: 601/sip:601@192.168.1.2:38116;transport=UD ba3b650e9b NonQual nan Transport: udp-transport udp 0 0 0.0.0.0:5060 Endpoint: 602 Not in use 0 of inf InAuth: 602/602 Aor: 602 10 Contact: 602/sip:602@192.168.1.5:57429;transport=UD 2936e37328 NonQual nan Transport: udp-transport udp 0 0 0.0.0.0:5060 Objects found: 3 root@Filogic-GW:~# root@Filogic-GW:~# root@Filogic-GW:~# asterisk -x "pjsip show registrations" <Registration/ServerURI..............................> <Auth....................> <Status.......> ========================================================================================== 2931_registration/sip:sip.linphone.org udp dpt:5060 ACCEPT udp2931_auth -- 0.0.0.0/0 0.0.0.0/0 Registered udp dpts:10000:20000 |
9) For any debug regarding the logs please set pjsip logger to on.
| Code Block |
|---|
pjsip set logger on(exp. 79s) Objects found: 1 root@Filogic-GW:~# |