Home » Incredible PBX » CentOS/SL Platform » Double-NAT Blues: Tackling Asterisk’s Thorniest Problems

The Most Versatile VoIP Provider: FREE PORTING

Double-NAT Blues: Tackling Asterisk’s Thorniest Problems


Whether you’re new to VoIP technology or an Old Timer, nothing is quite as frustrating as wrestling with one-way audio and no audio on SIP calls either because of poorly designed NAT-based routers or poorly implemented SIP ALG solutions on low-end residential routers. To make matters worse, you get to deal with calls originating behind not one, but two, NAT-based routers neither of which complies with the basic SIP Rules of the Road. In a perfect world, SIP and RTP packets arriving from the Internet would have their public IP address translated into a private LAN address upon arrival at the NAT-based router. And the departing packets would have their private IP addresses translated into the public IP address of the router when leaving. If your PBX and SIP phone happen to be behind different NAT-based routers and hardware from the likes of Comcast, Spectrum, and AT&T, the odds of SIP calls working reliably are somewhere between slim and none. Perhaps it’s no coincidence that each of these providers also happens to offer competing (expensive) telephony service.

Today we’d like to offer some Asterisk® solutions that resolve these issues. First, if you are the subscriber to cable or DSL Internet service, you may have some success by talking to your provider and persuading them to set up their hardware in bridged mode so that you can install your own NAT-based router that properly handles SIP traffic. Second, it’s almost always a good idea to disable SIP ALG service on routers that you control. The reason is because of the poor ALG implementations on almost all low-cost routers. Third, configuring the Public and Private IP NAT Settings for your PBX using the FreePBX® GUI (Settings->Asterisk SIP Settings->NAT Settings) often solves the problems. Fourth, make sure NAT=yes is set in your extension and trunk settings.

If you happen to be traveling and have no control over the network architecture, the chances of the above recommendations resolving your SIP problems are not likely. This includes offerings in hotels, rental units, cruise ships, and WiFi HotSpots worldwide. In most of these locations, you would want to use a SIP phone to connect back to your home or office PBX so that you could receive incoming calls and place outbound calls just as if you were sitting at your desk at home. In these situations, we have a failsafe solution for you, but it requires a little advance planning because you need to configure your home or office Asterisk server to support the design.

The easiest way to eliminate NAT problems is to take NAT out of the equation when making and receiving SIP calls. With Asterisk, this is easy. What we typically do is interconnect the home or office Asterisk PBX with a local Asterisk PBX using an IAX2 trunk. Thus, no SIP traffic passes between your local PBX and your home or office PBX regardless of the number of layers of routers that are present between the two servers. If you can make SIP calls through a provider while sitting at home, you have solved the SIP connectivity issues at the home/office end. If your local PBX and SIP phone or softphone are on the same local LAN whether wired or wireless, then there is no SIP connectivity issue locally either. So how?

Rule #1: Always travel with a notebook computer that includes VirtualBox and a reliable SIP softphone. We’re big fans of all of the Mac notebooks, any of them will suffice. Windows and Linux notebooks work as well. Steer clear of Chromebooks which lack a crucial Linux kernel driver required by VirtualBox. There’s a solution, but it’s painful. On the Mac platform, you can’t beat the free Telephone app for your SIP phone.

Rule #2: Set up a NeoRouter VPN to provide secure interconnectivity between your home or office PBX and your local PBX. With Incredible PBX platforms, the NeoRouter client is included. You’ll just need to install the NeoRouter server component on some server with a public IP address. Complete details are here. To obtain a NeoRouter private IP address on each PBX, run this command after logging in as root: nrclientcmd.

Configuring IAX Trunk on Home/Office Server. You’ll need the NeoRouter IP address and a secure password to set up the trunk that will interconnect your Home-PBX with your local PBX. We’re going to refer to the two servers as Home-PBX (10.0.0.1) and Travel-PBX (10.0.0.2) to keep things simple. On the Home-PBX, create an IAX trunk using the FreePBX GUI with a Trunk Name of Travel-PBX. The PEER Details should look like the following using a very secure password that will be used on the trunk at the other end as well:

type=friend
secret=very-secure-password
host=dynamic
context=from-internal
requirecalltoken=no
deny=0.0.0.0/0.0.0.0
permit=0.0.0.0/0.0.0.0

The Registration String would look like the following where very-secure-password is your actual shared secret for the two trunks and 10.0.0.2 is the actual VirtualBox IP address of the Travel-PBX: Home-PBX:very-secure-password@10.0.0.2

Configuring IAX Trunk on Travel-PBX Server. You’ll need the NeoRouter IP address and a secure password to set up the trunk that will interconnect your Travel-PBX server with your Home-PBX. On the Travel-PBX, create an IAX trunk using the FreePBX GUI with a Trunk Name of Home-PBX. The PEER Details should look like the following using a very secure password that will be used on the trunk at the other end as well:

type=friend
secret=very-secure-password
host=dynamic
context=from-internal
requirecalltoken=no
deny=0.0.0.0/0.0.0.0
permit=0.0.0.0/0.0.0.0

