3

I am trying to setup a cloud Asterisk server that is behind a NAT with the hello-world example. I have NAT issues. The IP address Asterisk is supplying to the client through the SDP is its local address behind the NAT, not the external address.

I have attempted to set the externip value in sip.conf, but this seems to have no effect.

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

The SDP received at the client is not consistent with the server externip setting:

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

I expect the address in the SDP to match that provided in the externip field. I have tried both the actual IP address, as well as the server name, which correctly resolves to the IP address through DNS.

Am I setting the externip value incorrectly? Or is there a different setting that is required to have Asterisk advertise its external IP address?

1 Answer 1

6

You forgot to set localnet. The configuration file did warn you that you have to set this equal to the netblock of your local network.

;----------------------------------------- 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

It's usually fine, in fact, to just uncomment all four of the example localnet directives and call it a day.

(And you should complain very loudly about your service provider's lack of IPv6 support...)

2
  • is "NAT support" a readme or from a webpage? link?
    – Thufir
    Jan 5, 2017 at 12:57
  • 1
    @Thufir That's in sip.conf, which is the very file you should have been looking at if you also had this question. Jan 5, 2017 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .