假设这样的scenario
Internet ====== NAT ===== Asterisk-------Extensions
NAT Configuration:
Forward udp 5060 to Asterisk host.
Forward udp 10000-20000 to Asterisk host.
Asterisk Configuration:
sip.conf
[general]
externhost=<your external dns name>
;externip=xx.xx.xx.xx ; Or place your external ip address here if you don't have a dns name
localnet=192.168.1.0/255.255.255.0 ; I assume your local network is 192.168.1.xxx
rtp.conf
[general]
rtpstart=10000
rtpend=20000
这里需要注意的是如果Extension也在局域网内,而且允许Extension做Reinvite,则需要做下面的配置:
asterisk: sip.conf
[1001]
username=1001
secret=xxxxxx
host=dynamic
type=friend
dial=SIP/1001
nat=yes
canreinvite=yes
context=from-extensions
在Extension的客户端软件上需要设置STUN,并且设置默认的local UDP por为和Asterisk不同的端口,如5066.
这样,当Extension向Asterisk发起SIP请求的时候,Asterisk会使用局域网内的地址和端口(因为设置了nat=yes);而当Extension向外部的SIP peer发起invite的时候,使用的是外部的ip和port(通过STUN获得)
Internet ====== NAT ===== Asterisk-------Extensions
NAT Configuration:
Forward udp 5060 to Asterisk host.
Forward udp 10000-20000 to Asterisk host.
Asterisk Configuration:
sip.conf
[general]
externhost=<your external dns name>
;externip=xx.xx.xx.xx ; Or place your external ip address here if you don't have a dns name
localnet=192.168.1.0/255.255.255.0 ; I assume your local network is 192.168.1.xxx
rtp.conf
[general]
rtpstart=10000
rtpend=20000
这里需要注意的是如果Extension也在局域网内,而且允许Extension做Reinvite,则需要做下面的配置:
asterisk: sip.conf
[1001]
username=1001
secret=xxxxxx
host=dynamic
type=friend
dial=SIP/1001
nat=yes
canreinvite=yes
context=from-extensions
在Extension的客户端软件上需要设置STUN,并且设置默认的local UDP por为和Asterisk不同的端口,如5066.
这样,当Extension向Asterisk发起SIP请求的时候,Asterisk会使用局域网内的地址和端口(因为设置了nat=yes);而当Extension向外部的SIP peer发起invite的时候,使用的是外部的ip和port(通过STUN获得)
1439

被折叠的 条评论
为什么被折叠?



