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.

Primus talkbroadband with Asterisk

So I have an asterisk (Trixbox Asterisk 1.2.21) installed and working very well with a Sangoma A200 4 port FXO card and a Sangoma A102D 2 port T1/E1 card.  Due to some cost-cutting, we got rid of the PRI connected to the A102 and opted to put that FXO card in use.  After getting a talkbroadband connection from Primus, the task was to input that VOIP line into the Asterisk system.  Primus sent the adapter SPA2102, which thankfully, works on SIP.  It was fairly simple to connect the adapter to the FXO card.  Connected the internet cable in the blue port and then took a RJ11 to RJ9 cable and put it in the first port (serving as the FSX port) of the adapter straight to the first port (the FXO port) in the Sangoma Card.  Installed correctly, the trixbox settings were changed to allow outbound calls from the FXO card (in my system, trunk Zap/g1) and inbound call route was added to allow the system to receive the calls on the system. This was accomplished by adding a new outbound route.

At first, I tried to make a new inbound route by simply adding the VOIP number that came with the Primus adapter in asterisk as a DID, but that didn’t work.  Incoming calls to the VOIP number ended up with a message of “This number is not in service”.  I could see the call landing on the zaptel channel, but it was not ringing any extensions.  The trick was to change the context in the zaptel config file.  The Zaptel.conf file had the context listed as “context=from-pstn”.  Changing that to context=from-zaptel and then pointing that new inbound route to the specific zaptel channel allowed incoming calls to ring the extension.  Being new to asterisk, I’m not sure if I add a PRI in future, would the DIDs still work with context=from-zaptel instead of from-pstn .. but it did solve the issue.

So if you are looking to connect your new primus VOIP adapter to your asterisk PBX, get a FXO card and connect the adapter to the PBX instead of connecting a regular analog phone to it.