FreePBX SIP Trunks (Powered by Schmooze Com Inc)
Easy Setup of FreePBX.com Trunks
THIS DOCUMENT IS OUT OF DATE PLEASE VISIT THE WIKI FOR THE MOST UP TO DATE INFORMATION
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 the FreePBX mirror site. You will want to navigate to the FreePBX version that you are using in the previous link and from there, download the latest version of the sipstation-2.X.X.X.tgz module where you can use the Module Admin upload feature to install it.
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.phonebooth.net and trunk2.phonebooth.net either of which, or both can be used for outbound calling. Although these can both be access by using the SRV DNS entry trunk.phonebooth.net, Asterisk doesn't appear to handle SRV records correctly and you should use trunk1.phonebooth.net 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: [code] disallow=all allow=ulaw [/code] and to include g729 as well: [code] disallow=all allow=ulaw&g729 [/code]
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).
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.phonebooth.net as currently registrations to trunk2.phonebooth.net 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 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: [code] registerattempts=0 [/code] 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).
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.
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 18.104.22.168. 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:
[code] externip=22.214.171.124 localnet=192.168.1.0/255.255.255.0 [/code]
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:
[code] externhost=mydomain.dyndns.org externrefresh=120 localnet=192.168.1.0/255.255.255.0 [/code]
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.
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:
[code] UDP/5060 -> Forward to 192.168.1.100 UDP/10001-20000 -> Forward to 192.168.1.100 [/code]
That is all the setup that is required, you can now start making and receiving calls!
For added redundancy, there is a secondary server that can be used, trunk2.phonebooth.net in addition to the primary server trunk1.phonebooth.net. It is recommended that you repeat all of the above settings for a second trunk and registration to trunk2.phonebooth.net with your same credentials. You MUST have trunk1.phonebooth.net registered to receive calls. The secondary server trunk2.phonebooth.net will only signal inbound calls if trunk1.phonebooth.net were not available.