asgterisk sip nat localnet externaddr externhost qualify

If a peer is configured with nat=yes, it causesAsterisk to ignore the address information in the SIP and SDP headers from thispeer, and reply to the sender's IP address and port. nat=yes enablesa form of Symmetric RTP and SIP Comedia mode in Asterisk.

Comediamode means that Asterisk will ignore theIP and port in the received SDP from the peer and will wait for incoming RTP.This RTP should arrive to the port that Asterisk replied in the "200OK" SDP. After that, Asterisk already knows where to send its RTP.

This make communication possible with UA'sbehind NAT which don't solve NAT problem in client side (STUNICE, ALG enabledrouter, etc). This options works properly in conjuntion with qualify=yes option in order to keep open the connection fromAsterisk to the peer behind NAT.

 

Asterisk 1.8:
The 'nat' option has now been been changed tohave yesno,force_rport, and comedia as valid values. Setting it to yes forces RFC3581 behavior and enables symmetric RTP support. Setting it to no only enablesRFC 3581 behavior if the remote side requests it and disables symmetric RTPsupport. Setting it to force_rport forces RFC 3581 behavior and disablessymmetric RTP support. Setting it to comedia enables RFC 3581 behavior if theremote side requests it and enables symmetric RTP support.

 

Auto_comediaasterisk会判断跟asterisk之间是否有nat,如果有,就实行comedia机制,没有,就按正常的方式发送 rtp。

 


localnet=180.123.10.0/255.255.255.0

externaddr =192.168.0.189

当asterisk位于内网时,根据收到的linphone的sdp中的媒体IP和localnet可以判断出linphone是跟asterisk同一网段还是不同网段(有nat),如果不同一网段,asterisk向对方回的sdp中的媒体地址就是根据externaddr或者externhost得到公网地址(即192.168.0.189);如果在同一网段,就回asterisk本机地址(即180.123.10.196)。

 

nat = auto_comedia,asterisk会判断linphone跟asterisk之间是否有nat,如果有,就实行comedia机制,没有,asterisk就把rtp发向linphone的sdp中的媒体IP。

comedia就是asterisk把rtp发向收到的rtp的源地址,而不是发向linphone的sdp中的媒体IP。这主要是为了不支持stun功能的sip phone,因为他们发出的invite/sdp或者200/sdp中的媒体IP是内网地址,如果asterisk向这个内网地址转发rtp,肯定是不能到达,而是等收到它发来的rtp,然后向这个rtp的原IP(应该是经过nat映射后的IP)转发rtp。这个功能有可能穿越对称nat,还需要测试(这种穿越对称nat的方式是经asterisk中转)。

nat=yes等同于nat=force_rport, comedia,所以只测试了nat= auto_force_rport, comedia和nat=yes两种情形。force_rport是为了帮助sip phone信令穿越nat用的,因为linphone支持rport机制,所以选择auto_force_rport还是force_rport,没有影响,从测试中也发现,没有出现信令不能穿越nat的情况(就是注册不上或者播出号码后,对方没有振铃),所以大部分测试用例就配置成nat=yes。

 

directmedia=no表示不发出reinvite,directmedia=yes表示发出reinvite, directmedia=nonat表示当sip phone不在nat后面时,发reinvite,在nat后面时,不发reinvite,测试结果是,一直都发reinvite。directmedia=update表示使用update消息更新媒体IP,不使用reinvite。

 

Linphone stun相关配置:

1直接連到網路

2 nat / gate way

3 nat / stun

4 nat / ice

stun表示选择第3项,这时linphone在invite/sdp、200/sdp中的媒体IP就是通过stun服务器获取的公网ip:port。

gw ip表示第2项, 这时linphone在invite/sdp、200/sdp中的媒体IP就是内网ip:port。

 

 

关于srtp,参考25-102-2。

把srtp配置在全局中不生效,只能配置在peer中。

1、在peer中打开srtp时,作为被叫时,asterisk转发过来的invite/sdp中会带上srtp参数。作为主叫时,linphone必须也打开srtp,否则无法呼出。

2、在peer中关闭srtp,做被叫时,转发过来的invite/sdp中没有srtp参数(不管被叫linphone是否打开srtp)。作为主叫时,现象就跟1一样。

总之,正确使用srtp功能,必须linphone和asterisk都打开srtp。

 




###################################################################################

localnet=192.168.100.0/255.255.255.0

;externaddr = 192.168.0.189

externhost=voipwangpeng.vicp.cc

;当作为asterisk外时,这2个配置是localnet=192.168.0.0/255.255.255.0 externaddr=192.168.0.198,如果有域名就应该externhost=eullansh.f3322.org

;asterisk根据localnet判断linphone是不是在同一个网段的。当不是一个网段时,asterisk转发的invite/sdp200/sdp中的媒体IP就是externaddr或者externhost

;在同一个网段时,asterisk转发的invite/sdp 200/sdp中的媒体IP就是asterisk的内网IP。

 


###################################################################################

qualify=yesasterisk会默认每隔60秒发送sip/option 消息到终端,终端应该回200OK,如果没有收到终端的回复,会认为终端掉线。

qualify=xxx|no|yes
where XXX is the number of milliseconds used. If yes thedefault timeout is used, 2 seconds.

By default chan_sip.c sends the qualify every 60seconds.

就是说asterisk每60秒发一次option消息,2秒内没收到回应消息,就认为终端掉线了。

下面是全局的相关参数:

;qualifyfreq=60                 ; Qualification: How often tocheck for the host to be up in seconds

                                     ;and reported in milliseconds with sip show settings.Qualifyfreq表示发送option 消息的间隔,单位秒。

                                ; Set to lowvalue if you use low timeout for NAT of UDP sessions

                                     ;Default: 60

;qualifygap=100                          ; Number of milliseconds between each groupof peers being qualified

                                     ;Default: 100

;qualifypeers=1                           ; Number of peers in a group to bequalified at the same time

                                     ;Default: 1

;keepalive=60                   ; Interval at whichkeepalive packets should be sent to a peer

                                     ;Valid options are yes (60 seconds), no, or the number of seconds.

                                ; Default: 0

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值