Registering SIP phones from an outside location to your Asterisk Server

With Asterisk, it’s easy to register the IAX phones from an outside location when your asterisk server is behind a router/firewall, but doing the same with SIP requires a bit of work.  It may or may not work out of box.  Here is a quick guide to get you started if you are attempting to register a SIP phone placed outside the network where the asterisk server is.

First thing you will want to do is ensure that your Asterisk server is configured properly to accept connections from outside.  Look for sip_nat.conf file within the /etc/asterisk directory on your server.  If it doesn’t exist, create it.  We don’t need to modify the sip.conf file for these purposes, however, you do need to make sure this line is contained in your sip.conf file:

#include sip_nat.conf

This ensures that sip_nat.conf file is also read.

If you have the external IP address of your server, make sure you have that handy.  Your sip_nat.conf file should look like this:

externip=176.0.0.1  ;replace the IP address given here with your asterisk server’s external IP address
localhost=192.168.1.1/255.255.255.0  ;put your localhost IP range here
nat=yes  ;make sure you include nat=yes

If you have a dynamic IP address, you will want to probably give your dynamic IP a dynamic DNS using services such as dyndns.org and if you do have a dynamic DNS being used, use the following in your sip_nat.conf file:

externhost=yourdomain.dyndns.org  ; replace the domain name with your domain name
localhost=192.168.1.1/255.255.255.0
nat=yes

Save your sip_nat.conf file and reload your asterisk configuration.

Now what you need to do is make sure your router is configured to forward the required ports to your asterisk server: Point the ports 5060-5082 on UDP to the IP address of your asterisk server and also point the ports 10000-20000 on UDP to the ip address of your asterisk server.  This will allow any incoming connections on these ports to be routed directly to your Asterisk server which we have already configured to accept external SIP connections.

Now, you should make your new SIP extension that you will be using from the outside world.  Make a normal SIP extension, but make sure to configure your extension to have “Nat=yes” and “Qualify=yes” .  This is what it looks like on my trixbox when I make that SIP extension.  Notice the highlighted areas in the image:

And you are done, try registering your SIP extension from an external network on your Asterisk server and you should be good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">