Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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)

[default]
exten => _X.,1,NoOp(Unhandled call to ${EXTEN})
exten => _X.,n,Playback(vm-nobodyavail)
exten => _X.,n,Hangup()

exten => 1001,1,Dial(PJSIP/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(busi),Hangup()
exten => 1001,n(unavail),Playback(vm-nobodyavail)
exten => 1001,n(unavail),Hangup()

exten => 1002,1,Dial(PJSIP/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()

5) Run the asterisk server in the board and reload both the configuration files in the asterisk CLI

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 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
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 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.
    -- ReloadingTime 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

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.....>  <Channels.>
<MaxContact>
      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                                                 Not in use Unavailable   0 of inf
     InAuth:  1001/1001
        Aor:  1001                                              10
  Transport:  udp-transport  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                                                 UnavailableNot in use    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>

87) 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 -A I 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            udp dpt:5060
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpts:10000:20000

910) For any debug regarding the logs please set pjsip logger to on.

Code Block
pjsip set logger on

1011) 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.

...

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
[internalfrom-usersexternal]
exten => _9X.2931,1,NoOp
exten => _9X.,n,Dial(PJSIP/1001&PJSIP/${EXTEN:1}@linphone_freesip_trunk)
exten => _9X.,n,Hangup()
include => outbound-linphone

1002)

[from-internal]
exten => 1001,1,Dial(PJSIP/1001,20)
exten => 1002,1,Dial(PJSIP/1002,20)
includeexten => outbound-linphone

[outbound-linphone]
exten => _9X.,1,NoOp
same => n,_X.,1,Dial(PJSIP/${EXTEN:1}@linphone_freesip_trunk,60)
same => n,Hangup()

7) Add dialplan configuration for Incoming calls from public InternetAfter updating the configurations, reload both the configurations from asterisk CLI.

Code Block
[from-linphone]
exten => s,1,NoOp
same => n,Dial(PJSIP/1001,20)
same => n,Hangup()
exten => 2931,1,NoOp
same => n,Dial(PJSIP/1001,20)
same => n,Hangup()

8) 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> moduledialplan reload res_pjsip.so
Module 'res_pjsip.so'
Dialplan reloaded successfully.
[Jul    -- Reloading module 'res_pjsip.so' (Basic SIP resource)
Filogic-GW*CLI> dialplan reload
Dialplan reloaded.
[Jul 17 1217 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).

98) 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>

10) Now initiate an outbound call from internal extension to the external sip server(2931)9) Add firewall rules to allow sip and rtp ports.

Code Block
root@Filogic-GW:~# iptables -I ExecutingINPUT -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[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 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                  2931_auth                   Registered        (exp. 79s)

Objects found: 1

root@Filogic-GW:~#