Setting up Bandwidth.com IP trunks on Trixbox
by Chris on Oct.18, 2007, under Tech
Previously posted and imported from elsewhere
About a month and a half ago I launched a fully-functional IP phone system at Innova. It’s a TrixboxCE, which is an open-source (although corporate owned/backed, see Trixbox Pro and Fonality) package that utilizes Asterisk. Basically, it’s a preloaded version of CentOS with Asterisk and a few GUI’s that let you configure and manage the system without much command line. I know, I know, you’re already saying “A GUI? You must be a Windows user!” – I am most of the time, but that’s beside the point. Truth told I love command line, but have you ever set up something as big as a PBX with a command line? If you answered yes, click here, because you aren’t going to enjoy much more of this.
Now, let me tell you what I’m not going to address with this post. Pretty much everything about Trixbox. You’re going to get one tidbit about Trixbox – though it’s the most important tidbit you need if you’re going to use Bandwidth.com for your IP trunks. Unfortunately, doing a post on how to set up Trixbox is significantly beyond the scope of an easy blog post. As a matter of fact the best guides I found are over 100 pages. However, I spent a huge chunk of time trying to figure out the correct settings for use with Bandwidth.com because their Asterisk/Trixbox support sucks, and no one else on the internet really seemed to get it either. Hopefully I can save you some time with how I got my trunks to work the way I want.
Setting up your SIP trunk(s):
General Settings
Outbound Caller ID: “Entity Name” <1xxxxxxxxxx>
This should be your company name and main number. Don’t worry, with these settings you’ll be able to override this global caller ID setting if you want.
Never Override CallerID: unchecked
Maximum channels: x
This is the number of channels you have purchased from Bandwidth.com
Disable Trunk: unchecked
Monitor Trunk Failures: not enabled
Outgoing Dial Rules
Dial Rules:
1+NXXNXXXXXX
1614+NXXXXXX
Bandwidth.com (and almost every other provider) requires full 11-digit numbers for outgoing calls; these are my rules to change user-dialed local and long-distance/toll free numbers without the 1 or 1+area code into 11-digit numbers. If you want to force your users to dial all 11 digits, don’t put these rules in and they’ll always fail unless they dial the whole number.
Outbound Dial Prefix: +
This setting is EXTREMELY IMPORTANT, Bandwidth.com requires a + in front of outgoing numbers sent to them. Without this your outgoing calls will fail.
Outgoing Settings
Trunk Name:
Whatever you want to name your trunk, something short and descriptive like Bandwidth-1 would be sufficient.
PEER Details:
allow=ulaw
dtmfmode=rfc2833
fromdomain=xxx.xxx.xxx.xxx
host=xxx.xxx.xxx.xxx
nat=yes
port=5060
type=peer
fromdomain and host are both the IP that Bandwidth.com gives you for SIP traffic. I also set nat=yes because I’m NAT’ing through our super-badass firewalls. If you’re not doing NAT, I think you can set this to no or just don’t include it.
Incoming Settings
USER Context:
Whatever you want, this setting will be over-ridden in the details
USER Details:
canreinvite=yes
context=from-pstn
dtmfmode=rfc2833
fromdomain=xxx.xxx.xxx.xxx
host=xxx.xxx.xxx.xxx
insecure=very
nat=yes
port=5060
type=peer
Registration
Register String:
Bandwidth.com does not need a register string, so this setting is blank.
Overriding caller ID per extension:
This is hella-easy. When you create the extension in FreePBX, enter the Outbound CID like this:
“Entity Name” <1xxxxxxxxxx>
Whatever you enter here will be displayed on the outgoing call instead of the global value set in the trunk. If you leave it blank, the global value will be used.
A few words about NAT…
Your Trixbox is behind a firewall, and you’re only getting one-way sound, huh? You need to create the following NAT rules in your firewall:
SIP: Port 5060 TCP and UDP from the IP’s Bandwidth.com gave you to the internal IP of your Trixbox.
RTP: Ports 1024-64000 UDP from any IP to the internal IP of your Trixbox.
SIP is the carrier of your call signal, and RTP is the media (voice) connection. Bandwidth.com uses several providers for RTP, you have to leave it wide open since it will be coming from always-changing IP’s. But as long as you have your rule for SIP locked down to the IP’s that Bandwidth.com gave you everything should be fine. Your Trixbox will not accept media without the SIP carrier.
Now you need to make two entries into your sip_nat.conf file:
externip = xxx.xxx.xxx.xxx
localnet=xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx
externip is your external IP address and localnet is your internal network/subnet mask. You can use two or more localnet entries depending on how many local network segments you use.
I think that’s mostly the gist of it. If you run across this post and have a question, feel free to comment and I’ll do my best to help. If I can think of any other big pains I ran across, I’ll blog them too.
