Software Based VoIP Lab A step by step guide to setting up and configuring an IP-PBX Donal O Connor DNET 4 donaloconnor@gmail.com
Introduction Traditionally, a company or individual would have to buy really expensive hardware in order to implement their own private branch exchange (PBX) that facilitated the use of multiple phones within the organization without the need for a dedicated line to serve each. Fortunately in more modern times there are more options available and some are not even hardware based *. One of the main stream VoIP solutions out there is Cisco s call manager (now called Cisco Unified Communications Manager). We will not discuss how Cisco s implementation works here but we will concentrate on alternative open source and free versions out there. One of the most common open source packages out there is Asterisk. Asterisk is a cross platform independent IP based PBX software that is released the GPL license for personal use. However, if an organization wishes to release a version of asterisk with their own proprietary (closed source) based components, they can do so under a proprietary software license. Since Asterisk is open source, this opens it up to the large community of programmers that offer their free time on projects. This means that significant work has being invested freely to establish Asterisk s great stability by submitting bugs and fixing them. Although Asterisk can run on a variety of systems, it is mainly intended to be run on Linux based systems. This is no doubt due to the fact that Linux itself is open source and freely available. Further more Linux has a great track record of being a reliable OS. Asterisk provides a wide variety of features that proprietary PBX solutions offer. These include: Voice mail Conference calling Interactive voice response Automatic call distribution In addition to setting up simple extension numbers to allow connection of one to one calls, we will look at some of the IP-PBX features above, specifically voice mail and conference calling. Although it is possible to connect traditional analogue phones and proprietary system to the Asterisk system, we will not cover this as special hardware is required. Further more, most phones today will be VoIP based phones that connect directly into the network. * When we say not hardware based, we mean dedicated phone switching hardware and not the actual computers that run the voice software runs on. Note however, that cards still exist to connect physical phones.
Getting Started Before you get started at all you will need a working Linux installation. Since most people won t have Linux installed on their PCs by default, follow the steps in the following section in order to get Linux up and running in a virtual machine. This lab has been done on both VMWare and VirtualBox. VirtualBox was a little bit more troublesome that VMWare with networking issues. It seemed to require NAT, its bridge host mode was difficult. For this to work, ports had to be opened using the VboxManage utility (In appendix below). The help of VirtualBox has information on this or else you will can search Google for support on this. UDP ports 5060 have to be open for SIP. Note, if you are within college and have access to VMware, you might as well use that. Both provide the same functionality. Presently in XXX, VMware is configured with SuSE version 9.3. If you are setting up your own virtual machine you must obtain a copy of this or use the free OpenSUSE version. Note however, some commands may not be necessary on the newer versions. Version 10.1 is a bit out dated and some dependencies must be installed that may not be required on newer versions. In this lab, we will use SuSE version 10.1. This will be a bit newer than XXX s version installed but we will point out the extra things required to do Setting up VirtualBox Sun have pre compiled binaries of virtual box on their site that comes with an automated installer that will make life easy. Go to: http://www.virtualbox.org/wiki/downloads and downloaded the x86 version. Note however, if you are running a Windows 64bit OS you may choose to download that version. Run the msi installer and choose the default options along the way. Now that you have it installed, you must create a virtual hard drive. To do this, open VirtualBox and click File Virtual Disk Manager. Since we ve only installed this we will not see any existing hard drives. We must click New to do so. Create a hard disk that is 8GB of size, and use Dynamic Sizing as this will save space you your local hard disk. Once all that is done, accept changes until you reach the main window of VirtualBox again. To create a virtual machine, click on the New icon. Follow the instructions there selecting the OS as SuSE and the existing hard drive we created as the primary hard drive. Also if you have plenty of memory on your PC, you may want to increase the amount of memory allocated to the virtual machine. To install SuSE onto the virtual machine we either have to link [mount] the DVD-ROM drive to the machine or mount an ISO image. This can be done by right clicking on the newly created machine and selecting settings. Select the CD-ROM configuration tab and do the necessary changes in there. Now when the machine starts, it will attempt to boot from this CD. Install SuSE as you would normally on a regular machine. During the installation, choose to install GNOME instead of KDE. Notes on Networking VMWare Set networking to bridging mode and enable IP forwarding (Yast2->Network->Routing) VirtualBox Set networking to NAT. Not as reliable as VMWare. There is an issue with VirtualBox on some machines. It doesn t allow DNS to be configured automatically via VirtualBox s DHCP server. To do this edit /etc/resolv.conf and place the addresses of your name servers in there. [nameserver xxx.xxx.xxx.xxx]
Setting up our Terminal Session For the remainder of this, you will be using the console to download and install asterisk and its required modules. You will be working with run level 3, which means you will have to work via the command line. This will prevent ambiguity in areas such as downloading files. If you used the GUI, Firefox may download them to default locations and this can get confusing. To begin, right click on the desktop and select Terminal or use the start menu to locate one. Enter the following commands to launch run level 3. user@linux:~> su ; Enters root mode Enter password: xxxxx [Press Enter] linux:/home/user # init 3 ; Launch runlevel 3 When, the terminal loads, you must log in again. You must enter root mode so you have the necessary rights to run all the commands below. To do this, enter the following commands: user@linux:~> su Enter password: xxxxx [Press Enter] Creating your working directory You will have to create a location for the downloads. To do this type the following command. The purpose of the DAHDI directory will be explained later on. linux:/home/user # mkdir p asterisklab linux:/home/user # cd asterisklab linux:/home/user/asterisklab # mkdir dahdi Setting up the GCC compiler Like most open source software out there, you ll end up having to download a tarball source of the software. This is for reasons that allow it to be released independent of the Operating System or Architecture used. For this reason we will have to have a working GCC compiler installed on our system. To test to see if you ve GCC installed, type the gcc command in a bash shell. If you get something like no input files suggested then you ve working version. Otherwise if it says command not found you will have to complete this section. Important This will also install the kernel sources that are required for DAHDI later if not already installed. It might be advisable to run the command below even if you have GCC installed already. Since you may not have a C compiler on the computer, you must download a binary version as sources will be useless to us. To download this, simply type the following command on SuSE: linux:/home/user # yast2 -install gcc gcc-c++ make kernel-source Type gcc and hit enter. What do you see? Note You will require the SuSE DVD mounted and in your drive for this. There are other ways using RPM s but they require a great deal more work on your behalf that is out of scope of this.
Setting up Asterisk In this section you will install Asterisk on the host machine by downloading its source code and compiling it with the GCC. The steps below should be fairly straight forward. Download Asterisk You will need to download the latest version [1.6] of Asterisk from the official website. Currently, the newest version is 1.6. To download this quickly, open terminal session and type following: linux:/home/user # cd /home/user/asterisklab linux:/home/user/asterisklab # wget http://downloads.digium.com/pub/asterisk/releases/asterisk- 1.6.0.1.tar.gz Note: If using root account instead of user, replace /home/user/ with /root/ Extract Contents from Tar ball To untar the download enter the following commands: linux:/home/user/asterisklab # tar xzvf asterisk-1.6.0.1.tar.gz Installing Necessary Dependencies As with everything in the Linux world, dependencies will always exist. This means we must have certain modules installed before hand before attempting to install Asterisk. These are as follows: Bison Libterm && libterm-devel Termcap Ncurses && ncurse-devel Gmime && gmime-devel OpenSSL && openssl-devel DAHDI && DAHDI-Tools DAHDI : Digium Asterisk Hardware Device Interface The DHADI components are actually optional but for conferencing later, they will be needed. The MeetMe application is dependent on DAHDI. You can t add them in later either without recompiling Asterisk again. To install each, we must download the tar ball source from GNU s public ftp site. The fastest way to get these is to download them straight using wget. Type the following commands to download and install termcap, ncurses, DAHDI, DAHDI-tools. linux: # cd /home/user/asterisklab linux: # wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz linux: # wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.7.tar.gz linux: # cd /home/user/asterisklab/dahdi linux: # wget http://downloads.digium.com/pub/telephony/dahdi-linux/dahdilinux-2.0.0.tar.gz linux: # wget http://downloads.digium.com/pub/telephony/dahdi-tools/dahditools-2.0.0.tar.gz
To install these type following commands. These may take time to build. linux:/home/user/asterisklab/dahdi # cd /home/user/asterisklab linux:/home/user/asterisklab # tar xzvf asterisk-1.6.0.1.tar.gz linux:/home/user/asterisklab # tar xzvf termcap-1.3.1.tar.gz linux:/home/user/asterisklab # tar xzvf ncurses-5.7.tar.gz linux:/home/user/asterisklab # cd ncurses-5.7 linux:/home/user/asterisklab/ncurses-5.7 #./configure linux:/home/user/asterisklab/ncurses-5.7 # make linux:/home/user/asterisklab/ncurses-5.7 # make install linux:/home/user/asterisklab/ncurses-5.7 # cd../termcap-1.3.1 linux:/home/user/asterisklab/termcap-1.3.1 #./configure linux:/home/user/asterisklab/termcap-1.3.1 # make && make install linux:/home/user/asterisklab/termcap-1.3.1 # cd../dahdi linux:/home/user/asterisklab/dahdi # tar xzfv dahdi-linux-2.0.0.tar.gz linux:/home/user/asterisklab/dahdi # tar xzfv dahdi-tools-2.0.0.tar.gz linux:/home/user/asterisklab/dahdi # cd dahdi-linux-2.0.0 linux:/home/user/asterisklab/dahdi/dahdi-linux-2.0.0 # make linux:/home/user/asterisklab/dahdi/dahdi-linux-2.0.0 # make install linux:/home/user/asterisklab/dahdi/dahdi-linux-2.0.0 # cd.. linux:/home/user/asterisklab/dahdi/ # cd dahdi-tools-2.0.0 linux:/home/user/asterisklab/dahdi/dahdi-tools-2.0.0 #./configure linux:/home/user/asterisklab/dahdi/dahdi-tools-2.0.0 # make linux:/home/user/asterisklab/dahdi/dahdi-tools-2.0.0 # make install linux:/home/user/asterisklab # yast2 -install gmime linux:/home/user/asterisklab # yast2 -install gmime-devel Note [Last 2 Lines] There is a bug in version 1.6 of asterisk to do with SuSE Linux: http://bugs.digium.com/view.php?id=13583. The bug means Gmime is needed during build stages but the configure script fails to verify this. We must use Yast2 to install this as it has quite a few dependencies like Glib, Pkg-config, GTK# etc. You can try and skip installing Gmime and the headers but this may result in an error when building asterisk below. You will have to repeat similar steps if you have more modules to install but on SuSE, this was all that was required in order to get asterisk installed. The make part will also take quit some time, GCC compiles the binary files at this stage so depending on speed of computer, this will vary. Configuring and Building Asterisk Now that we should have the necessary modules installed, we can build asterisk. Navigate to the asterisk directory: linux:/home/user/ # cd /home/user/asterisklab/asterisk-1.6.0.1 linux:/home/user/asterisklab/asterisk-1.6.0.1 # make clean linux:/home/user/asterisklab/asterisk-1.6.0.1 #./configure linux:/home/user/asterisklabasterisk-1.6.0.1 # make menuselect A menu should appear. Press F8. Now press enter to go into the Applications sub menu. In here you will have to scroll down to app_meetme.so. Ensure that this is ticked. If not press space bar so that you get a * before it. After ensuring it ticked, press ESC to go back and press X to save the config file and quit. Now we are ready to build asterisk and install it. Type the following command. linux:/home/user/asterisklabasterisk-1.6.0.1 # make && make install Note If Asterisk fails to build Make[2] Error, then more than likely a dependency is required. You will have to work out yourself what is required and download. Issue a make clean before attempting to rebuild. Now that we have asterisk installed on our machine, we will configure it.
Configuring Asterisk for Basic Calling Before you start Asterisk, you must set up extension numbers. Asterisk keeps all its configuration files in /etc/asterisk/. By default, this directory will be empty so you will have to create some files. The files you will create for now are modules.conf, sip.conf and extensions.conf. Type the following commands to create the 3 files: linux:/home/user/asterisklabasterisk-1.6.0.1 # cd /etc/asterisk linux:/etc/asterisk # touch modules.conf linux:/etc/asterisk # touch extensions.conf linux:/etc/asterisk # touch sip.conf Modules Configuration File (/etc/asterisk/modules.conf) This file specifies what modules should be loaded by Asterisk. If this file doesn t exist, you won t be able to access the SIP commands or use SIP for calls. The SIP module is chan_sip.so. Instead of listing the modules to load one by one you can simply use an autoload feature to load all modules automatically for you. Use an editor, nano for example (or VI/GEdit) to edit the modules file: linux:/etc/asterisk # nano modules.conf Enter the following: [modules] autoload=yes When finished entering these press CTRL+X followed by enter to save changes. Note If Asterisk fails to load when trying below, you may want to only load the necessary modules by typing in the following lines below the [modules] heading. autoload=no load=>chan_sip.so load=>pbx_config.so load=>app_meetme.so ; Allow Conference Calling SIP Configuration File (/etc/asterisk/sip.conf) This file contains parameters that relate to the configuration of SIP client access to the Asterisk server. Clients have to be configured in this file or they will be unable to participate in the placing and receiving of calls. You will set up 3 user clients for our server. Similar to how you edited modules.conf, edit the sip.conf file and enter the following information. Comments can be left out. Press CTRL+C to save changes once entered. [general] port = 5060 ; Port to bind to (SIP is 5060). bindaddr = 0.0.0.0 ; Adddress to bind to (all addresses) allow = all ; Allow all codecs for voice compression context=inbound-calls ; Inbound calls from this host go here
[2000] type=friend username=2000 secret=password2000 host=dynamic mailbox=2000@default ; This device makes and takes calls ; Username on device ; Password for device ; Host may use DHCP so address might change [2001] type=friend username=2001 secret=password2001 host=dynamic mailbox=2001@default [2002] type=friend username=2002 secret=password2002 host=dynamic mailbox=2002@default First of all we have the general section of the file with the following parameters. Port This is the port that Asterisk will listen on. This should be 5060 as this is the standard SIP port Bindaddr This is used if the host machine that runs Asterisk has more than one port. It specifies which interfaces Asterisk will listen on. It is set to the wildcard address which enables asterisk to read all interfaces. Context This sets the default context all further clients are placed in. This can be overridden by placing a context parameter within the client configuration. (i.e. Below [2000]) Next we have the actual client configurations. You have 3 here since we will have 3 clients. The parameters in these are: Type This sets the connection class for the client. A friend is a device that makes and receives calls. Other options here are peer (receives calls) or user (makes calls) Username This is the username that the client logs in with. Secret This is the password that the client logs in with. Host This is the IP address of the client, we set it to dynamic in this case as the IP may not always be the same (DHCP).
Mailbox One or more mailboxes may be listed (separated by commas) for sending Message Waiting Indicator (MWI) messages to a given SIP peer. (We should see an envelope sign on X-Lite if waiting voicemail). Extensions Configuration (/etc/asterisk/extensions.conf) This is the most important configuration file of Asterisk. It defines the dialplans that are used. The dialplans are the heart of Asterisk. They define the rules in how Asterisk handles inbound and outbound calls. Dialplans are fully customizable and this is one of the attractive features of Asterisk over other proprietary systems. A dialplan is made up of four main concepts: contexts, extensions, priorities, and applications. Contexts Dialplans are broken into contexts. These are groups of extensions that are isolated from each other. In other words, contexts keep different parts of the dialplan from interacting with each other. Contexts are done by placing the name inside square brackets. E.g. [incoming]. Above in the sip.conf file, you have specified the context: inbound-calls. This means all clients will use the context [incoming-calls] in our extensions.conf file. The [general] and [globals] context are special contexts belong to Asterisk. They define global behavior. Contexts can give callers special permissions (e.g. Allow long-distance calling). This is what makes Asterisk so flexible. Below is the extensions.conf file we will be using. [general] ; Following two lines prevent commandline interface from overwriting the config file. static=yes writeprotect=yes [inbound-calls] exten=>2000,1,dial(sip/2000,20) exten=>2000,2,voicemail(2000@default,u) exten=>2000,102,voicemail(20002@default,b) exten=>2000,103,hangup exten=>2001,1,dial(sip/2001,20) exten=>2001,2,voicemail(2001@default,u) exten=>2001,102,voicemail(2001@default,b) exten=>2001,103,hangup exten=>2002,1,dial(sip/2002,20) exten=>2002,2,voicemail(2002@default,u) exten=>2002,102,voicemail(2002@default,b) exten=>2002,103,hangup You can see above, you have two contexts. [general] which is an Asterisk specific one, and your custom one, [inbound-calls]. The static=yes and writeprotect=yes ensures that you do not overwrite this file from the CLI console interface. Extension Syntax exten=>name,priority,application() Our first line, we have the extension 2000 with a priority of 1 and the application is Dial().
Priorities and Applications These define the steps in which the channel takes when initiated. As you can see, it starts by a dial. Each application performs a specific action on the current channel, such as playing a sound, accepting touch-tone input, dialing a channel etc. The next step after a Dial is a Hang up here. A hang-up occurs after the channel is dialed since the priority is higher. Take the 2000 client. If one was to phone this client they would hit priority 1. This means once a SIP channel is opened for 2000, it will first attempt to dial the SIP client using the Dial() application. The Dial() and Voicemail() applications In the example above, we have included Dial(SIP/2000,20) for our first client. This means that we attempt to dial the client 2000 using the SIP channel driver. The 20 means, let the number ring for 20 seconds, and then if no answer proceed to priority 2. The jump to priority 2 is the sum of the specified priority 1, plus the current priority of this. So 1+1 = 2. In the priority 2, we send the caller to Voicemail. The u in the u2000 stands for unanswered, meaning we rang 20 seconds and arrived here so it has to be unanswered and this is the end of the chain. However if the dialed number in priority 1 above results in a busy code, then Dial will jump to 101 + Current priority which is 101+1 = 102 in this case. The 101 is built into Asterisk and does not need to be defined. So if the Dial() responds with busy, then we will jump to 102. This directs to Voicemail with the b meaning busy. Finally the last in the chain is hang up. Launching Asterisk This should be all that is required for configuring asterisk for now. To launch asterisk enter the following command: linux:/etc/asterisk # asterisk -vvvc You will see a series of messages when starting up. Hopefully you get to the end successfully with an Asterisk Ready message. Press enter to enter the command line interface (CLI>). The v s in the command are the Verbosity. The more v s the more detail you get such as debug details. The c means launch the CLI console. When the CLI console loads (Press Enter if not), type in sip show peers. What do you see? At the CLI type in dialplan show. What do you see? Type core show codecs. What do you see? What are these?
Setting up Softphones on 3 hosts Softphones run on a computer. In this lab, we will use X-Lite. The 3 host machines will all connect to the asterisk machine. For this, all machines will have to be contactable form the asterisk server. Presuming your PC s are windows, download the X-Lite software from http://www.download.com/x-lite/3000-2349_4-10547103.html. Once that is installed, you must configure a SIP account. For the first computer, follow the following steps: Once you click Add, a dialog will appear. Enter the following information: Obviously, replace the IP address in both cases for the one that Asterisk lies on. Repeat this step for the remaining 2 computers, entering 2001 and 2002 as the account names for both along with their respected passwords. To make a call, simply enter 2001 in the 2000 computer s X-Lite to ring 2001 or vice versa. This setup only allows 1:1 calling, but further along we will set up conference functionality.
Setting up Voicemail Asterisk provides a broad array of voice mail features including unlimited password-protected mailboxes, custom or default greetings. You will set up a very basic voice mail box for each of our 3 clients. Asterisk use s the voicemail.conf configuration file for its settings. Just like our extensions configuration file, our voicemail configuration file contains contexts that define different sets of mailboxes. If Asterisk is running, you may want to stop asterisk by typing the command: CLI> stop gracefully Creating Mailboxes Asterisk defines a syntax for specifying mailboxes: mailbox => password,name[,email[,pager_email[,options]]] First of all, create a blank file in our asterisk configuration directory like we done above called voicemail.conf. Enter the following information: [general] format=wav ; MP3 would require mp3 modules to be installed fromstring=xxxasterisk emailsubject=new Voicemail (${VM_MGSNUM}) in mailbox ${VM_MAILBOX} emailbody=dear ${VM_NAME}:\n\n\tYou have a ${VM_DUR} long message (number ${VM_MSGNUM}) in mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}.\n\nThanks!\n\n\t\tXXXXs Asterisk System [default] 2000=>3000,John Doe,jdoe@xxx.ie,attach=yes 2001=>3001,John Smith,jsmith@xxx.ie,attach=yes 2002=>3002,Mary Sullivan,msullivan@xxx.ie,attach=yes Save this file. You should now have have /etc/asterisk/voicemail.conf with the contents above in it. Note You may want to enter actual proper email addresses in here as an email is sent by Asterisk. The last 3 lines specify 3 mailboxes, one for each of our clients. The password for our 2000 client in this example would be 3000. We have also specified one of the options available, the attach one to allow emails to be sent with the attached voice message left. Now that you have your voicemail set up, let s test it. Start up Asterisk again. At the CLI type in voicemail show users. What do you see? Now dial the 2000 client from the 2001 client. Leave it phone for a while until you reach voicemail. Leave a message after the tone and hang up. This message will now go into 2000 s mailbox.
If you have SUSE set up correctly so send outgoing email, then 2000 should receive an email with the wav file attached. As well as that, you should now see an envelope sign appear on 2000 s X-Lite indicating voicemail unread. At the CLI type in voicemail show users. What is different this time? You will get an email message like this if email is set up correctly. You can now set up a 171 extension that allows users to access their Voicemail from their phone. This information is stored in the extensions.conf file. If you have no shut down Asterisk already, enter the stop gracefully command in its CLI. Re-open the extensions.conf file and at the end add this line at the end. ; After stuff above. exten=>171,1,voicemailmain() Save this configuration and reload Asterisk. Now from 2000 s X-Lite client, dial 171. You will be greeted by the Voicemail application. It will ask you to enter your mailbox number (Your extension number in this case). After you enter press the # key. Next you will be asked to enter your password. The password we chose for 2000 is listed in the voicemail.conf file above. It is 3000 in this case. After you enter this, press the # key. You should here the message that was recorded by 2001. Note Using Asterisk behind NAT is a problem. The ACK that Asterisk sends out as a keepalive fails to get back so Asterisk drops to call. This was the case for VirtualBox in NAT mode. In VMWare you may want to use Bridged mode instead.
Conference Calls with Asterisk Now since you have a working VoIP server enabling you to phone different clients within an organization. At times, multiple clients will all want to participate in a single call. For this you can enable Asterisk to deal with conferences. The MeetMe()application is used to set up conference calls. Users basically decide on a time to meet Asterisk sets up a conference room to allow all to join. You can create a dedicated extension number for the conference rooms. Asterisk requires the app_meetme.so module to be loaded in order to facilitate conferences. This module is dependent on the zaptel driver/dahdi. From 2006, onwards Zaptel had to be renamed or continued as DAHDI. If you did not include the MeetMe module and DAHDI above you may want to do so and recompile Asterisk. Setting up a conference in Asterisk is very simple. You only have to edit two files. These are the extensions.conf and meetme.conf file. The Files Required To Edit To set up conferencing, you need to create an extension. Create a high valued extension number such as 9000 to prevent conflict from client extension numbers. The first step is to edit extensions.conf and add the following: ; : : ; After previous entries exten => 9000,1,MeetMe(600,i,1234) Where: 600 => Room specified in meetme.conf file. i => Announces when people enter/exit the room 1234 => Password You also have to edit/create the meetme.conf file and add the following lines: [rooms] conf => 600 Now from one of the SIP clients, dial the extension number 9000. Note The clients should be prompted to enter passwords but we have not configured DAHDI channels. Setting these up are out of the scope of this document. IMPORTANT Before you reload asterisk you will have to load the DAHDI dummy timer kernel module, dahdi_dummy. A timer is required in order for conferencing to work. To do this, enter the commands below. You will have to load modprobe every time you reboot your machine. linux:/etc/asterisk # modprobe dahdi_dummy linux:/etc/asterisk # asterisk vvvc All 3 SIP clients can now simply dial 9000 to enter the conference. From the Asterisk CLI, type meetme and press enter. What do you see?
Setting up IVR Menus and Configuring VoIP Gateways This part of the lab already assumes that you have registered an account with Blueface. If not, you can sign up for a free trial on their website http://www.blueface.ie. You will have to take note of the extension number you get. This is in the email or in the account settings. This lab task will enable us to use own telephony system to make and receive calls to or from PSTN networks. All users will register through our system and we will forward to Blueface for external calls. This allows us to be in control of our own voicemail system, extension numbers, conferences etc. The first step in this lab will involve you connecting Asterisk to the Blueface SIP gateway [sip.blueface.ie]. Insert the following line in the top of your sip.conf file (under the [general] context). register => username:password@sip.blueface.ie/323228 Replace 323228 with your own Blueface extension number. Start the Asterisk server again and do a show sip registry on the CLI. What do you see? What does this output mean? Now that we have our clients communicating with our Asterisk PBX, and Asterisk communicating with our VoIP provider Blueface, we can configure it to handle incoming calls. We will create an IVR menu to greet our callers. To record the message s that users hear we will use Asterisk s recording application. To do this set up a temporary context in our extensions.conf file. Insert the following lines: [inbound-calls] include => tempmenu ; This is in addition to existing lines [tempmenu] exten=>9999,1,wait(2) ; Wait 2 seconds exten=>9999,2,record(/tmp/asterisk-recording.gsm) exten=>9999,3,wait(2) exten=>9999,4,playback(/tmp/asterisk-recording) exten=>9999,5,wait(2) exten=>9999,6,hangup Once you ve entered these lines, start Asterisk again and from one of the SIP clients phone the extension 9999. You will hear a beep. Record the following message: Welcome to our PBX, Press 1 to dial an internal extension, 2 to join a conference or 3 to hear this menu again Press the # button when you finished. 2 seconds later you will hear the message played back and a hang up. Repeat the step until you are happy with it. Exit Asterisk and copy the file /etc/asterisk-recording.gsm to /var/lib/asterisk/sounds/dcsmmainmenu.gsm.
Start up Asterisk again and repeat the step above but using this message instead: Please enter the internal extension that you wish to dial followed by the hash symbol The message will be recorded into the same file as above, so repeat the copy procedure above but instead use the file name DCSMInternalExtension.gsm Remember: Filenames are case sensitive in Unix. Now that we have recorded our messages, we can create a menu. Menus will be separated by contexts in our sip.conf file. Create the following context to handle incoming calls: [inbound-calls] include=>incomingpstn [blueface-in] type=peer host=sip.blueface.ie context=incomingpstn In the extensions.conf file place the following after the default context. [incomingpstn] exten=>1234,1,wait(1) exten=>1234,n,background(dcsmmainmenu) exten=>1,1,goto(internalext,s,1) exten=>2,1,goto(s,1) exten=>i,1,playback(invalid) exten=>i,n,goto(s,1) [internalext] exten=>s,1,playback(dcsminternalextension) exten=>s,2,read(number) exten=>s,n,dial(sip/${number}@192.168.2.2,20,r) exten=>t,1,voicemail(${number}@default) For outgoing calls include the following at end of sip.conf: [blueface-out] type=peer host=sip.blueface.ie fromuser=yourbfusername authuser=yourbfusername username=yourbfusername secret=yourbfpassword And following in extensions.conf: [voipcalls] exten=>_x.,1,dial(sip/${exten}@blueface-out) exten=>_x.,2,hangup Test outgoing by phoning your mobile number from one of our SIP Clients. Test incoming by dialing +353-1-5242025 extn: <yourbluefaceext>
Appendix /etc/asterisk/sip.conf [general] register=>donaloconnor:xxxxxxxx@sip.blueface.ie/xxxxxxx port = 5060 bindaddr = 0.0.0.0 allow = all context = inbound-calls [2000] type=friend username=2000 secret=password2000 host=dynamic mailbox=2000@default [2001] type=friend username=2001 secret=password2001 host=dynamic mailbox=2001@default [2002] type=friend username=2002 secret=password2002 host=dynamic mailbox=2002@default [blueface-in] type=peer host=sip.blueface.ie context=incomingpstn [blueface-out] type=peer host=sip.blueface.ie fromuser=donaloconnor authuser=donaloconnor username=donaloconnor secret=xxxxxxxx
/etc/asterisk/extensions.conf [general] static=yes writeprotect=yes [inbound-calls] exten=>2000,1,dial(sip/2000,20) exten=>2000,2,voicemail(2000@default,u) exten=>2000,102,voicemail(2000@default,b) exten=>2000,103,hangup exten=>2001,1,dial(sip/2001,20) exten=>2001,2,voicemail(2001@default,u) exten=>2001,102,voicemail(2001@default,b) exten=>2001,103,hangup exten=>2002,1,dial(sip/2002,20) exten=>2002,2,voicemail(2002@default,u) exten=>2002,102,voicemail(2002@default,b) exten=>2002,103,hangup exten=>171,1,voicemailmain() exten=>9000,1,meetme(600,i,1234) include => createmenu include => incomingpstn include => internalext include => voipcalls [createmenu] exten=>9999,1,wait(2) exten=>9999,2,record(/tmp/asterisk-recording:gsm) exten=>9999,3,wait(2) exten=>9999,4,playback(/tmp/asterisk-recording) exten=>9999,5,wait(2) exten=>9999,6,hangup [incomingpstn] exten=>1234,1,wait(1) exten=>1234,n,background(dcsmmainmenu) exten=>1,1,goto(internalext,s,1) exten=>2,1,goto(s,1) exten=>i,1,playback(invalid) exten=>i,n,goto(s,1) [internalext] exten=>s,1,playback(dcsminternalextension) exten=>s,2,read(number) exten=>s,n,dial(sip/${number}@192.168.2.2,20,r) exten=>t,1,voicemail(${number}@default) [voipcalls] exten=>_x.,1,dial(sip/${exten}@blueface-out) exten=>_x.,2,hangup
/etc/asterisk/voicemail.conf [general] format=wav fromstring=xxxasterisk emailsubject=new Voicemail (${VM_MSGNUM}) in mailbox ${VM_MAILBOX} emailbody=dear ${VM_NAME}:\n\n\tYou have a ${VM_DUR} long message (number ${VM_MSGNUM}) in mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}.\n\nThanks!\n\n\t\tXXX's Asterisk System [default] 2000=>3000,John Doe,jdoe@gmail.com,attach=yes 2001=>3001,John Smith,jdoe@msn.com,attach=yes 2002=>3002,Donal,jdoe@xxx.ie,attach=yes /etc/asterisk/meetme.conf [rooms] conf => 600 etc/asterisk/modules.conf [modules] autoload=yes VboxManage commands for NAT Forwarding > cd C:\Program Files\Sun\xVM VirtualBox > VboxManage setextradata YourVMMachine VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestasterisk/Protocol TCP > VboxManage setextradata YourVMMachine VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestasterisk/GuestPort 5060 > VboxManage setextradata YourVMMachine VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestasterisk/HostPort 5060