Reprint - Linux Advanced - Creating A PBX System From VOIP


Published on

Advanced Information on creating a PBX system using a Linux VOIP app.

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Reprint - Linux Advanced - Creating A PBX System From VOIP

  1. 1. MASTERCLASS ADVANCED LINUX This Series Part One Part Two Part Three IP Telephony Getting started Asterisk Asterisk essentials with Linux with Asterisk applications and Asterisk Planning a PBX system PROJECT TIME Last month we looked at Asterisk basics, this month David Coulson 2 00HRS MINS looks at how to make a PBX out of the popular VoIP application SKILL LEVEL e’ve looked at Asterisk as a simple call routing maxlogins=3 0 10 8 ADVANCED W system, where we can take calls in from a SIP phone and output them to a carrier using IAX2. [default] 100 => 1234,Example Mailbox,root@localhost We’re setting up a whole However, Asterisk has many capabilities beyond this telephone network functionality, making it a fully fledged PBX system. A single voicemail box, number 100, is defined here with a This month we’re going to use Asterisk for a Voicemail default password of ‘1234’. We also define the mailbox as YOU’LL NEED THIS and Queue management system. As much as we all hate ‘Example Mailbox’, which is used to indicate which mailbox A Linux system with an the ‘your call is important to us’ nonsense, it is a the message is left in, when sending an email to the user, in ! Asterisk install necessary evil for many businesses and Asterisk can deliver it at a much lower cost than many to other PBX this case root@localhost. environments available. 2 Wait for the beep The mailbox we deliver voicemail to does not have to be the same as the extension, although 1 Voicemail configuration The basics of any PBX when it comes to building a more complex PBX, having system involve the ability to route a call to the appropriate everything the same makes life much simpler. With individual, or give the option of going to voicemail or back to extensions matching voicemail boxes and other simple an operator to leave a message. Asterisk has a complete organizational techniques, major PBX functions can be voicemail system called ‘Comedian Mail’ built-in, but only scripted into macros which allows us to have a single once we have it up and running can we really appreciate the function run multiple commands. way it integrates with email and other systems. For extension 100 and mailbox 100, we can build our Voicemail in Asterisk is configured through the ‘/etc/ ‘extensions.conf’ with a section such as following: asterisk/voicemail.conf file’, which is organized in a similar way to the other configuration files. We start off with a exten => 100,1,Dial(SIP/100,20,Ttr) ‘general’ section, followed by contexts for handling exten => 100,2,VoiceMail(u100) mailboxes. For a PBX, shared between multiple corporations exten => 100,3,Hangup or departments, contexts allow you to create multiple exten => 100,102,VoiceMail(b100) mailboxes with the same name and have unique methods exten => 100,103,Hangup() for access to voicemail. A typical voicemail.conf would look some like the following: 3 Extension macros Next, we would have to repeat these five commands for each extension. For a couple, it’s [general] not a major ordeal, but for ten or more extensions, it’s very format=wav49|gsm|wav tiresome. Instead, you can build a far more flexible and easy serveremail=asterisk to replicate extension configuration using a macro: attach=yes skipms=3000 [macro-didexten]; maxsilence=10 ; Arg 1 is Voicemail Box, Arg 2 is Channel/Ext silencethreshold=128 exten => s,1,DBput(LastCIDNum/ ${DNID}=${CALLERIDNUM}) exten => s,2,Dial(${ARG2},20,r) exten => s,3,Voicemail(u${ARG1}) exten => s,4,Goto(default,s,5) exten => s,102,Voicemail(b${ARG1}) exten => s,103,Voicemail(u${ARG1}) exten => s,104,Goto(default,s,5) Now for extension 100 we can do: exten => 100,1,Macro(didexten,${EXTEN},SIP/ ${EXTEN}) Additional extensions can easily be added. We can also setup direct dial numbers and point them to extensions: Digium has lots of Asterisk hardware for connecting exten => 2169203100,1,Macro(didexten,100,SIP/ to the PSTN for single lines or ISDN circuits. ${EXTEN}) 152 PCPlus 231 | July 2005PCP231.lx2 152 13/5/05 11:21:50 am
  2. 2. ADVANCED LINUX MASTERCLASS PCPlus Back Issues David Coulson Missed an instalment? Phone 0870 837 4722 David is a Linux consultant who specialises to order your back issue in network architecture and system management PASSING SHOT While Asterisk is a popular system, there are times when a full-blown PBX application is simply overkill on a network. For SIP users, SIP Express Router or SER ( ser/) is a great alternative to Asterisk where a large number of users will be using the service to deliver their calls. While it lacks the functionality of Asterisk for inbound callers and business users, SER is a highly efficient SIP gateway package, which allows SIP calls to be routed and terminated on devices without SER ( is perfect for gateways, which are Call queues, or ACD, are a necessary evil on many phone having to have them outwardly only handling SIP without the overhead of Asterisk. systems to manage large numbers of inbound calls. accessible on the Internet. This is ideal for large scale SIP Again, if the DIDs are assigned in a sequential format and announce = queue-techsupport services, where the there’s a correlation between DID and the extension, it can all strategy = ringall authentication stage is off- be built using wildcards: context = default loaded onto SER and internal announce-frequency = 90 SIP devices and deliver the exten => 216920310_ announce-holdtime = yes calls onto the PSTN. ,1,Macro(didexten,${EXTEN:7},SIP/${EXTEN:7}) monitor-format = wav monitor-join = yes 4 Call queues After voicemail, the most common use of joinempty = yes a PBX is for call queues, otherwise known as Automated Call leavewhenempty = yes Distribution, or ACD. Asterisk allows for a very complex call eventwhencalled = yes queue configuration, where members can call into Asterisk member => SIP/100,1 remotely, obviously, this is very useful for home workers. member => SIP/101,1 Queues are configured in ‘/etc/asterisk/queues.conf’, with member => Agent/1001,2 each context being a separate queue. We can define specific member => Agent/1002,2 options for a queue, such as announcements to tell people how many are in the queue and estimated hold time: 5 Dynamic agents In this instance, we’ve given priorities to our members, so the two SIP users will be called first and [tech-support] if neither of them answer or they are busy, then it will try the musiconhold = default two dynamic agents. These agents are users who have to MeetMe Conference calling services can prove expensive, but Asterisk can do it Being able to create virtual conference confno[,pin] the group. We can also define an conf => 1234 rooms where people can call in and talk extension, where users can enter can be a great benefit to any business. To connect to MeetMe, we define an the group in a muted state. Indeed, many corporations exist purely extension within ‘/etc/asterisk/ MeetMe requires a timer to to deliver this service, which can really extensions.conf’: function, so either Zaptel prove expensive if you many users. hardware is necessary, or the Asterisk includes an application exten => ‘ztdummy’ module needs to be called MeetMe, which creates a 8600,1,Meetme(1234|Mp) loaded. For 2.4 users, you can conference bridge. MeetMe rooms are use zaprtc to access the real-time Conference bridges are a must configured in ‘/etc/asterisk/meetme. When a single user is in the conference, clock on the system, as ztdummy in 2.4 for a smooth running business conf’, with a specific conference number, they will hear a recording that they are requires USB hardware using UHCI to and Asterisk cuts the costs. as well as an optional PIN. alone and then hear the hold music. A function. Lots of documentation on beep will sound when users join the Meetme can be found at www.voip- [rooms] conference group, and the hold music ; Usage is conf => will cease once there are two people in cmd+MeetMe. ■ PCPlus 231 | July 2005 153PCP231.lx2 153 13/5/05 11:21:52 am
  3. 3. MASTERCLASS ADVANCED LINUX Music on Hold When silence is not golden, music can soothe the wounded customer No one loves the sound of silence when ‘Music on Hold’ contexts for different command, before being placed on hold or sitting in a queue. users. When configuring Music on Hold, we send users Playing music is a much more pleasant it’s necessary to remember that the music into conference bridges or queues and has a idea, giving the indication that the call is selected is that of the channel the held make sure the music is appropriate. wide selection of music still in progress and potentially can be user is on, not the channel type of the Hold music is configured within ‘/etc/ which can be used by PBX systems. used to take the edge of people who call person who put them on hold. asterisk/moh.conf’, and Asterisk comes in a less than ideal state. We need to use the SetMusicOnHold complete with a selection of royalty free Asterisk uses a directory of MP3s for its application to set the hold music context music which can be used without cost on hold music, and we can create multiple for a specific call, so we can place this your system. ■ GOING FURTHER call into our system, authenticate, then become participants The Asterisk development within the queue. Using the AgentCallbackLogin application community has come up with and ‘agents.conf’, we can have people call an extension to a clever little system to handle manage their activity. The .CONF file looks very similar to automated routing of calls, ‘voicemail.conf’, with an agent ID, password and name: allowing anyone with an Asterisk system to make free agent => 100,1234,David calls out to anyone who will terminate their call. DUNDi is We can now set up ‘extensions.conf’ with extension 700 currently an add-on patch for where people can login and out of the queue: Asterisk, although it will likely make its way into the release cycle at some point in the exten => 700,1,AgentCallbackLogin(|${CALLERIDNU future. Those who wish to M}@local) terminate calls on their own local equipment can advertise Callback numbers are collected from the caller ID, which permitted number blocks onto vmail ( is a great front-end to makes life much simpler for everyone. Once the agent has Asterisk’s voicemail system for easy access from a workstation. the DUNDi network, which logged in, it will receive a call as if it were a static member of other Asterisk users can look the queue. If we define an ‘announce’ entry in our queue. up against. Should the lookup conf file, then the agent will hear a message indicating ${TIMESTAMP}) be successful, IAX2 is used to deliver the call over the which queue the call is from, so it knows that the call is exten => _8.,2,Monitor(wav,${CALLFILENAME},m) Internet. Your mileage will vary being routed via ACD, rather than a call for its extension. exten => _8.,3,Dial(LOCAL/${EXTEN:1}@outbound) with DUNDi, as it is dependent exten => _8.,4,Congestion upon the public Internet to 6 Call monitoring For business users, having the ability exten => _8.,104,Congestion deliver the call, but it is to record calls either made by employees to clients, or ///CODE/// certainly a promising platform inbound support calls, is very beneficial for training. It’s worth for a ‘free for use’ VoIP remembering that different countries have their own laws For calls within queues, we can set the ‘monitor-format’ interconnect environment. regarding recording of conversations, and in certain places and ‘monitor-join’ options, which will do the exact same you are required to indicate that the call may be recorded. thing to calls being handled by the ACD system. It’s important The ‘Monitor’ application monitors a specific channel, and to note that it can take some CPU power to convert ULAW will generate two WAV or GSM files, one for each side of the call formats into GSM, particularly if it’s a long call. Simply conversation. More recent versions of Asterisk will use ‘sox’ to dumping everything to disk in WAV format is often a good merge the two files together, so we end up with a single file option, as they can be migrated off the Asterisk server and containing everything within the channel. archived. For inbound calls it’s not a good idea to simply The most basic configuration is to create an extension monitor them all, otherwise it creates a nice little DoS attack wildcard, so that any call prefixed with an ‘8’ will against your system if someone calls in a dozen times, then NEXT MONTH automatically be recorded: waits an hour and hangs up. Asterisk will kick off twelve Next month we conclude our instances of ‘sox’, each of which are CPU hungry by series on Asterisk with a look [record-out] themselves, disrupting calls and potentially killing the system at some advanced call routing. exten => _8.,1,SetVar(CALLFILENAME=${EXTEN:1}- if the memory available is too short. PCP Asterisk Security Maintaining a VoIP gateway requires some security considerations Asterisk and other VoIP of IAX2 providers, or internal although we can safely block systems use IP to communicate systems talking IAX2. The IAX2 TCP and low UDP ports. and are, therefore, open to format is easy to filter as it lives Inbound SIP connections will attack and exploit. While we on a single UDP port, 4569, so be on port 5060, so it would be can’t completely cut the system we can permit access to that better if a IPTables connection off from the world, we can port to and from hosts that we tracking module existed, which restrict access to services. peer with. permitted RTP traffic when a For the most part, SIP will be RTP is a little more corresponding SIP connection the only protocol where the complicated to filter, as existed, but at this point one users may be connecting from potentially it can use a large doesn’t exist. Of course, You can set up ‘Music on Hold’ anywhere. For IAX2 number of UDP ports across a someone is sure to write one and keep people calm when on hold, and reassured that connections, we’ll know where range. Often there’s little option, before too long, as it has some someone will answer their call. connections will be coming but to open them up to important functionality to from, as we’ll have a select list everyone for RTP to even work, secure VoIP environments. ■ 154 PCPlus 231 | July 2005PCP231.lx2 154 13/5/05 11:21:53 am