Asterisk 不使用 externip

Asterisk 不使用 externip

我正在尝试使用 hello-world 示例设置位于 NAT 后面的云 Asterisk 服务器。我遇到了 NAT 问题。Asterisk 通过 SDP 提供给客户端的 IP 地址是其位于 NAT 后面的本地地址,而不是外部地址。

我曾尝试设置externip中的值sip.conf,但似乎没有效果。

[general]
externip=xxx.yyy.zzz.vvv
nat=yes
tcpenable=yes

客户端收到的SDP与服务器设置不一致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 正确解析为 IP 地址。

我设置的externip值是否不正确?或者是否需要其他设置才能让 Asterisk 公布其外部 IP 地址?

答案1

您忘记设置了localnet。配置文件确实警告过您必须将其设置为等于本地网络的网络块。

;----------------------------------------- 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 (e.g. 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, e.g. 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 支持......)

相关内容