Voip-info.org: Asterisk, SIP and NAT
SIP协议,采用5060端口来传递指令,10000-20000传递语音流,所有如果SIP客户端在防火墙或者内网就需要开放相应的端口,来通讯。
From Voip-info.org
On your router NAT/firewall, forward SIP ports 5060 - 5082 and RTP ports 8000 - 20000 to your * server IP address. Then edit the "rtpstart" value in rtp.conf - from rtpstart=10000 to rtpstart=8000 since 8000 is the default RTP port on x-lite phones. Also enter the same externip=xxx.xxx.xxx.xxx and localnet=xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx info from your sip.conf general settings into sip_nat.conf. Then in sip.conf under the remote extension account authentication settings add nat=yes, canreinvite=no . This should get it working flawlessly, it did it for me after much research and troubleshooting. This should mark the end of NAT/firewall issues with asterisk.
NOTE: Your WAN or externip address from your ISP is usually not permanent so in the case where it changes you will have to edit the "externip=" value in sip.conf general settings and sip_nat.conf to the new value or you can register with dynamic DNS (dyndns) to automaticaly update the value.
IAX2协议指令和媒体流都通过4569端口来传递,穿透能力比较强。