When sip is behind a NAT do not forget to specify:
in sip.conf
[general]
nat=yes
externip = X.X.X.X
fromdomain = yourdomain.com
localnet = 192.168.X.0/255.255.255.0
qualify=yes
The host specified by externip can be either a fully qualified domain name (FQDN) or an IP address.
For versions of Asterisk pre v1.2, the hostname associated with externip is only looked up when Asterisk startups up or if a 'sip reload' is executed.
You should also add qualify=yes (it wasn't said here before) if You don't add this line You won't be able to do or receive any SIP-call from behind NAT
in sip.conf
[general]
nat=yes
externip = X.X.X.X
fromdomain = yourdomain.com
localnet = 192.168.X.0/255.255.255.0
qualify=yes
The host specified by externip can be either a fully qualified domain name (FQDN) or an IP address.
For versions of Asterisk pre v1.2, the hostname associated with externip is only looked up when Asterisk startups up or if a 'sip reload' is executed.
You should also add qualify=yes (it wasn't said here before) if You don't add this line You won't be able to do or receive any SIP-call from behind NAT


Comments
333Asterisk 1.2.7.1 -- Contact Binding header
I am new to Asterisk and have a problem:
First my setup:
1.- Asterisk box (172.18.18.5) running on port 5061 is behind a Linksys router (172.18.18.2 on the LAN side, dynamic IP on the WAN side, I am using DynamicDNS).
2.- The Linksys does all the port forwarding to Asterisk
3.- I am using X-Lite softphones as clients and they succesfully register into Asterisk (I see the 200 OK).
4.- The problem is that I can't hear any sound. To test I dial *43 from the X-Lite and although it says connected and the server plays back the echo-test I do not hear anything (I telnet the Asterisk box to see the output in the asterisk*CLI).
5.- On an Ethereal trace I see this header after the INVITE when Asterisk sends a Status:100 Trying (1 bindings) packet to the client:
Contact: <sip:9978597@17.18.18.5:5061>
Contact Binding: <sip:9978597@172.18.18.5:5061>
URI: <sip:9978597@172.18.18.5:5061>
SIP contact address: sip:9978597@172.18.18.5:5061
The server is telling the client its internal IP instead of the public IP used by the Linksys (who is doing the NATing)
From this point forward the X-Lite uses this internal IP as the destination one to talk to the Asterisk box and of course it does not work.
During registration the server does send the WAN IP address of the Linksys as its address indicating NATing is working fine but for calls the problem mentioned above happens.
I have tried many ideas on the conf files, the last one is this (I use my real domain in mydomain.com):
externip = mydomain:5061
fromdomain = mydomain.com
localnet = 172.18.18.0/255.255.255.0
qualify=yes
No change, any idea please? is this a bug in Asterisk 1.2.7.1?
Thanks in advanced
333Re: Externip (NAT)
The externip is used only for NATed environments. Normally, the asterisk subnet should have access to your corporate network with simple routing and not by address translation. Are you sure that you need 2 externips instead of 2 localnets?
If you have more than one local networks, then you should add one "localnet" lines for each one of them. For your case:
localnet=10.180.201.0/255.255.255.0
localnet=10.5.0.0/255.255.255.0
Note: Please make sure that the netmask is valid for your networks (as I don't know how you have them configured)
333Externip (NAT)
Any idea?
Thanks.
333Externip (NAT)
Any idea?
Thanks.
333canreinvite
333Re: externip with dynamic ip
See ya...
d.c.
333externip with dynamic ip
sip.conf:
#include sip_nat.conf
sip_nat.conf:
fromdomain = host.dyndns
localnet = 192.168.1.0/255.255.255.0
#include sip_nat_externip.conf
sip_nat_externip.conf:
I can write a script to get the external ip and write it to sip_nat_externip.conf but I want to know if there's a better solution with dynamic ip's since I now have to figure out how to reload the config in asterisk when the ip changes.
333From a newbie
If so, let me ask:
In "externip = X.X.X.X ", X.X.X.X would be the address my router has on its Internet port (WAN)?
In "fromdomain = yourdomain.com ", youdomain.com can be a no-ip or dyndns domain wich resoved to X.X.X.X ?
Thanks!