The Registration String would look like the following where very-secure-password is your actual shared secret for the two trunks and 10.0.0.1 is the actual VirtualBox IP address of the Home-PBX: Travel-PBX:very-secure-password@10.0.0.1

Once you get this far, log into both servers as root and start up the Asterisk CLI. On each server, issue the following command to be sure the two trunks are registered with each other: iax2 show registry

Routing Calls from Home-PBX to Travel-PBX. What follows is one scenario for call routing. We’re assuming calls to your Home-PBX are routed to a Ring Group consisting of various extensions in your home or office. We’re also assuming you want to now add an extension on Travel-PBX to that Ring Group so that incoming calls to your Home-PBX will also ring the softphone connected to an extension on your Travel-PBX. In the Asterisk/FreePBX world, we accomplish this by adding an Outbound Route for the Travel-PBX extension and then adding this number to the Ring Group with a # prefix to tell FreePBX that it’s a trunk call rather than a local extension. In our example, we’re assuming the softphone extension on Travel-PBX is 701, but we’re also assuming there is a different extension 701 on Home-PBX. To avoid confusing the Home-PBX, we’ll add a 7 prefix for the Travel-PBX extension and then strip it off before passing the call to Travel-PBX.

First, create an Outbound Route called Travel-PBX-Out. For the Dial Pattern, enter a Prefix of 7 and a Match Pattern of 701. For the Trunk Sequence, choose Travel-PBX. Move the Outbound Route near the top of your route list to assure that it gets processed before any other 4-digit extensions. Second, edit your Ring Group and add 7701# to the existing list.

Routing Calls from Travel-PBX to Home-PBX. On the Travel-PBX, we’re assuming you’d like calls placed from your softphone to be processed exactly as if you were calling from a local extension on Home-PBX. Create an Outbound Route called Home-PBX-Out. For the Dial Patterns, add one for 10-digit calls: NXXNXXXXXX. If you want to be able to reach 3-digit extensions on Home-PBX, add a second dial pattern with a 9 prefix and XXX for the Match Pattern so it doesn’t conflict with local extensions. For Trunk Sequence, choose Home-PBX.

Originally published: Monday, August 20, 2018


Support Issues. With any application as sophisticated as this one, you’re bound to have questions. Blog comments are a terrible place to handle support issues although we welcome general comments about our articles and software. If you have particular support issues, we encourage you to get actively involved in the PBX in a Flash Forums. It’s the best Asterisk tech support site in the business, and it’s all free! Please have a look and post your support questions there. Unlike some forums, ours is extremely friendly and is supported by literally hundreds of Asterisk gurus and thousands of users just like you. You won’t have to wait long for an answer to your question.



Need help with Asterisk? Visit the PBX in a Flash Forum.


 

Special Thanks to Our Generous Sponsors


FULL DISCLOSURE: ClearlyIP, Skyetel, Vitelity, DigitalOcean, Vultr, VoIP.ms, 3CX, Sangoma, TelecomsXchange and VitalPBX have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. As an Amazon Associate and Best Buy Affiliate, we also earn from qualifying purchases. We’ve chosen these providers not the other way around. Our decisions are based upon their corporate reputation and the quality of their offerings and pricing. Our recommendations regarding technology are reached without regard to financial compensation except in situations in which comparable products at comparable pricing are available from multiple sources. In this limited case, we support our sponsors because our sponsors support us.

BOGO Bonaza: Enjoy state-of-the-art VoIP service with a $10 credit and half-price SIP service on up to $500 of Skyetel trunking with free number porting when you fund your Skyetel account. No limits on number of simultaneous calls. Quadruple data center redundancy. $25 monthly minimum spend required. Tutorial and sign up details are here.

The lynchpin of Incredible PBX 2020 and beyond is ClearlyIP components which bring management of FreePBX modules and SIP phone integration to a level never before available with any other Asterisk distribution. And now you can configure and reconfigure your new Incredible PBX phones from the convenience of the Incredible PBX GUI.

VitalPBX is perhaps the fastest-growing PBX offering based upon Asterisk with an installed presence in more than 100 countries worldwide. VitalPBX has generously provided a customized White Label version of Incredible PBX tailored for use with all Incredible PBX and VitalPBX custom applications. Follow this link for a free test drive!
 

Special Thanks to Vitelity. Vitelity is now Voyant Communications and has halted new registrations for the time being. Our special thanks to Vitelity for their unwavering financial support over many years and to the many Nerd Vittles readers who continue to enjoy the benefits of their service offerings. We will keep everyone posted on further developments.
 



Some Recent Nerd Vittles Articles of Interest…


1 Comment

  1. If you are going to be using NeoRouter, why not just install the NeoRouter client on your travel laptop (with the softphone) and connect the softphone directly to your home/office PBX over NeoRouter? Why throw another PBX into the mix?

    [WM: As we noted at the top of the article, if it works, great. We were offering a solution for those cases in which NAT routers at both ends of a call often can cause RTP packets to get lost resulting in audio failures.]

Comments are closed.