This blog post series is the steps to build a working unified messaging lab for Exchange Server. I thought I would write it all down as I found a lack of end to end documentation for the process and what I thought would be a days work turned into many as I worked at finding all the settings and configurations having no experience on the subject before this.
This part will look at taking the already installed AsteriskNOW server (in Part 2 and Part 3) and configuring a few telephone extensions and external calls. Part 5 will look at configuring unified messaging in Exchange Server 2010 and Part 6 the same for Exchange Server 2013. Later parts will look at connecting Asterisk to Exchange for voicemail.
Configuring Extensions
For this part you will either need to download a softphone (a SIP phone running as software on your PC) or have two physical SIP phones – EBay is a good source of SIP phones. I have two Draytek Vigor 350 phones which are a basic office phone that can connect to any SIP based IP PBX.
First we need to create two extensions based on your already determined dialplan (see Part 3 for more). In this lab 8xxx is the dialplan, so extension 1 will be 8001 and extension 2 will be 8002. Both extensions will have similar settings, just things like display name and extension number will change.
These changes can be made in FreePBX or directly in the config files. To do this in FreePBX click the Applications menu and select Generic SIP Device from the Device drop-down.
Enter the following as a minimum: Extension number, Display Name, a complex password for the secret (containing two letters and two numbers) and voicemail should be enabled and a voicemail password set (but the remaining voicemail settings can be ignored). Unless the phone will be used outside the firewall, set NAT to No-RFC3581. The secret will be the password the phone uses to register with the PBX. The user of the phone does not need this value and therefore make it very complex and you can copy and paste it into the phone’s configuration pages. If it is simple then you might find external connections being made to your PBX, logging in as your extension and making paid calls on your behalf and using up your credit with the SIP Trunk provider.
Repeat these steps for each extension you have and click Apply Config when finished. Remember that you made direct changes to sip.conf file (or the sip_general_custom.conf file) and the rtp.conf file and you have not yet applied these changes to Asterisk. Clicking Apply Config in FreePBX does all this for you. Use amportal restart from the Linux console if you made all the changes directly in the config files.
Connecting Telephones To Asterisk PBX
The exact steps for this will depend upon your actual phones, but you will need to have the IP address of the PBX, the SIP port, the extension number and the secret to hand. If your phone has a voicemail button then enter the pilot number as the number to call, as that is the number you chose for voicemail when looking at the dialplan.
The Draytek Vigor 350 phones that I am using have a web interface to them and the IP address can be determined from the phone menu button. From the phones web GUI I select SIP Account Settings and then select one of the available accounts, as this phone supports multiple SIP based IP PBX’s. The required information is then filled in:
In my case I am using port 5065 for SIP (over UDP) so I needed to mention it on the Registration Server line. If I was using 5060 I would not have needed it for this phone. Notice that once the information has been entered the phone shows that the connection is registered.
I repeat the configuration for all the other phones I have, just using the correct secret, display name and extension and once registration is complete the phone displays the SIP account by its display name on the LCD panel. I need to select this account to make calls using it on this phone.
You should now be able to dial the other extensions in your telephone network.
Configuring Trunks
Trunks are the name given to connections to other telephone systems and we need to configure a trunk to the outside world to enable us to make and receive calls from other phone systems. We will also in a later part of the blog make a trunk to Exchange Server for unified messaging.
To configure a trunk to the internet for making and receiving SIP based calls or for a SIP based call to be placed onto the classic telephone network you need an account with a SIP Trunk provider. There are a number of providers that are approved by Microsoft for use with Lync Server, but for now any that you have used before or can find via a web search should do. For this blog I am going to use Voipfone in the UK. Once I registered I got an email and 5 minutes of free outbound calls. The email contains my account details, inbound telephone number (UK starting 0560 in this case). Instructions for configuring Asterisk with Voipfone are at http://www.voipfone.co.uk/Asterisk_Setup.php and so I will not repeat them here apart from stating that you need to ensure that the settings go in the correct file.
If you have FreePBX installed as we do in this blog then you need to put the register value in sip_general_custom.conf and the [voipfone] section in sip_additional.conf or use the FreePBX web GUI directly. This is what we have done in the screenshot to the right:
The SIP Trunk settings are configured in FreePBX by going to Connectivity menu > Trunks. Add SIP Trunk and entering the required details. In the screenshot 12345678 is the account number and XXXXXX is the secret/password for the SIP trunk (which may or may not be the password for your account depending upon the provider). Don’t reveal this information, as it will allow others to use your credit at the SIP provider.
The settings entered into the trunk configuration are a simple as the name of the trunk under General Settings and again under Outgoing Settings and the following for PEER Details:
type=friend
secret=XXXXXX ;your voip password
username=12345678 ;your account number
fromuser=12345678 ;accont number again
fromdomain=sip.voipfone.net
host=sip.voipfone.net
insecure=very
dtmfmode=rfc2833
context=from-pstn
deny=0.0.0.0/0.0.0.0
permit=195.189.173.27/255.255.255.255
qualify=yes
And finally the following for the Register String:
12345678:XXXXXX@sip.voipfone.net/12345678
PEER Details and Register String values are available from your SIP Provider. You do not need to set an Outbound CallerID as per the warning you get in FreePBX. In addition to the settings I was provided by the SIP Trunk provider, I added qualify=yes to the PEER settings. This allows me to monitor connections to this trunk with the “sip show peers” command from the Asterisk console.
Configuring Outbound Routes
Before you can make any calls you need to set an Outbound Route and before you can receive any calls you need to make an Inbound Route. For the Outbound Route (Connectivity menu > Outbound Routes) create a new route for your SIP provider. At the very least you can give a name for the route and select the trunk you just created for Trunk Sequence 0. It is possible to add dial patterns to improve the functionality of the route. For example in the UK it is possible to dial six or seven digits when ringing within the same town or city. For this call to be handled by a UK SIP provider we need to automatically add the area code and for a non-geographic SIP provider we would need to add the international code as well. In the below screenshot the Outbound Route contains entries for handling emergency calls (route 999 and others via this SIP provider) and if I dial a local Oxford number (01865 being the area code) then all I need do is dial six digits and Asterisk converts this to 00441865XXXXXX.
The (0044)+0|[XXXXXXXXXX]/ entry will match any eleven digit number starting with 0 (X=any digit), remove the 0 and add 0044 before sending down this route. This allows for UK wide national calling. Miss any valid route (or place the numbers against a non-existent route) and you stop calls being placed to those numbers. A simple way to bar calls to premium rate numbers or international numbers. The 00. route matches all numbers starting 00 of any length and routes them via the trunk – this is to allow international calls. The full-stop/period symbol indicates any number and any number of numbers.
Apply Config to make your changes and then check in the Asterisk console if the connection is working okay by typing asterisk -Rv to enter the console for Asterisk and then sip show peers to see who is online.
Whilst you have the Asterisk console open (asterisk -Rv entered) if you make an external call it will show you the connection and any errors should there be any. Use the screen command before you enter the Asterisk console to allow you to scroll back through any messages reported to the console. Use ! to exit the Asterisk console and CTRL+A then [ to allow you to access the screen mode and allow the use of the arrow keys to scroll up and down the console output.
You should now be able to make outbound calls. Things like CallerID and so on are typically configured at your SIP provider, and in the case of Voipfone the default is to withhold them. It is also UK law to enter your physical address should you route an emergency call via a UK SIP Trunk from a UK address, and so if this applies to you then do this now – you don’t want to have to call an emergency and find you need to reconfigure your telephone first! Similar conditions will probably apply in your country too.
Configuring Inbound Routes
This blog will not go into the process of setting up an IVR (telephone answering menu) and will just route inbound calls to a single telephone extension. If you have a full telephone number per extension (DDI) then you can set up a number per physical device or you can create an IVR by adding that module to Asterisk.
To route all inbound calls to the primary extension (in this blog that is 8001) you need to enter the following config file entries:
Or use FreePBX and Connectivity menu > Inbound Routes and enter a name, your account number and a destination of going to a selected Extension.
Finally, dial the inbound number your VoIP provider has given you from another telephone system and see if your extension rings and that you can answer it and have audio going in both directions. One way audio typically means ports blocked on your firewall. If you extension does not ring then look on the Asterisk server console for any error messages. A common one is about context, and for this make sure that the Trunk configuration contains context=from-pstn and no other context values. Advanced configuration can change the context later, but this is outside of the scope of this blog.
So now we have a PBX that support IP (and specifically TCP) and you are able to make and receive telephone calls. Now its time to move to Part 5 to configure Exchange Server to provide your voicemail service and voice access to your email and calendar.
Leave a Reply