Easy Setup of FreePBX.com Trunks
FreePBX.com SIP trunks are easy to setup and 100% supported by FreePBX. You not only get the benefit of using one of the world's best VoIP backbone networks that Bandwidth.com has built up over the last decade, but you will be directly supporting the FreePBX project when using these trunks. Also, you will be using a trunking service that is designed to work with FreePBX and Asterisk, not an after thought.
If you have not already purchased service, you can do so by going to The FreePBX.com Trunk Store and signing up for service. Your account and phone numbers will be activated instantly and then you can quickly configure and enable your account.
If you are running FreePBX, as most of you are, you can download the SIPSTATIONTM Module from the online repository to auto-configure your trunks. It should be available on versions 2.5 and beyond. It should also work on earlier versions. If you are running a recent version of trixbox you will not have access to our module from their repository. You can download the latest version from here, sipstation-2.6.0.3.tgz to your desktop and then upload it through the Module Admin.
Once you have an account, configuration is straight forward. In your portal area you will find your SIP Username and SIP Password needed to configure your trunk. In the example next, the SIP Username is 0137fg92 and the SIP Password is fs%7fRtu8 to be used in our example.
Now we go into FreePBX and Setup a new SIP trunk. In this example we are assuming that one of our DIDs (account phone numbers in the portal) is 212-555-1234 and we want to setup dialing so that 7 digit dialing, if enabled in our routes, will be sent out from this trunk with the 212 area code automatically. The next screen shows how to do this. The other fields can remain blank. You do not need to set the Maximum Channels field in your trunks with FreePBX SIP Trunks. If you use more channels than you have purchased, the network will signal congestion properly allowing other fail over trunks to be engaged if you have configured them in your route.
You will notice that we put the 2125551234 into the Outbound Caller ID field. This will be the default CallerID used when extensions do not have their own Outbound Caller ID configured.
Next we must configure the Outgoing Settings to talk to the service. There are two SIP Trunk Servers available on this service, trunk1.freepbx.com and trunk2.freepbx.com either of which, or both can be used for outbound calling. Although these can both be access by using the SRV DNS entry trunk.freepbx.com, Asterisk doesn't appear to handle SRV records correctly and you should use trunk1.freepbx.com for FreePBX. Notice that we will ONLY configure the Outgoing Settings box and leave the Incoming Settings box blank. Using the credentials we showed above, the following settings will properly configure your Outgoing Settings with a trunk called freepbx-rocks:
IMPORTANT: The above assumes you have default codecs configured which include ulaw. The service will work with ulaw and g729 if you have g729 licenses. If you have changed this in your global settings you should add:
disallow=all allow=ulaw
and to include g729 as well:
disallow=all allow=ulaw&g729
The setting of qualify=yes is technically not needed but allows you to monitor the health of the internet connection in Asterisk, and if not doing any port forwarding, keeps the NAT pinhole open. For those of you on the extremely techie side, the setting of insecure=very is correct inside FreePBX. FreePBX will automatically convert this to: insecure=port,invite on Asterisk 1.4 and higher versions. (But if you happen to be setting this up in a raw Asterisk install, then you will want the latter).
Some Asterisk versions have been reported to require the Inbound Settings if you find that incoming calls are not being routed properly, possibly receiving the infamous ss-noservice message. If this happens, then try this for the Inbound Settings:
The last bit we need to configure is the registration string so that the FreePBX.com servers know where to send your inbound calls. This is simply derived from you SIP Username and SIP Password. You should be registering to trunk1.freepbx.com as currently registrations to trunk2.freepbx.com will not function:
Now you should be able to hit submit and your trunk should be able to connect and start making and receiving phone calls.
Asterisk: registerattempts
Asterisk has a configuration parameter of registerattempts which determines how many times it will retry a registration if it is not successful. The default value of 10 is typically inadequate. If you have a short network outage, this can result in your registration going away which will stop inbound calls from reaching your system.
We recommend this be set to 0 by editing you sip_general_custom.conf file and adding:
registerattempts=0
A value of 0 tells Asterisk to try forever until successful. You can also use the Asterisk SIP Settings module to configure this, currently available in FreePBX 2.6, and will be backported to 2.5 shortly (and works now if you want to grab the tarball and install it).
Inbound Route
Don't forget to configure an Inbound Route so your PBX knows where to send incoming calls! The most common cause of support calls that start with "I'm not receiving inbound calls" is either a missing or improperly formatted Registration String or NO Inbound Route. Assuming you have purchased DIDs, your calls will be transmitted as a 10 Digit DID and should be entered as such in your Inbound Route section (or using the shortcut "Add Inbound DID" on the Extension tab for each user. You can also create an Any/Any route which will terminate any DIDs you have not specifically assigned.
NAT Configuration
If your PBX is behind NAT and does not have a public IP address, you are going to have to do some additional configuration. This is required for any type of SIP Trunking service that you may have, or to connect remote SIP phones to your PBX. Although you may find that you are able to register without the subsequent instructions, you should always set these up to get proper and optimal service and not rely on features such as NAT Troubleshooting Mode which may get your service going but may result in non-optimal service and voice quality.
The setup is essentially identical as the first two sections of How to Setup a Remote SIP Extension. The information is summarized here:
Internal/External Network Information
You must edit or create the file sip_nat.conf typically found in your /etc/asterisk directory and make sure it is owned by asterisk. We will assume that you have an internal network of 192.168.1.0/255.255.255.0 and that you have a static IP address of 24.72.182.16. If you have a dynamic IP, see the notes that follow. In this situation, you need to create or edit the following entries in your sip_nat.conf file:
externip=24.72.182.16 localnet=192.168.1.0/255.255.255.0
This tells Asterisk what IP address range is internal vs. external so that it can rewrite the SIP headers appropriately. If you have a dynamic address instead of a static address then you need to modify the above. You will need to have a domain name for the host, let's assume you are using dyndns.com's free service and have chosen the name mydomain.dyndns.org. Then your sip_nat.conf file would look like the following:
externhost=mydomain.dyndns.org externrefresh=120 localnet=192.168.1.0/255.255.255.0
Where externrefresh tells Asterisk to recheck the IP address every 120 seconds in this case. You should adjust this higher or lower based on the frequency that this changes.
Firewall/Router Configuration
The default installation of FreePBX is configured to use UDP port 5060 as the SIP signaling port and UDP ports 10001-20000 as the RTP Media ports. All these ports must be forwarded to your FreePBX System. How to do this varies widely depending on the firewall or equipment that you are using. It is commonly referred to as Port Forwarding or maybe Destination NAT (DNAT). However it is referred, if we assume in this example that your FreePBX system has an internal IP address of 192.168.1.100 then you will want:
UDP/5060 -> Forward to 192.168.1.100 UDP/10001-20000 -> Forward to 192.168.1.100
That is all the setup that is required, you can now start making and receiving calls!
Related Content
- Printer-friendly version
- Login or register to post comments



SIPSTATION
If you are using the SIPSTATION module you need to configure your UDP forwarding for 10000 thru 20000 or your run firewall test will fail. The "unused" port that the firewall test selects is 10000 resulting in the the test fail if that port isn't included.
actually the 'unused' port
actually the 'unused' port that the firewall uses will be the lowest unused port based on the rtp.conf configuration. If you have 12000-16000 as your port range, and there is currently a call using 12000 for its media, then the firewall test would end up testing on 12002.