Help needed with NAT configuration

Hi all,

I need some assistance as I cannot get my trunk connected to my VOIP provider. I’m guessing its a problem because i’m behind a NAT router. I have a asterisk 1.4 installation with the 2.0 GUI installed on a QNAP 219P.

I have forwarded 5060 udp and TCP. On the web interface (gui) of my installation I added the VOIP trunk to my provider. In the status overview it says: Unregistered. Strangly enough when I type in sip show registry on the CLI it says registered.

When I debug I keep seeing this SIP Error message: “489 Bad event” when it tries to register.

Behind my NAT router is my QNAP 219P installed, and also the sip phones are behind my router. When I configure the sip trunk account directly in for example x-lite it works immediately. On the asterisk installation it doesnt.

Is this a nat problem? And if so, how can I resolve this issue?

Thank you so much for your help in advance.

You need to forward RTP ports too (/etc/asterisk/rtp.conf)
Put nat=yes in general and also externip=X.X.X.X , localnet = Y.Y.Y.Y

something to read

[quote=“shmaize”]You need to forward RTP ports too (/etc/asterisk/rtp.conf)
Put nat=yes in general and also externip=X.X.X.X , localnet = Y.Y.Y.Y

something to read[/quote]

I have the same SIP problem where I can connect and the status says “unregistered”.

Just wanted to know which externip should I use (my WAN IP?) since I don’t have a static IP adress? also the local net’s adress, should it be my router’s LAN adress?.. I tried this approach and I couldn’t connect

Thanks… i’m a rookie in asterix as you can see

Can someone explain why I almost always see requests to set
[ul]nat=yes [/ul]
when talking about anything related to NAT ?
Do people ever read docs ?
nat=yes should almost never be used.

nat=yes is the only way that you can get the Asterisk box that is BEHIND NAT (has a private IP address and accesses the internet via NAT enabled router) to connect to a VoIP provider, that is on the Internet.

Witout nat=yes, Asterisk sends it’s private IP address in the SIP header to the provider, so the provider uses that IP address as the IP address of the customer. With nat=yes and externip and localnet parameters set correctly, Asterisk includes the public IP address in the SIP header requests, which is correct.

@thor, do you have another solution for this problem? If yes, please do share.

thanks for the reply boys… but would anyone have any answers regarding second question:

Wwhich externip should I use (my WAN IP?) since I don’t have a static IP adress? also the local net’s adress, should it be my router’s LAN adress?.. I tried this approach and I couldn’t connect

Thanks

localnet IP address is your router’s LAN subnet address - i.e. 192.168.1.0/255.255.255.0. Don’t forget to define the subnet mask!

About the externip - get a static IP address.

[quote=“dejanst”]localnet IP address is your router’s LAN subnet address - i.e. 192.168.1.0/255.255.255.0. Don’t forget to define the subnet mask!

About the externip - get a static IP address.[/quote]

for the static IP adress, will the DynDNS.org adress work?

If you have a static address, you don’t need dyndns.org. If you don’t, and your IP address changes, even though you are permanently online, you need a new ISP.

I don’t have static IP or the money to get one

:cry: :cry: :cry: :cry: :cry:

thanks guys

Yes, dyndns.org may accomplish the same result as static ip address using

[code][general]
externhost=myhostname.dyndns.org

In place of:

[general]
externip=w.x.y.z[/code]

Note externip can also use a hostname (your dyndns name for example) but is only resolved at the time sip.conf is read so any ip address changes will not be reflected in asterisk until a sip reload… which is why you want to use externhost as it is resolved each time it is used so it will accurately reflect your current configuration.

I wish there were more folks interested in providing reasonable solutions to the challenges as posted…

I belive there could be a problem with that.

If your computer goes to renew its lease with the DHCP server, should it not be given the same lease back, Asterisk will not use the new IP number until a restart?

At 1/2 lease expiration time a dhcp client will attempt to renew the currently assigned address, suggesting it be reassigned the previously assigned address, usually the dhcp server will agree and renew the current lease with the same ip address but is under no obligation to do so.

My assumption was the asterisk server was behind a NAT router and it was the NAT router’s external (WAN) dynamic ip address which was not under user control and hence the dyndns suggestion… this is the typical networking challenge scenario for NAT. If it’s about the asterisk server’s dhcp behavior behind the NAT router then that’s a completely different matter since it’s under user control (most likely) and dyndns is not a solution since the internal private ip address is not visible to dyndns… but then this is not the typical networking issue.

Unclear if this was directed at my sip reload comment using hostname for externip… My point was you can use a hostname (myhost.dyndns.org for example) using either sip.conf parameters “externip” or “externhost”, the difference being externip is resolved at the time sip.conf is loaded (or reloaded) hence not being very useful, or use externhost which is resolved each time it is referenced; if there is an ip address change for the external hostname while using externip with hostname then for any change in ip address to be recognized by asterisk would require a “sip reload” to reread the sip.conf file and hence resolve the externip again to the new ip address… just use externhost with the external, dynamic -> hostname mapping and all is good

[quote=“dejanst”]nat=yes is the only way that you can get the Asterisk box that is BEHIND NAT (has a private IP address and accesses the internet via NAT enabled router) to connect to a VoIP provider, that is on the Internet.

Witout nat=yes, Asterisk sends it’s private IP address in the SIP header to the provider, so the provider uses that IP address as the IP address of the customer. With nat=yes and externip and localnet parameters set correctly, Asterisk includes the public IP address in the SIP header requests, which is correct.

[/quote]

nat=yes/no describes the peer situation, not asterisk’s. nat setting has nothing to do with using public/private IP by asterisk.