If you’ve been following along through the introduction, part 1, and part 2, you now have a PBX in a Flash (PiaF) setup running under Microsoft Virtual Server. It’s keeping time, it knows who it is and can send out mail. Now it is finally time to configure the PBX itself!
Setting up the PBX involves a few steps:
Updating and Adding FreePBX modules
Configuring Trunks, Extensions, and Routes
Configuring Other Features
As in part 2, I’ll be following Ward Mundy’s “knol,” the Nerd Vittles Step-by-Step 1.3 Tutorial, starting at the section Updating and Configuring FreePBX. This time, however, my instructions will relate much more specifically to the installation that I’m implementing, so I’ll be skipping some of Ward’s recommendations and pulling together a few of my own. Let’s get started!
Updating and Adding FreePBX modules
FreePBX comes pre-loaded with several basic modules. It also provides an online repository of about two dozen additional modules that can make it one very powerful phone system indeed. Follow these steps to update the current modules and get all the new ones.
- In a browser, open the IP address or DNS name of your PBX.
- From the PBX in a Flash menu, in the lower left corner, click on Admin. This adds a few buttons to the screen.
- Click on the FreePBX Administration button. Type
maint
as the user name. Use the password that you assigned usingpasswd-master
near the end of part 2. This loads the main FreePBX administration screen, which will be our starting point for the rest of the tasks this article. You might want to bookmark this page so you can return here directly without going through the PiaF button top-level screen. - The left column has two tabs, Setup and Tools. From the Setup tab, click on Module Admin. This shows the (relatively short) list of currently-installed modules.
- At the top of the Module Administration page, click on the link Check for Updates Online. Now you will see all modules that are available.
- Click on the Download All link. Then click on the Upgrade All link. This simply selects everything for downloading and upgrading; it doesn’t start the download and upgrade process. If you want, you can deselect specific modules that you know you won’t be using.
- According to Ward (and he should know), a couple modules need to be installed last.
– Under CID & Number Management, change Speed Dial Functions to No Action.
– Under System Administration, change PHPAGI Config to No Action. - Scroll to the bottom of the page. Click on Process. Scroll to the bottom of that page. Click on Confirm. An orange popup window appears where you can monitor the progress of the installations. After a few minutes, when you scroll to the bottom of the orange popup, you’ll see a Return link. Click on Return.
- Now we can download and install the two modules that we skipped above. Click on Check for Updates Online, Download All, Process, and Confirm. (In addition to Speed Dial Functions and PHPAGI Config, I see that it still needs to install two options under Inbound Call Control: Blacklist and Caller ID Lookup. Maybe those modules depend on the two that we skipped before. I’ll leave them all selected this time.) When the orange popup finishes the installs, click on Return.
- Scroll down the list of modules to the Maintenance section. Click on ConfigEdit, Sys Info, and phpMyAdmin. Under each one choose Install. (Don’t install A2Billing Admin unless you need it.) Scroll to the bottom of the window, click on Process, and Confirm. The orange popup gives you the option to Return almost immediately.
- At the top of the Module Administration section, you should see a thin orange bar that says “Apply Configuration Changes.” Click on that link and an orange popup appears. Click on Continue with Reload to finish reloading the Asterisk configuration files.
Note: This two-step apply/continue process is necessary after any change to the Asterisk configuration. Whenever you see that orange bar, make sure no one is on the phone and then click on it to apply the changes! From now on, I’ll simply say “Apply and Continue” to indicate this procedure. - Ward recommends updating the system modules now. Oops! We did that in step 6 already when we selected Upgrade All. Seems to work fine that way too!
- Any time you want to disable or uninstall modules (maybe you don’t need call queuing for your home office), come back to the Module Administration page, click on the module, and choose Disable or Uninstall. Then go through the by-now-familiar Process, Confirm, Return, Apply, Continue steps.
Configuring Trunks, Extensions, and Routes
I hope Ward doesn’t mind me quoting an entire paragraph verbatim, but there is no better way to put this: “There are four components in FreePBX that need to be configured before you can place a call or receive one from outside your PBX in a Flash system. So here’s FreePBX for Dummies in less than 50 words. You need to configure Trunks, Extensions, Outbound Routes, and Inbound Routes. Trunks are hosting provider specifications that get calls delivered to and transported from your PBX to the rest of the world. Extensions are internal numbers on your PBX that connect your PBX to telephone hardware or softphones. Inbound Routes specify what should be done with calls coming in on a Trunk. Outbound Routes specify what should be done with calls going out to a Trunk. Everything else is bells and whistles.”
Let’s take those one at a time. Note that I’ll only show setting up one analog trunk and one analog extension to connect to my Linksys SPA3102 ATA. You’ll want to set up the ATA at the same time as the PBX. However, to keep this post focused on the PBX, I’ve split out the ATA instructions into a separate post titled Setting Up PBX in a Flash, Part 4: Configuring a Linksys SPA3102. My setup will use one SPA3102 for the incoming business line and the analog business phone, and another SPA3102 for the personal line and phone. These steps use the personal line and phone as an example. All configurations are for a system operating in San Diego, California.
Set Up a Trunk
Follow these steps to set up a trunk to connect to the FXO (PSTN) port of the SPA3102:
- From the FreePBX main menu, click on the Setup tab. Under Basic, click on Trunks. From the Add a Trunk page, click on Add SIP Trunk.
- Under Outgoing Dial Rules > Dial Rules, add the following lines. Change “619” to your area code. By the time it reaches the trunk, numbers will be formatted as 7 or 10 digits (more on that under Set Up Outbound Routes below). These lines instruct the trunk to strip off “619” or “1619” if dialed with the number, and to prepend “1” to any other ten-digit number.
619|NXXXXXX
1619|NXXXXXX
1+NXXNXXXXXX - Under Outgoing Settings > Trunk Name, enter “Personal” (for example).
- Under Outgoing Settings > PEER Details, remove the default text and enter these lines, replacing the “secret” value with a secure password:
context=from-trunk
host=dynamic
username=Personal
secret=<same password as configured as password spa3102 PSTN Line tab>
type=friend
dtmfmode=RFC2833 - Under Incoming Settings > USER Details, remove the default text. Leave this box empty.
- Scroll to the bottom of the screen and click on Submit Changes. At the top of the window, click on Apply Configuration Changes, then in the orange popup window, click on Continue with Reload.
- Now that you have configured a trunk, you can delete the default Zaptel trunk, since we aren’t using Zaptel. In the upper right corner, click on Trunk ZAP/g0. Then at the top of the screen click on Delete Trunk g0. Apply and Continue.
Congratulations, your trunk is set up! You may want to set up the PSTN Line tab in the SPA3102 before continuing.
Set Up an Extension
Follow these steps to set up an extension so you can connect an analog phone to the FXS (Line 1) port of the SPA3102:
- From the FreePBX main menu, click on the Setup tab. Under Basic, click on Extensions. From the Add an Extension page, from the Device drop-down, select Generic SIP Device, then click on Submit.
- Under Add Extension > User Extension, enter “20” (for example–I’ll use 2-digit extensions for my home office setup).
- Under Add Extension > Display Name, enter “Personal”.
- Under Device Options > Secret, enter a password for the extension. This is not the voicemail password! It is the password that you configure in the SPA3102 Line 1 tab so that the SPA3102 can register with Asterisk. Make it a secure one so anyone who gains access to your network will not be able to also use your PBX.
- Under Voicemail and Directory:
– Set Status to Enabled.
– Set Voicemail Password to a numeric password.
– Set Email Address to the address where you want to receive voicemail by email.
– Set Email Attachment to Yes.
– Optionally set Play Envelope to Yes.
– Under VM Options, enter “callback=from-internal”. This will allow you to call back the caller by choosing Advanced Options when listening to a message. See the NerdVittles article Tricking Out Your Trixbox for more information.
Note: Hover the mouse over any of the options with a dotted underline for an explanation of what the option does. - Scroll to the bottom of the screen and click on Submit Changes. Apply and Continue.
Your first extension is now configured! Again, you should make the corresponding setup in the SPA3102 Line 1 tab before continuing.
Check for SPA3102 Registration
At this point, your SPA3102 should be successfully registering with FreePBX/Asterisk. To check this, from the FreePBX administration screen, click on the Setup tab, then click on FreePBX System Status. Under FreePBX Statistics, you should see one IP Phone and one IP Trunk online. Sometimes these values are not completely accurate (e.g. if the SPA3102 was registered, then powered down).
To double-check, go to the SPA3102’s web interface. Under the Voice > Info tab, look for the Registration State values in the Line 1 Status and PSTN Status sections. Both should say “Registered”.
If the SPA3102 isn’t registering, try forcing a reboot of the SPA3102 by unplugging it and plugging it back in, then check the above values again. If registration is still failing, review the steps above.
Set Up Outbound Routes
Even though your SPA3102 is registering, you won’t be able to call out until you tell FreePBX how you want your calls routed. For that you need at least one Outbound Route.
If you read the introduction to this series, you know that one of the things I wanted to do was set up least-cost routing. Asterisk has very flexible rules that allow me to do that. At this point, we are only setting up one outbound line, so the routing is rather dull–everything must go out on the same line (trunk). To spice things up, we’ll add in a few extra routes so that when we add additional trunks in the future, we can ensure that some calls always go out on the Personal trunk.
- From the FreePBX main menu, click on the Setup tab. Under Basic, click on Outbound Routes.
- First let’s delete the default route. In the upper right corner of the Add Route page, click on 0 9_outside. Click on Delete route 9_outside, then Apply and Continue.
- Let’s assume we want all calls to x11 (211, 611, 911) to route to the Personal trunk. (This is actually desirable because this trunk goes to my an analog home phone line. This is the number the pops up my address for the 911 operators.) Set up the first outbound route as follows:
– Route Name: 211-Thru-911
– Dial Patterns:N11
– Trunk Sequence: SIP/Personal
Click on Submit Changes. We’ll Apply and Continue later. - Next, let’s set up a route that allows selecting this specific trunk by dialing “98” before making the call. This isn’t really necessary with only one trunk, but after adding more trunks, it is sometimes desirable to be able to override the least-cost defaults and dial out on a specific trunk. Click on Add Route and set up this route as follows:
– Route Name: 98-UsePersonal
– Dial Patterns (only pass along 7- or 10-digit number to trunk):
981|NXXNXXXXXX
98|NXXNXXXXXX
98|NXXXXXX
– Trunk Sequence: SIP/Personal
Click on Submit Changes. - The next route is for local and toll-free numbers. Even if we had a separate ATA to handle long-distance, we want these local numbers to dial out on the Personal line, which includes unlimited free local calls. “Local” in my area means numbers within a certain radius, and can include prefixes in both the 619 and 858 area codes. Click on Add Route and set up this route as follows:
– Route Name: LocalOrTollFree
– Dial Patterns Wizards: select TollFree and you’ll see this fill in the Dial Patterns. Put a pipe (|) after each “1” so the “1” (if dialed) will be stripped off before the number is passed to the trunk:
1|800NXXXXXX
1|888NXXXXXX
1|877NXXXXXX
1|866NXXXXXX
– Dial Patterns Wizards: select TollFree again. This time, remove the leading “1”s so that you can dial the number without dialing the 1:
800NXXXXXX
888NXXXXXX
877NXXXXXX
866NXXXXXX - – Dial Patterns Wizards: select Lookup Local Prefixes. In the popup box, enter your area code + prefix and click on OK. Then sit back and watch the magic! That’s right, FreePBX just filled in every area code and prefix that is a free call for you. Feel free to double-check these against the phone book :). Actually, you may find that there are prefixes that you dial regularly that need to be added to this list.
– Trunk Sequence: SIP/Personal
Click on Submit Changes. - Our last outbound route will be for all long distance calls. Click on Add Route and set up this route as follows:
– Route Name: LongDistance
– Dial Patterns (capture international and all remaining 10-digit numbers):
011.
– Trunk Sequence: SIP/Personal.
1|NXXNXXXXXX
Click on Submit Changes. Note that if you add a cheaper long-distance trunk later on, you can adjust the Trunk Sequence to make this route use the cheaper trunk first. - You should now see four routes listed in the upper right corner of the Edit Route page. Use the up and down arrows to adjust their precedence if necessary. When you’re satisfied, click on Apply, then Continue.
The downside to having this huge list of local prefixes defined in step 5 is that it now takes considerably longer to Apply Configuration Changes. If you prefer, you could change this rule to remove all those local prefixes and only include the toll-free numbers, all 7-digit numbers (NXXXXXX
), and all 858 numbers (1|858NXXXXXX
).
Set Up an Inbound Route
Our last step in this section is to set up an inbound route:
- From the FreePBX main menu, click on the Setup tab. Under Inbound Call Control, click on Inbound Routes, then Add Incoming Route.
- Under Add Incoming Route, set these values:
– Description: Personal
– DID Number: Personal (corresponds to the User ID configured in the SPA3102 PSTN line) - Under Options, set this value:
– CID Name Prefix: P- (this adds a “P-” prefix to Caller IDs that come from the Personal trunk) - Under Fax Handling, if you are setting up faxing as described in this Nerd Vittles article, set these values:
– Fax Extension: FreePBX default (use value from General Settings–see below)
– Fax Email: [leave blank] (use value from General settings–see below)
– Fax Detection Type: NVFax
– Pause After Answer: [leave blank]
Note: These values differ from those used in the Nerd Vittles article. In particular, leaving Pause After Answer blank, indicating that no pause is needed, seems to work fine. If you follow call progress in the Asterisk Command Line Interface (asterisk -r -vv
at a CentOS prompt), you’ll see that NVFaxDetect adds its own 4-second delay. An additional delay here is apparently not needed. - Under Set Destination, select this value so this route will immediately ring extension 20:
– Extensions: <20> Personal - Scroll to the bottom of the screen and click on Submit Changes. You’ll see a popup message warning you that you have entered a non-standard DID pattern. Click on OK. Then Apply and Continue.
That’s it! One you connect your telco and analog phone lines to the SPA3102, you should now be able to make and receive calls. Try dialing 611 to test the first route. (If you want to test 911, call the non-emergency police or dispatch number first to ask permission.)
Don’t be surprised that FreePBX takes a few seconds to start ringing the internal extension. That’s due to the 5-second PSTN Answer Delay that we set in the SPA3102. That allows the SPA3102 to detect the incoming Caller ID, which is delivered between the first and second rings. If you don’t care about Caller ID, you can set PSTN Answer Delay to zero.
Configuring Other Features
As you can imagine, there are tons of additional things that you can set up in FreePBX!
General Settings
It’s worth making the following changes to General Settings now:
- From the FreePBX main menu, click on the Setup tab. Under Basic, click on General Settings.
- To enable call transfers and call recording under Dialing Options, set these values:
– Asterisk Dial Command Options: tTrwW (default is “tr” if you want to revert later)
– Asterisk Outbound Dial Command Options: TwW (default is blank if you want to revert later) - Under Voicemail, I’ve found that I prefer these settings:
– Optional Voicemail Recording Gain: 10
– Do Not Play “please leave message after tone” to caller: checked - Under Fax Machine, make these settings:
– Extension of fax machine for receiving faxes: system (sends to email address)
– Email address to have faxes emailed to: [email protected]
– Email address that faxes appear to come from: [email protected] - Under Online Updates, make this setting:
– Update Email: [email protected] - Click on Submit Changes, then Apply and Continue.
Voicemail
One thing you’ll want to do is record your voicemail greetings. Dial *97 from your extension and follow the prompts. To manage your voicemails (and lots more) in a browser, from the FreePBX main menu, click on the small Recordings tab at the top of the screen, then log in with your extension number and voicemail password.
On the topic of web management of voicemail, when you receive voicemails via email, you’ll notice a link that includes the string AMPWEBADDRESS. Here’s how to update that:
- From the FreePBX main menu, click on the Tools tab, then under Maintenance, click on Config Edit. This opens a window in the right pane where you will see all of the nitty-gritty Asterisk configuration files.
- In the gray bar at the top of this pane, click on the
/etc/asterisk
directory. The files in this directory are listed. - Click on the
vm_email.inc
file to open that file. - Scroll to the right until you see “AMPWEBADDRESS”. Replace that string with the IP address or DNS name of your FreePBX machine, e.g. mypbx.mydomain.local.
- At the bottom of the edit window, click on Update.
- In the gray bar at the top of the pane, click on the link at the far right side:
Re-Read Configs
. This reloads the configuration files.
The next time you get a voicemail by email, you can click on the link to load the voicemail web interface!
Internal and Outbound Faxing
See the Nerd Vittles article on faxing if you want to set up extensions for internal and outbound faxing. One thing worth doing now is to to use the Config Edit tool described just above to edit the [faxit] context at the bottom of /etc/asterisk/extensions_custom.conf.
Change the LOCALHEADERINFO
value to the name to be displayed on outbound faxes. Change the LOCALSTATIONID
value to the fax number to be displayed on outbound faxes.
Going Further
A few suggestions on where to go from here:
- Many features are accessible via feature codes. From the main FreePBX menu, click on the Setup tab, then under Basic, click on Feature Codes to see the whole list.
- The list of installed modules under the FreePBX Setup tab should also give you some ideas about built-in capabilities. Set up an auto-attendant (IVR). Create speed dial numbers. Blacklist numbers by Caller ID. Set up groups of phones to ring at the same time. Change which phones ring during business hours and afterwards.
- While you were setting up the extension above, you may have noticed the VmX Locatorâ„¢ option at the bottom of the extension screen. FreePBX has some amazing abilities for automatically hunting you down–if you want it to. Setting that up is beyond the scope of this article, but for more information. see the FreePBX article Follow Me or VmX Locaterâ„¢ – Which One is for You?
- One of the advantages of having an Asterisk-based systems is that its use is so widespread that lots of people develop add-ons for it. A good resource for those add-ons is the Nerd Vittles site. They have enough tips for FreePBX and Asterisk to keep you occupied for months! Want to set up automatic backups? How about getting weather by zip code? Click-to-dial any number you see in a Firefox browser? The list seems endless.
Before going too far, make one more backup of your working, configured PBX in a Flash virtual machine. Call it something like “PiaF.4.With installation-specific updates, after FreePBX configuration.zip”. Finally, you may want to turn off Undo Disks in Virtual Server to make things run a bit faster.
Enjoy your new PBX!
I do have a little problem: after receiving an inbound fax message (which works flawlessly, accepted message is in perfect shape) the PIAF does not hang up the PSTN trunk that had been used for receiving (in fact, after activating of the fax modul the system behaves so for all incoming calls, including fax messages). I guess the fax module does not detect end of the call and therefore does not send the hangup command onto the PSTN gate concerned). I would really appreciate any tipp or guide as to what to do to get this fixed…
Hi there
Many thanks for the advice that you have posted, has helped me out a great deal, but am after a bit more advice if possible.
I have a SPA3000 set-up as the PSTN interface to a FreePBX setup running on a Raspberry Pi. The trunk registers fine and I can dial in and phones connected to the associated ringgroup all ring as expected, but I am unable to answer the call. When you pick up a phone it appears to drop the call and then instantly starts to ring again. This happens on all attached handsets.
All extensions are able to call each other, so am happy that the PBX is working correctly as it should there.
Am also unable to make any outgoping calls onto our company network. I think this may be to do with dial plans being incorrect but am not sure how to correctly configure them so as to achieve my aim.
What I am after is that three digit numbers are dialed between local phones, 4 digit numbers are routed out of the PSTN/on site exchange line and then dial other extensions that are connected to the company exchange. This should be achieved without the need to dial 9 for an outside line too. I alos need it so that we are able to use the current facility of dialling national numbers (01234 567890 as example) which at present using the current company exchange is achieved by dialling a 0 infront of the number we wish to dial. There is also a facility for dialing other company exchanges too which needs preserving. These are in the format of 91234 5678.
Sorry to be so needy and ask for the moon on a stick, but am getting rather desperate trying to sort this out as have been taking one step forwards and 2 back for over 2 months now on this and have very littel hair left.
Many thanks in advance for any help, advice and assitance.
Paul, I feel your pain but it has been years since I have set up an Asterisk box and never Raspberry Pi. I found the people over at the PBX in a Flash forum to be very helpful:
http://pbxinaflash.com/community/index.php
There is also a FreePBX forum:
http://www.freepbx.org/forums
Hopefully someone in one of those forums will be able to get you over some of these hurdles.
Hey Paul,
Are you able to solve the problem, I am facing similar problem , When I pick up the call , it drops.
Looking forward for your response.
Thanks