asterisk - sip

最後更新: 2018-0-719



friend:  An entity which is both a user and a peer.


NAT Setting


Old version

; asterisk version 10

New version

; asterisk >= 11
; nat=yes is deprecated


nat=yes is working for asterisk version 10 or older. From asterisk 11 , nat=yes is depricated.

In new version, nat=yes or nat=force_rport,comedia are same.

They said nat=yes and nat=force_rport,comedia are same. But i think both are different.

If we change to nat=force_rport,comedia the behavior seems to be fine, except for outside users behind NAT. Our server is also behind NAT.

When an outside NAT:ed user calls in to the network everything works as expected, but when calling the outside user, or when two outside NAT:ed users call each other, the audio only goes one way without any errors shown in the console. When changing back to nat=yes, everything work again.

By looking in the source code for sip/config_parser.c, it seems like the reason for the difference is that when using sip=yes, the auto_force_rport and auto_comedia are cleared. However, when using force_rport,comedia, the auto equivalents are not cleared away.





# sip.conf

; tcp, default no
tcpenable = yes
tcpbindaddr =

; udp
udpbindaddr =
bindport = 5060

# checking

netstat -nlp | grep 5060

# users.conf



當 Server 不支援 tcp 的 sip 時, 會有以下 msg

[Sep 14 11:18:31] ERROR[24069]: chan_sip.c:14877 register_verify: 'TCP' is not a valid transport for '221'. we only use 'UDP'! ending call.




boxA*CLI> sip set debug on



asterisk register sip provider



* Registration is the process in which the endpoint sends a "SIP REGISTER" to the SIP SERVER

* endpoints are located (否則點知 client 在那裡呢)
* validates the user's credentials
* Registration will then update on a regular schedule

* UDP 5060

call with SIP:

Caller initiates the call by sending an "invite" to Callee

exchange of media information



    register => user[:secret[:authuser]]@host[:port][/extension]