How to use SIP over TCP
SIP normally runs over UDP but it is possible to run it over TCP in certain versions of Asterisk. Only Asterisk versions 1.8 and above support SIP over TCP.Â
Enabled TCP on the general section of sip configuration file (/etc/asterisk/sip.conf)
[general]
...
tcpenable=yes
tcpbindaddr=0.0.0.0
...
For each SIP client you create, Â transport=Â tcp must be defined for each individual connection:
[client001]
callerid="Client 001" <001>
username=client1
secret=password
type=friend
host=dynamic
context=internal
canreinvite=yes
mailbox=001@default
transport=tcp
disallow=all
allow=alaw
nat=route
dtmfmode=inband
The final steps is to reload your sip.conf settings and confirm that Asterisk is now listening on 5060/tcp with netstat. Within the Asterisk CLI, performing the following commands should provide you with these results:
server*CLI> sip reload
server*CLI> quit
$ netstat -tlpn | grep 5060
tcp   0   0 0.0.0.0:5060   0.0.0.0:*   LISTEN   17414/asterisk