Asterisk 不使用 externip

mat*_*ttm 3 nat asterisk

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

我试图在 中设置externipsip.conf,但这似乎没有效果。

[general]
externip=xxx.yyy.zzz.vvv
nat=yes
tcpenable=yes
Run Code Online (Sandbox Code Playgroud)

客户端收到的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
Run Code Online (Sandbox Code Playgroud)

我希望 SDP 中的地址与externip字段中提供的地址相匹配。我已经尝试了实际 IP 地址和服务器名称,它们通过 DNS 正确解析为 IP 地址。

我设置的externip值不正确吗?或者是否需要不同的设置来让 Asterisk 通告其外部 IP 地址?

Mic*_*ton 6

你忘记设置了localnet。配置文件确实警告您必须将其设置为与本地网络的 netblock 相等。

;----------------------------------------- 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
Run Code Online (Sandbox Code Playgroud)

事实上,通常可以取消对所有四个示例localnet指令的注释并收工。

(你应该大声抱怨你的服务提供商缺乏 IPv6 支持......)