Asterisk setup in Linux machine
1) Install and setup asterisk server in Ubuntu. Run the asterisk server using below command.
Ex: asterisk -rvvv
asterisk -rvvv swamidas-HP-Laptop-14q-cs0xxx*CLI>
2) Install sip clients in two different machines which are in the same network in which asterisk server is running.
3) Configure the sip and extensions files. Reload the updated configuration of both sip and extensions using below commands.
Ex: sip reload
dialplan reload
swamidas@swamidas-HP-Laptop-14q-cs0xxx:/etc/asterisk$ cat sip.conf [general] context=default bindaddr=0.0.0.0 nat=force_rport,comedia externip=192.168.84.236 localnet=192.168.84.1/255.255.255.0 qualify=yes [1001] type=friend context=internal host=dynamic secret=password1 dtmfmode=rfc2833 disallow=all allow=ulaw allow=alaw directmedia=no [1002] type=friend context=internal host=dynamic secret=password2 dtmfmode=rfc2833 disallow=all allow=ulaw allow=alaw directmedia=no
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()
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip reload Reloading SIP swamidas-HP-Laptop-14q-cs0xxx*CLI> dialplan reload Dialplan reloaded.
4) Make sure the ports are being allowed in the asterisk server to listen to the traffic from the clients. Allow ports using below commands,
Ex: sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp
5) Register the sip clients with the asterisk server ip, username and password as configured in the sip.conf file.
6) After successful registration in both the clients, initiate a call between two clients and verify the logs in the asterisk CLI.
7) Voice can be audible clearly between two clients.
8) Below is the configuration files added for the asterisk server.
swamidas@swamidas-HP-Laptop-14q-cs0xxx:/etc/asterisk$
=======================================================
CLI LOGS
=======================================================
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1001/1001 (Unspecified) D Yes Yes 0 UNKNOWN
1002/1002 (Unspecified) D Yes Yes 0 UNKNOWN
2 sip peers [Monitored: 0 online, 2 offline Unmonitored: 0 online, 0 offline]
-- Registered SIP '1001' at 192.168.1.16:39563
[Jun 27 11:50:07] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1001' is now Reachable. (337ms / 2000ms)
swamidas-HP-Laptop-14q-cs0xxx*CLI>
swamidas-HP-Laptop-14q-cs0xxx*CLI>
-- Registered SIP '1002' at 192.168.1.4:43325
[Jun 27 12:21:54] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1002' is now Reachable. (100ms / 2000ms)
swamidas-HP-Laptop-14q-cs0xxx*CLI>
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1001/1001 192.168.1.16 D Yes Yes 39563 OK (1 ms)
1002/1002 192.168.1.4 D Yes Yes 43325 OK (12 ms)
2 sip peers [Monitored: 2 online, 0 offline Unmonitored: 0 online, 0 offline]
== Using SIP RTP CoS mark 5
[Jun 27 12:55:31] NOTICE[23025][C-00000001]: chan_sip.c:26826 handle_request_invite: Call from '1002' (192.168.1.4:43325) to extension '1001' rejected because extension not found in context 'internal'.
== Using SIP RTP CoS mark 5
[Jun 27 12:55:44] NOTICE[23025][C-00000002]: chan_sip.c:26826 handle_request_invite: Call from '1002' (192.168.1.4:43325) to extension '1001' rejected because extension not found in context 'internal'.
== Using SIP RTP CoS mark 5
[Jun 27 12:55:49] NOTICE[23025][C-00000003]: chan_sip.c:26826 handle_request_invite: Call from '1002' (192.168.1.4:43325) to extension '1001' rejected because extension not found in context 'internal'.
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'
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip reload
Reloading SIP
== Using SIP CoS mark 4
== Using SIP RTP CoS mark 5
-- Executing [1001@internal:1] Dial("SIP/1002-00000000", "SIP/1001") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1001
-- SIP/1001-00000001 is ringing
-- SIP/1001-00000001 is ringing
-- SIP/1001-00000001 answered SIP/1002-00000000
-- Channel SIP/1001-00000001 joined 'simple_bridge' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
-- Channel SIP/1002-00000000 joined 'simple_bridge' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
[Jun 27 13:01:23] WARNING[23025]: chan_sip.c:4151 retrans_pkt: Retransmission timeout reached on transmission SBLw7uYy-wTk5rEGVuN4lQ.. for seqno 2 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 16446ms with no response
[Jun 27 13:01:23] WARNING[23025]: chan_sip.c:4175 retrans_pkt: Hanging up call SBLw7uYy-wTk5rEGVuN4lQ.. - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
-- Channel SIP/1002-00000000 left 'native_rtp' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
-- Channel SIP/1001-00000001 left 'native_rtp' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
== Spawn extension (internal, 1001, 1) exited non-zero on 'SIP/1002-00000000'
== Using SIP RTP CoS mark 5
-- Executing [1002@internal:1] Dial("SIP/1001-00000002", "SIP/1002") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1002
-- SIP/1002-00000003 is ringing
-- SIP/1002-00000003 answered SIP/1001-00000002
-- Channel SIP/1002-00000003 joined 'simple_bridge' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
-- Channel SIP/1001-00000002 joined 'simple_bridge' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
[Jun 27 13:02:28] WARNING[23025]: chan_sip.c:4151 retrans_pkt: Retransmission timeout reached on transmission lw6Ulds1px-COhEIX7VAbA.. for seqno 2 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 6400ms with no response
[Jun 27 13:02:28] WARNING[23025]: chan_sip.c:4175 retrans_pkt: Hanging up call lw6Ulds1px-COhEIX7VAbA.. - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
-- Channel SIP/1001-00000002 left 'native_rtp' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
-- Channel SIP/1002-00000003 left 'native_rtp' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
== Spawn extension (internal, 1002, 1) exited non-zero on 'SIP/1001-00000002'
[Jun 27 13:05:31] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1002' is now Lagged. (3389ms / 2000ms)
[Jun 27 13:05:31] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1002' is now Reachable. (204ms / 2000ms)
[Jun 27 13:06:35] NOTICE[23025]: chan_sip.c:30551 sip_poke_noanswer: Peer '1002' is now UNREACHABLE! Last qualify: 204
swamidas-HP-Laptop-14q-cs0xxx*CLI>
swamidas-HP-Laptop-14q-cs0xxx*CLI>