Help needed with NAT configuration

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

Help needed with NAT configuration

Postby zipt.nl » Sun Aug 29, 2010 3:13 pm

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.
zipt.nl
Newsterisk
 
Posts: 2
Joined: Wed Aug 25, 2010 8:19 am

Re: Help needed with NAT configuration

Postby shmaize » Tue Aug 31, 2010 6:36 am

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
shmaize
Oldsterisk
 
Posts: 132
Joined: Wed Mar 14, 2007 5:24 am

Re: Help needed with NAT configuration

Postby igracgq » Fri Nov 26, 2010 12:26 pm

shmaize wrote: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


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
igracgq
Newsterisk
 
Posts: 6
Joined: Fri Nov 26, 2010 12:20 pm

Re: Help needed with NAT configuration

Postby thor » Sat Nov 27, 2010 10:25 am

shmaize wrote:Put nat=yes in general


Can someone explain why I almost always see requests to set
    nat=yes
when talking about anything related to NAT ?
Do people ever read docs ?
nat=yes should almost never be used.
thor
Oldsterisk
 
Posts: 238
Joined: Thu Mar 18, 2010 12:19 pm

Re: Help needed with NAT configuration

Postby dejanst » Sat Nov 27, 2010 2:33 pm

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.
dejanst
Astmaster
 
Posts: 930
Joined: Tue Apr 27, 2010 7:14 am
Location: Ljubljana, Slovenia

Re: Help needed with NAT configuration

Postby igracgq » Sat Nov 27, 2010 3:28 pm

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
igracgq
Newsterisk
 
Posts: 6
Joined: Fri Nov 26, 2010 12:20 pm

Re: Help needed with NAT configuration

Postby dejanst » Sat Nov 27, 2010 3:51 pm

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.
dejanst
Astmaster
 
Posts: 930
Joined: Tue Apr 27, 2010 7:14 am
Location: Ljubljana, Slovenia

Re: Help needed with NAT configuration

Postby igracgq » Sun Nov 28, 2010 8:55 pm

dejanst wrote: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.



for the static IP adress, will the DynDNS.org adress work?
igracgq
Newsterisk
 
Posts: 6
Joined: Fri Nov 26, 2010 12:20 pm

Re: Help needed with NAT configuration

Postby david55 » Tue Nov 30, 2010 5:33 am

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.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: Help needed with NAT configuration

Postby igracgq » Tue Nov 30, 2010 8:29 am

david55 wrote: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
igracgq
Newsterisk
 
Posts: 6
Joined: Fri Nov 26, 2010 12:20 pm

Re: Help needed with NAT configuration

Postby smbrown » Wed Dec 01, 2010 1:23 am

Yes, dyndns.org may accomplish the same result as static ip address using
Code: Select all
[general]
externhost=myhostname.dyndns.org

In place of:

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


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...
smbrown
Newsterisk
 
Posts: 15
Joined: Tue Jun 15, 2010 4:28 pm

Re: Help needed with NAT configuration

Postby mazzic » Wed Dec 01, 2010 10:36 am

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?
-Mazzic
mazzic
Oldsterisk
 
Posts: 277
Joined: Wed May 05, 2010 8:55 am
Location: Waco, TX

Re: Help needed with NAT configuration

Postby smbrown » Thu Dec 02, 2010 1:56 am

If your computer goes to renew its lease with the DHCP server, should it not be given the same lease back


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.

Asterisk will not use the new IP number until a restart?

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
smbrown
Newsterisk
 
Posts: 15
Joined: Tue Jun 15, 2010 4:28 pm

Re: Help needed with NAT configuration

Postby thor » Wed Jun 15, 2011 9:54 pm

dejanst wrote: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.



nat=yes/no describes the peer situation, not asterisk's. nat setting has nothing to do with using public/private IP by asterisk.
thor
Oldsterisk
 
Posts: 238
Joined: Thu Mar 18, 2010 12:19 pm


Return to Asterisk Support

Who is online

Users browsing this forum: Google [Bot] and 1 guest