Asterisk PBX Installation
Adam Vartanian, Hassan Ajmal October 10, 2006
In this lab, we installed and conﬁgured Asterisk, an open source software PBX system. Asterisk is dual-licensed under both the GPL and a proprietary license under which GPL-incompatible code may be combined. Though we will not use them in this lab, Asterisk provides many advanced features, such as voicemail, interactive menus, and interserver communication. In this lab, we installed Asterisk, conﬁgured it, and used it to route calls between soft and hard phones.
• Download source archive at http://ftp.digium.com/pub/asterisk/asterisk1.2-current.tar.gz • Unpack archive • make • make install • make samples
Installing Asterisk is straightforward.
Asterisk is conﬁgured through the use of conﬁguration ﬁles stored in the /etc/asterisk directory. Conﬁguration ﬁles are organized into sections, which are delimited by brackets, and then a set of instructions of the type either marker => instruction or name=value There are two steps to conﬁguring Asterisk for our environment: conﬁguring the SIP accounts, and conﬁguring the extensions. To conﬁgure the accounts, one must edit the sip.conf ﬁle. There is a section called general, which deﬁnes how the SIP server should act, and then a set of sections whose names are the accounts and whose values are speciﬁc to those accounts. The ﬁle we used is shown below 1
Next. To perform serial forking. such as transferring to other systems. which will occur when the ﬁrst action times out. though many other actions are implemented.Dial(SIP/JOE) exten => 5567.168.1. then provide a second action with another priority which rings the second phone.4745 [FRED] type=friend secret=12345 host=dynamic mailbox=1764.1.1 context=default [BOB] type=friend secret=12345 host=dynamic mailbox=2345.1.Dial(SIP/JOE&SIP/FRED) 2
. we provide a timeout to the ﬁrst action. all we have is extensions which ring the speciﬁed phone. Actions for our purpose are in the form of Dial(information).(action).Dial(SIP/FRED) Here.(priority).1. which makes the phones associated with both JOE and FRED ring until one picks one up. exten => 5600. recording voicemail. We also added several rules of the form exten => (extension). the priority is the order in which rules should be executed.conf ﬁle.34745
Each account may also have a transport=tcp line added to force interaction to be performed over TCP instead of the default of UDP. we added rules to support forking.[general] port=5060 bindaddr=192. and the action is what action to take. which we left in place.0. the ﬁle contains a large number of sample rules. To perform parallel forking. or playing a message. we ﬁrst added rules for dialing each phone individually. By default.Dial(SIP/BOB) exten => 5568. To conﬁgure the extensions. we set the action to Dial(SIP/JOE&SIP/FRED). exten => 5566. where the extension is the extension to dial.1234 [JOE] type=friend secret=12345 host=dynamic mailbox=123345. The information about the deﬁned extensions is kept in the extensions.
Hard Phone Conﬁguration . we needed to provide the SIP proxy. It’s also important to note that no spaces are allowed in the action speciﬁcations. As a result of this. more advanced features are not covered well at all. and added a new proﬁle of the “Calls through SIP Proxy” type. you push the center button in the directional button area of the phone. For the SIP proxy and outbound proxy. display name. then repeated it for each letter. we added the proxy address and port to the SIP Proxy tab. We went into the preferences dialog. At that point. To conﬁgure it to use our Asterisk server was comparitively simple.
Soft Phone Conﬁguration . you scroll down to the Settings menu item and select it. and the phone connected after prompting us for our username and password. we ended up adding the names by entering a number and then using the directional keys to scroll through all the characters until the letters until we reached the given letter. several commands are useful. At the console.Dial(SIP/JOE. where the v options indicate that Asterisk should be especially verbose.10) exten => 5561. which is a very poor interface for setting complex conﬁguration parameters such as usernames and passwords.2. authentication name. it was fairly simple to add the addresses.Dial(SIP/FRED) While these features are fairly well documented in the Asterisk handbook. and the c option indicates that it should provide a console and not detach from the controlling terminal. and password. as they were numerical and the asterisk key can be used for periods. though. outbound proxy. After conﬁguration. we ﬁrst set up the Grandstream phone. which is very counterintuitive.exten => 5561. we could ﬁnd no convenient interface to enter letters. Thus. and are especially helpful in investigating conﬁguration problems. we changed all the account names to be in all caps (as the capital letters are before the lowercase letters in 3
We tested the SIP proxy using the SJPhone available from http://www. and Mac OS X. went to the Proﬁles tab. starting Asterisk is as simple as performing asterisk -vvvc.sjlabs. Linux. For the SIP settings. we needed to provide the IP address and netmask. and ﬁnding the handbook on Asterisk’s website can be diﬃcult. All of the phone’s conﬁguration is done through the phone itself. To access the settings. which works on Windows. which turns on or oﬀ SIP debugging messages.html. we simply switched to that proﬁle in the preferences dialog. For network settings. The particular settings needed to get the phone working were in the Network and SIP sections of the phone. Then. In the proﬁle setup.Grandstream
For hard phones.1. These messages include all incoming and outgoing SIP packets. most especially the sip [no] debug command. For the names and password.
ﬁrst we accessed the settings menu through the settings button. The phone also has a very strange eﬀect where after you save a name. To set up the web interface. In testing the protocol types. then followed the prompts to set the IP address and netmask of the phone.Snom
Finally. it worked as expected. which causes Asterisk to treat it as a diﬀerent name than what is in its conﬁguration ﬁles. After entering the necessary information into the form and submitting it. all three phones supported both UDP and TCP connections. Once that was established. we were able to establish calls between all endpoints and perform both serial and parallel routing. which are diﬀerent conﬁgurations of SIP proxies and related information. and thus reject the logon attempt. we conﬁgured a Snom hard phone. Thus. you need to enter the name and then go back into the settings and delete the extra space.
Once all the components were conﬁgured. This problem was not experienced for the password for some reason.
. The Snom hard phone provides a convenient web interface which makes conﬁguration much easier than for the Grandstream phone.
Hard Phone Conﬁguration . chose the DHCP entry (despite using a ﬁxed IP address). The web interface allows you to enter information for up to 15 “identities”. Once the phone was setup and rebooted. it puts a space after it. we could access the phone by pointing a web browser at its IP address. to properly conﬁgure the phone.the sequence) and the passwords to all be numerical. the phone connected to the proxy.