我正在尝试使用hello-world示例设置一个位于NAT后面的云Asterisk服务器。 我有NAT问题。 Asterisk的IP地址是通过SDP提供给客户端的,它的本地地址在NAT后面,而不是外部地址。
我试图在externip中设置externip值,但是这似乎没有效果。
[general] externip=xxx.yyy.zzz.vvv nat=yes tcpenable=yes
客户端收到的SDP与服务器externip设置externip :
v=0 o=root 291445984 291445984 IN IP4 172.31.46.110 s=Asterisk PBX 11.7.0~dfsg-1ubuntu1 c=IN IP4 172.31.46.110 t=0 0 m=audio 10078 RTP/AVP 0 101 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 a=sendrecv m=video 0 RTP/AVP 96
我期望SDP中的地址与externip字段中提供的地址相匹配。 我已经尝试了实际的IP地址,以及通过DNS正确parsing到IP地址的服务器名称。
我externip错误地设置了externip值? 还是有一个不同的设置,要求Asterisk公布其外部IP地址?
你忘了设置localnet 。 configuration文件的确提醒你必须将其设置为等于本地networking的networking块。
;----------------------------------------- NAT SUPPORT ------------------------ ; ; WARNING: SIP operation behind a NAT is tricky and you really need ; to read and understand well the following section. ; ; When Asterisk is behind a NAT device, the "local" address (and port) that ; a socket is bound to has different values when seen from the inside or ; from the outside of the NATted network. Unfortunately this address must ; be communicated to the outside (eg in SIP and SDP messages), and in ; order to determine the correct value Asterisk needs to know: ; ; + whether it is talking to someone "inside" or "outside" of the NATted network. ; This is configured by assigning the "localnet" parameter with a list ; of network addresses that are considered "inside" of the NATted network. ; IF LOCALNET IS NOT SET, THE EXTERNAL ADDRESS WILL NOT BE SET CORRECTLY. ; Multiple entries are allowed, eg a reasonable set is the following: ; ; localnet=192.168.0.0/255.255.0.0 ; RFC 1918 addresses ; localnet=10.0.0.0/255.0.0.0 ; Also RFC1918 ; localnet=172.16.0.0/12 ; Another RFC1918 with CIDR notation ; localnet=169.254.0.0/255.255.0.0 ; Zero conf local network
实际上,通常取消注释全部四个示例localnet指令并称之为一天。
(你应该大声抱怨你的服务提供商缺乏对IPv6的支持…)