DIY Home IP-PBX Setup Guide
DIY Home IP-PBX Setup Guide
The state of open source software has progressed to the point where you can set up your
own IP PBX at home in a single evening, with a minimum of investment needed. All
you need is explicit instructions, which is what I provide here.
In past times, it would have been quite costly to have a “personal” PBX. Using spare
hardware, open source software, and low-cost service providers, it can now be done for
almost nothing. The key advance is the open source Asterisk IP PBX and the
Asterisk@Home package that includes Asterisk and a web-based GUI configuration
tool.
The Components
Your will have to set up three main components: the IP PBX itself, the phones (or
softphones) to be used with it, and the gateway service that lets you call other people on
the PSTN. I will describe how to set up each of these. I assume you already have a
home network and broadband access. If you are behind a NAT firewall, it does not
matter – you don’t have to do anything special like running the IP PBX outside the
NAT. All that matters is that you have enough bandwidth (upstream and downstream)
to carry voice traffic.
The IP PBX
You will need a computer to run the IP PBX. While you may already have a Linux
server at home, I do not recommend using it to also run your phones. If you want to do
that, you will have to figure out how to load and configure the PBX software on your
own, although the rest of the instructions here will be helpful.
If you have an old PIII class machine lying around, then use that. If not, you can buy
one on EBay for about $40.
I used a Dell OptiPlex GX1, a PIII 450MHz system with 128M RAM. It has a built-in
sound and Ethernet, so no additional hardware is required.
You will load Asterisk@Home on this computer. It will take it over – it starts by
formatting the hard disk, so make sure there is nothing on the machine that you want to
keep. Detailed instructions are given below.
Phones
You can buy SIP phones from Grandstream, SNOM, Cisco, even Avaya. Or you can
buy an adapter from SNOM or Cisco and use an analog phone. To get started, though,
it is easiest to get a softphone and run it on another computer. We will describe how to
obtain and install the XLite softphone on a Windows machine to use for a phone. You
will also use this Windows machine to administer the IP PBX, through a browser. If
you want to use a Linux machine instead, you will need to get an appropriate softphone
for it, but you can still use its browser to administer the IP PBX.
SIP Gateway
I presume you want to communicate with others on the PSTN network, so you need to
obtain gateway service. Since part of the call is being carried on the circuit switched
network, it costs real money. This means you will have to pay for this part of the
system.
I will describe how to set up access to two services, one for outgoing calls and another
for incoming calls.
VoipJet is used for outgoing calls. It is priced at 1.3 cents per minute (USA), with no
monthly minimum or service charges.
BroadVoice is used for incoming calls. You get a phone number (you can choose the
area code and exchange). They have various plans, but I signed up for one that is $5.95
per month, with unlimited incoming minutes. You can also make outgoing calls using
this account (it includes 100 minutes per month, and 3.9 cents per minute additional).
There is a $9.95 one time activation fee to sign up for BroadVoice.
So if you have the hardware, you can set up your IP PBX for a total of $9.95 and run it
for $5.95 per month.
Home Network
I assume you have a home network, and that you are setting up behind a Gateway
Router (otherwise known as a NAT firewall). You will need to pick a static IP address
for your IP PBX that is on your home network.
If you already have a spare computer that you can dedicate to this project, there is no
cost at all for equipment, unless you need to buy an audio headset for the softphone. If
you do not have a spare computer, then you can buy one on EBay for about $60,
including shipping. This does not include a monitor, but you don’t need a monitor
except briefly when you first set it up. I assume you can borrow a monitor (or that you
have a KVM switch).
Your only other initial cost will be the $9.95 activation fee to BroadVoice.
Your monthly cost will be $5.95 for incoming service from BroadVoice, and 1.3 cents
per minute for outgoing calls to VoipJet. If you only make a few outgoing calls, you
could drop VoipJet, and stay within the 100 outgoing minutes that you get from
BroadVoice. If, say, you use 100 minutes of VoipJet outgoing calls, it would cost an
additional $1.30.
So you can build and experiment with your own IP PBX for an investment of less than
$100, and for an ongoing cost of less than $100 per year. This is a lot less than I am
now paying for my phone service from AT&T. In fact, a whole year’s service would be
less than my monthly phone bill. Hmmm…
VoipJet
Browse to
http://www.voipjet.com. Sine up for service. Then log on and follow the line describing
how to set up Asterisk. You will need to copy down your “VoipJet account number
(username),” your “Authorization code (password),” and your server IP address
(depending on your location). Ignore the rest of the setup instructions.
BroadVoice
You should also click on the “Support Center” link on the left and bring up the “Step By
Step Installation Guide” for “Bring Your Own Devices.” Select “Asterisk.” You must
follow the instructions in Section 3 to find the “right proxy” to use. This involves
pinging their proxies to find which has the lowest latency. You will use this later.
2. Pick the one with the lowest latency. In my case, it was
proxy.dca.broadvoice.com.
It should look something like this.
The phone will try to register, but for now it will fail.
Introduction
AAH is a package consisting of several major components. These were developed and
supported relatively independently. The “Asterisk” part is the core IP PBX, and the
“@Home” part consists of applications, a provisioning system, an installer, and an
operating system that, together, make a complete package. The major components that
make up AAH are
Load AAH
This is going to reformat your hard disk and load everything from the operating system
on up, so make sure there is nothing on the hard drive that you want to save.
Boot your machine from the CD. When it prompts, type ENTER. Then wait as
everything loads and compiles. This could take 30 minutes or more, depending on how
fast your computer, hard drive, and CDROM are. At the end, it ejects the CD and
reboots from the hard drive.
username: root
password: password
Set Up Networking
The machine probably got an IP address from DHCP, but it is not what you want. Log
in as root and run:
netconfig
IP address: 192.168.0.40
Netmask: 255.255.255.0
Gateway: 192.168.0.1
OK these changes, then reboot the machine to make them take effect.
After reboot, long in once more. You need to add the BroadVoice server IP address
to /etc/hosts.
sip.broadvoice.com 147.135.0.128
Here the IP address was the one obtained when signing up with BroadVoice.
Once this is done, you can do the rest of the configuration through the web.
Browse To AMP
From your web browser, go to http://192.168.0.40. You should see the following:
Select “Asterisk Management Portal.” Log in as follows:
username: maint
password: password
Click on “Trunks” and then “Add SIP Trunk.” You see a blank SIP trunk form.
You will need to fill out the main items on the SIP/Trunk screens. I am using
BroadVoice for incoming service only, so I will not administer outgoing trunk
information.
The outgoing settings can be left as is, except to fill in the trunk name as
BroadVoice.
7327570239@sip.broadvoice.com:**********:7327570239@sip.broadvoice.com
/200
Once all of this information is entered, you can click the Submit button. Once you do,
a red line will appear at the top of the page. To "apply" your changes you must click
this red line (this will cause AAH to tell the Asterisk engine to reload its config files).
Click on “Trunks” and then “Add IAX2 Trunk.” You see a blank IAX2 trunk form.
The outgoing dial rules control how numbers are processed before they are sent to the
trunk. In the case of VoipJet, phone numbers must be in the form “1+Area Code+Local
Number”. If the number appears to have an area code but not a “1”, then it is added. If
it does not have an area code, then “1732” is added (I am in area code 732). So the dial
rules are:
1+NXXNXXXXXX
1732+NXXXXXX
You can leave the “Incoming Settings” and the “Register String” blank.
Set Up Extensions
Now it is time to define the extensions. I will set up two extensions, number 200 in the
basement and number 201 in the study. I have already shown how to configure XLite
extension 200, and you can configure another extension like it for 201. Or you can set
up a SIP phone instead.
Click on “Extensions” on the left, and “Add an Extension.” You will see the extensions
page.
Extension: 200
Password: abc123
Full name: basement
Voice Mail Password: 1234
Email Address: <your email address>
When you're finished adding the extension, you can see the details of the extension by
clicking on its name on the right-hand side of the AMP interface (as shown above).
Add extensions 201 similarly. Remember to click on the red bar, to make Asterisk take
not of your changes.
At this point, the XLite application should have registered with AAH. If not, exit XLite
(you have to stop it from the tray icon) and restart. It should say “Logged in”. If not,
see the troubleshooting section below. To start with, make sure you have assigned the
same password in the extension form and in the phone.
Now we set up a ring group, so that we can ring all the extensions at once. This is
useful, for instance, so that incoming calls can alert at all extensions.
On the left, click “Ring Groups” and on the right “Add Ring Group”.
Fill out the form as follows:
Group Number: 1
Extension List:
200
201
Ring Time: 18
Destination if no answer: Voicemail basement <200>
>
Submit the changes, and click the red bar to make them take effect.
Click “Digital Receptionist” on the left. Enter 200 as the current extension number.
On XLite, dial *77 and record a message. It goes something like this:
Hello. You have reached Charles Hayden’s experimental Asterisk phone system. You
can dial a three digit extension. Dial 1 to ring all extensions . Or dial pound for a
directory.
On the next page, for “Number of options for Menu top greeting enter 1.
On the next screen, choose “Ring Group #1” as the action. This means that when
the caller enters “1” it will go to Ring Group #1, which rings all extensions.
The dial patterns given here will allow you to dial international calls, long distance with
1+area code, and calls within the 732 area code with only the area code but without the
1. This is how it works here in the 732 area. If you can dial locally without the area
code, then you could add “NXXXXXX” as well. As we have seen, the trunks cannot
necessarily accept all these dialing combinations, so they have their own rules to screen
and transform them.
If you've made it this far you should be able to dial "7777" on your SIP phone - this will
simulate an incoming phone call - and you should hear your greeting. At this point the
system should have enough functionality to dial out through VoipJet.
Go ahead and call a number and it should ring at the other end. Remember that you need
to dial 1 followed by a 10 digit number. If it does then pat yourself on the back! Only a
few more steps are needed to get incoming calls to work (you can try to call your
BroadVoice number, but it won't work yet).
Now we will set up incoming calls to go to the digital receptionist. Choose the
“Incoming Calls” link, and click the “Digital Receptionist” “top greeting”.
Edit extensions.conf
So far we've done everything through the AMP web GUI. Now we have to drop into
editing text files. This is obviously not desirable, but this is how it is right now, so you
have to go through this. You can edit extensions.conf through the AMP web GUI.
Click the Maintenance link at the top of the AMP page and then click the Config
Edit link in the left-hand menu. Then click on extensions.conf.
Look on the left for from-sip-external and click it. By default, AAH sends all
incoming SIP calls to a congestion status. This means that all incoming calls will ring
fast-busy to the caller and they will never make it into our AAH system.
There are four lines under the [from-sip-external] section. One is already
commented out with a semi-colon (;). Comment out the remaining three lines by adding
semi-colons. Now we need to add two new "exten" lines.
which tells AAH to wait for 1 second once a call has been detected from an external SIP
device. This makes sure we don't clip off the first part of our greeting message. The
second line we need to add is:
[from-sip-external]
;give external sip users congestion and hangup
;exten => _.,1,AbsoluteTimeout(15)
;exten => _.,2,Congestion
;exten => _.,3,Hangup
When you're finished and you've saved your changes, you need to click the link at the
top of the config edit screen labled Re-Read Configs. This will cause Asterisk to
reload its configuration files and make any changes take effect.
Now is the moment of truth. If everything went smoothly, you should now be ready to
test an inbound call to your AAH system. From a phone (POTS or cell, either will do)
dial your BroadVoice number. You should hear your greeting! At this point you'll
probably be giddy that it's all working. Go ahead and listen to your greeting a few times
(dial 9 to repeat it). Then either dial "1" or your extension and your SIP phone should
start ringing. You now have Asterisk@Home configured and working with your
BroadVoice account.
Set up Passwords
You need to change the default passwords, so that people do not break into your
system. There are a variety of passwords, used for different things.
AMP allows you to assign different login accounts to access the Maintenance section
separately from the other sections (Setup, Reports, and Panel). If you log into AMP
with the maintenance account, you will be able to access everything, but if you log in
with the admin account, you will have to log in also to get to the maintenance section.
To change these passwords, you must log into the console as root, either on the physical
console or using a ssh client such as putty (which can be obtained from
http://www.chiark.greenend.org.uk/~sgtatham/putty/) from a windows platform or using
ssh from a Linux platform.
Troubleshooting
If things did not work the first time, you can track down the trouble using the Asterisk
console. This can be used to display SIP messages coming through the system, as well
as steps executed in interpreting the dial plan instructions.
If you are more comfortable using Ethereal, you can use that instead (or also) to see the
SIP messages. I will not describe how to download or configure it, other than to point
out that it can be obtained from http://www.ethereal.com.
To use the Asterisk console, go to the Linux console or enter through ssh. Remember
the username is root and the password is password. Give the command:
asterisk –vvvvr
This will attach to the console with verbose mode set. Give the command
sip debug
to enable SIP debugging. You can turn off SIP debugging using the command
sip no debug
If you are having trouble making outgoing calls, check the username and secret in the
IAX2 trunk. Make sure you can ping the host address listed there. The username is a 4
digit number that you find from your account settings on VoipJet.
On a message trace, you should see an INVITE going out, followed by receipt of
TRYING and OK (when the far end answers). If there is no response, then perhaps you
have the wrong IP address. If the INVITE is immediately followed by a 4XX or 5XX
error, maybe the username or password is wrong.
Incoming calls
If the incoming BroadVoice trunk is set up properly, Asterisk will register successfully,
and will renew the registration every 10 seconds. Look for an outgoing REGISTER, a
challenge, another outgoing REGISTER with credentials, and an incoming 200 OK. If
you get no response, or either REGISTER yields an error reply, then look at the host,
secret, and user fields from the SIP trunk.
If the REGISTER succeeds, then when you call (from a POTS phone) you should see an
INVITE being received. If you have not properly changed extensions.conf, then
the system will reply with an error rather than with TRYING. Look at the debug output
to see how the INVITE is being processed. You should see the Wait and the GoTo
that you entered into extensions.conf. If you see these, and the call is still not
answered, you might want to change Incoming Calls to route the call to a specific
phone, for instance to “basement <200>”. This will bypass the Digital Receptionist
and the Ring Group for now. If this fixes things, look at those two screens. If not, make
sure the “context=from-pstn” is present in the incoming trunk user details. If this
still does not fix things, you will have to follow the trace as it steps through the contexts
and steps in extensions.conf.
More
This section describes some things you might want to do to further customize your
system. I am experimenting myself, and presenting the results here. These instructions
might not be the most effective way to achieve the desired results. If you find a better
way, please let me know. The instructions in this section are briefer, reflecting your
increased level of experience with AAH.
You can modify the digital attendant so that it can read the weather to callers.
Remember to modify your digital attendant announcement recording if desired (“press
2 for weather”).
1. Modify the Digital Receptionist. For “Number of options” give “2”. On the
next screen, for option 2, give “Custom App” and enter
custom weather,s,1
2. Go into “Maintenance”, “Config Edit”, “extensions_custom.conf”. At the end,
add:
[custom-weather]
exten => s,1, Goto(from-internal-custom,*61,1)
You can customize the weather for your own city be editing
/var/lib/asterisk/agi-bin/weather.agi. You need to edit $custpath
and $filename. Don’t forget to modify the announcement a few lines down. You
can ftp to weather.noaa.gov and cd to data/forecasts/city to see the
state/city combinations that are available.
Outgoing BroadVoice
You can set up the BroadVoice trunk to carry outgoing calls. Since you get 100 “free”
minutes per month, you might want to use these up first, before switching over to
VoipJet. It would be great if the system could do this for you, but for now there is no
easy way to do this. So instead, let’s up a dial-9 trunk for BroadVoice.
allow=ulaw
authuser=7327570239
callerid=7327570239
disallow=all
dtmfmode=inband
fromdomain=sip.broadvoice.com
fromuser=7327570239
host=sip.broadvoice.com
insecure=very
qualify=yes
secret=*******
type=peer
username=7327570239
9|1NXXNXXXXXX
9|732NXXXXXX
By default, when you set up an extension, and add an email address in the “email
address” field, then when the system records a message, it sends email containing a link
that will let the recipient listen to the voice message on their computer (through the
browser). For this to work, you must open up your Asterisk machine to browser traffic
from outside the router’s firewall. I leave it to the reader to figure out this one.
Once you do, you still need to change the email, which contains a link to the mail
reading web page.
You may notice a few things wrong with the voice mail reader application. I guess this
means that it is not really finished, although it appears to basically work. I noted that
the initial login does not fill in your extension, as it should. Also the image links are
broken. Maybe the next version will clean up these details.
You first need to sign up for a FWD “phone number,” which you can do at the web site
listed above. Be sure to enable IAX service while you are there. My number is
679263. I will use this in the examples below, but you should replace it with your own
number and password, as appropriate.
1. Open the Trunks page, select “Add Trunk” and select “Add IAX2 Trunk”. Enter
the following information. I have chosen to use a prefix of “393” (FWD) to
select the FWD trunk. You can pick a different trunk prefix if you want.
allow=ulaw
auth=md5
disallow=all
host=iax2.fwdnet.net
qualify=yes
type=peer
username=679263
USER Details:
allow=ulaw
auth=rsa
context=from-pstn
disallow=all
inkeys=freeworlddialup
type=user
Register String:
Ring Group: #1
3. Open the “Outbound Routing” page and select “Add Route”. Enter the
following information:
ArtDio
There are many choices for phones that you can use with the Asterisk system. Among
the possibilities are IAX phones, SIP phones, SIP softphones, and analog phones with a
SIP/analog converter. Such a converter should provide a FXO interface. Sources of
phones and converters are listed below.
1. Plug the phone in, log on to it, and set its IP address, net mask, and default
gateway parameters.
2. Browse to the phone and set up its SIP gateway, its name and password, and
other SIP parameters. You will know these are right when the phone can
register. In the case of the ArtDio phone the critical step was knowing that there
were two passwords, and that only the “super user” password (“12345678
begin_of_the_skype_highlighting 12345678 end_of_the_skype_highl
ighting”) would allow access to the key SIP configuration parameters.
3. The fields that I had to change on the ArtDio are as follows (assuming the
extension is 201 and the IP address of the phone is 192.168.0.60):
If you do not see the screen below when you browse to the phone’s IP address, but
instead see a simpler screen, then it means that you have logged in with the phones user
password, not its superuser password.
Sipura
Once I had a few phones set up, I realized that there are
places in my home where I wanted a phone, but where I did
not have Ethernet wiring. There are several ways to address
this:
The simplest, least expensive, and least disruptive choice was to use an analog phone
adapter with a cordless hone. The Sipura adapter is widely available on eBay. It was
distributed by various IP telephony service providers. I guess people who tried it and
did not like it are selling their used adapters. Just make sure you get one that is
“unlocked”. Apparently Vonage adapters are set up so that you cannot modify the
critical SIP parameters, and are not usable with Asterisk. Other service providers such
as BroadVoice, do not lock their devices.
I bought a used Sipura SPA-2002. I have also tried this with a Sipura 1000 and it works
about the same. Setting it up was pretty easy.
1. Set up an extension, as before, in the AMP Setup/Extensions screen.
2. Plug it into Ethernet and connect a phone. When you apply power, it gets an
IP address from DHCP.
3. You need to get the IP address. Pick up the phone, dial “****” and then dial
“110#”. It will speak the IP address.
5. If you have purchased a used unit, it would be a good idea to clear out any old
settings first. On Sipura devices, you can do a factory reset by:
a. Dial “****” and verify that you hear a voice prompt.
6. On the “System” tab, enter the fixed IP address you want to assign the device.
7. Using the new IP address, browse to the advanced admin screen again. This
time, select the “Line1” tab. Enter the proxy information (the IP address of the
Asterisk system) and the subscriber information (the extension number and
password you set up in step 1).
You should be able to use the phone at this point. Go to AMP’s
Maintenance/Asterisk Info screen to check that the new extension is registered.
Router
Once you have your system set up and are using it for
phone service, you may notice that the sound quality is
terrible when you are doing other things on your broadband
connection, such as large FTP transfers. This depends a lot
on your connection speed. In my case, which I imagine is
pretty common these days, I have only 128K bits per
second uplink speed. For comparison, with the standard
G711 coder, one phone call takes 64K bits, half the
bandwidth. Unless you do something, FTP will take
enough bandwidth to make telephone calls impossible.
What can you do about this ? Your router may be able to
help, by giving traffic coming to and from the Asterisk box priority. I have a Linksys
WRT54G, a widely available combo router, 4 port switch, and wireless access point. It
has a way to assign priority to different traffic in various ways. I set it up to give
priority to a given switch port, where I have the Asterisk system plugged in.
To set this up, browse to your router, log in, and go to “Applications and Gaming” and
then to “QoS”. I plugged my Asterisk system into port two, so I set up:
QoS: Enable
Port 2: Priority High
Next
The AAH people have provided you with a ton of pre-configured features. You can start
reading through the main configuration files to see some of the cool things you can do
with AAH and your BroadVoice and VoipJet accounts. You might want to set up the
BroadVoice trunk to do outgoing calls, using a prefix. It would be nice if it could use
BroadVoice for outgoing calls until the 100 minutes are used up, then switch to
VoipJet. If you figure out how to do this, let me know.
You can make a backup of your configuration files by backing up the files in the
/etc/asterisk directory of your AAH server. The AMP “Backup” command on
the left can be used to set up periodic backups.
If you are interested in making international calls, add some more patterns in
“Outbound Routing”. Commonly used dial patterns are preconfigured, so you
only have to select them.
Read through the extensions.conf and see what all is already configured for you
to test and work with.
Further Reference
Here are some places to go to find out more about AAH, Asterisk, and the components
that make it up.
Service Providers
BroadVoice http://broadvoice.com
VoipJet http://voipjet.com
VoicePulse http://connect.voicepulse.com
TelaSip http://www.telasip.com/index.html?PARTNER=coupon4voip
Free World Dialup http://www.freeworlddialup.com
LibreTel http://www.libretel.com
Software
Asterisk@Home http://asteriskathome.sourceforge.net/
Asterisk http://www.asterisk.org/
Asterisk@Home Handbook http://asteriskathome.sourceforge.net/handbook
Asterisk@Home support http://www.voip-info.org/tiki-index.php?
page=Asterisk+at++Home
Asterisk Support http://www.voip-info.org/tiki-index.php?page=Asterisk
Asterisk@Home info http://geekgazette.com/index.php?
option=com_frontpage&Itemid=1&limit=4&limitstart=8
Sugar CRM
CentOS
Phones
XLite http://xten.com/index.php?menu=products&smenu=xlite
SipXPhone http://www.sipfoundry.org/sipXphone/index.html
Tools
Phones
Acknowledgements
A preliminary version of this set of instructions was produced by Jacob Cazell
(http://www.cazz.org/). It helped immensely in getting my own system set up properly
the first time, and inspired this document. A few of the sections here incorporate
material that first appeared there.
I will be adding to these instructions from time to time as I experiment with additional
features, service providers, and subsequent releases. If you have suggestions,
corrections, or comments on these instructions, I welcome your feedback. Please send
commands to cchayden@gmail.com
asterisk –r
General commands
!<command>: Executes a given shell command
logger reload: Reopen log files. Use after rotating the log files.
AGI commands
show agi: Show AGI commands or specific help
sip show peers: Show defined SIP peers (clients that register to your Asterisk
server)
sip show registry: Show SIP registration status (when Asterisk registers as a client
to a SIP Proxy)