Building An Exchange Unified Messaging Lab (Part 7)

Posted on Leave a commentPosted in 2008, 2010, 2013, asterisknow, exchange, rtp, sip, unified messaging, voicemail

In this series of blog posts I am looking at creating a Unified Messaging lab for Exchange Server 2010 (and 2013). Earlier posts have looked at the installation of the PBX (AsteriskNOW) and the configuration of the Exchange Server.

This post will look at the configuration of the user’s settings. For each user there are two settings to configure. The first are the related settings on the telephone and the second is the configuration of the unified messaging properties on the Exchange mailbox.

The first set of settings are covered in detail in Part 4 of the blog but in brief they involve choosing a unique extension number that has the same number of digits as the dialplan (all extensions must be unique within the dialplan) and creating this extension within the PBX and configuring a phone to use this extension. Once you have done the steps in Part 4 of the blog you should be able to ring any of your extensions and pickup the call.

If you ignore the call or press any “reject” button on the handset you will find that Asterisk voicemail answers the phone. So this part of the blog series will go into the steps to configure Asterisk to forward voicemail to Exchange Server (and this is the same for Exchange Server 2010 or 2013).

Configuring Unified Messaging Mailboxes in Exchange Server

For each user you need to associate their mailbox in Exchange with their extension number. You can do with the Enable-UMMailbox cmdlet or the Enable Unified Messaging wizard in the Exchange Management Console.

For the wizard, right-click the mailbox under Recipient Configuration and select the Unified Messaging Mailbox Policy that you created earlier. Then either choose a PIN or have the system generate on for the user automatically. The user will get an email informing them of their PIN either way. Click Next.

imageIf the user already has the Business Phone attribute (or Telephone number attribute on the General tab in Active Directory Users and Computers) populated in Active Directory then the option to automatically generate the mailbox extension will be available, and the extension will be shown (greyed out) in the field to the right. If this is incorrect, or a full phone number was not specified, then only the manual option will be available.

The Exchange Management Shell cmdlet to do the same is:

Enable-UMMailbox username -PinExpired $false -UMMailboxPolicy 'policy_name'

 

 

or, if you want to specify the extension number:

 

Enable-UMMailbox username -PinExpired $false -UMMailboxPolicy 'policy_name' -Extensions '8001'

 

 

As each mailbox is enabled for unified messaging, the mailbox will get an email telling them the access numbers for voicemail (the dialplan subscriber numbers), their number (which should be the same as their telephone extension number) and their PIN.

 

On the mailbox, if you look on the E-mail Addresses tab you will see the EUM address, and this should read ext;phone-content=policy. You can add additional extensions (EUM addresses) here manually if you wish.

 

Configuring and Using Outlook Voice Access

 

Now that you have the extension configured on a phone, the same extension configured against the mailbox, a dialplan with subscriber access number configured, SIP trunks to Exchange and an Outbound Route for the subscriber access number you should be able to ring the subscriber access number from your physical handset.

 

Upon dialling from the phone configured with your extension number you will hear the Exchange chimes and be asked to setup your Outlook Voice Access for the first time. You will need your PIN number to complete this, and this will have been emailed to the mailbox at the time the mailbox was configured for UM.

 

Configure Asterisk to Forward Calls to Exchange Unified Messaging for Voicemail

 

Asterisk defaults to forwarding calls to its own voicemail extensions and so edits need to be made to extensions.conf (or linked files if using FreePBX) to route calls to Exchange Server for voicemail.

 

In this blog series we have FreePBX installed, so we need to edit /etc/asterisk/extensions_override_freepbx.conf rather than extensions.conf. The first change is to copy the [macro-vm] section from /etc/asterisk/extensions_additional.conf into /etc/asterisk/extensions_override_freepbx.conf. [macro-vm] is approx 150 lines long and ends with “;–== end of [macro-vm] ==–;”.

 

Then we need to make some changes and additions to the macro-vm section. The first set of changes will comment out the code the directs calls to Asterisk voicemail and the additional lines will dial the Exchange Server trunks and add SIP Diversion headers so that Exchange knows which mailbox to answer the call for.

 

So first, locate the following lines and comment them out. The numbers in brackets at the start are the approx. location in extensions_override_freepbx.conf where you will find the line:

(86) exten => s-BUSY,n,VoiceMail(${MEXTEN}@${VMCONTEXT},${VM_OPTS}b${VMGAIN})
(92) exten => s-NOMESSAGE,n,VoiceMail(${MEXTEN}@${VMCONTEXT},s${VM_OPTS}${VMGAIN})
(97) exten => s-DIRECTDIAL,n,VoiceMail(${MEXTEN}@${VMCONTEXT},${VM_OPTS}${VM_DDTYPE}${VMGAIN})

 

Each of the above lines can be commented out by placing a semi-colon (;) at the start of the line.

 

Return to the s-BUSY block (starting at line 84) and add the following after the line that you just commented out:

exten => s-BUSY,n,SIPAddHeader(Diversion:<tel:${MEXTEN}>\;reason=no-answer\;screen=no\;privacy=off)
exten => s-BUSY,n,Dial(SIP/xxxx&SIP/yyyy) /* xxxx/yyyy here are the two trunk names, one for each TCP listening port */
exten => s-BUSY,n,Hangup

 

This code adds the Diversion header to read tel:extension. Note that the tel:ext block is surrounded by greater and less than signed (triangle brackets if you will) which have a habit of not being displayed on web pages.

 

Also note that you need to use the names of your two trunks connecting to Exchange that you will make in the final part of this blog series (Part 8). You will make one trunk connecting to port 5065 and the other to port 5067. The Dial() command tells Asterisk to dial both trunks at the same time and direct the call to whichever answers first. Therefore if Exchange is listening on 5065 or 5067 the connection will work. For ease of configuration, if you pick the names for the two trunks now you can add them to the config file here and then when you create the trunk in Part 8 you just need to use the same names. I used ToExchangeUM5065 and ToExchangeUM5067 in my lab. Then I replace xxxx with ToExchangeUM5065 and yyyy with ToExchangeUM5067.

 

The s-NOMESSAGE block (at line 92) needs the following added after the line that has been commented out:

exten => s-NOMESSAGE,n,SIPAddHeader(Diversion:<tel:${MEXTEN}>\;reason=no-answer\;screen=no\;privacy=off)
exten => s-NOMESSAGE,n,Dial(SIP/xxxx&SIP/yyyy) /* xxxx/yyyy here are the two trunk names, one for each TCP listening port */
exten => s-NOMESSAGE,n,Hangup

 

Again, change xxxx and yyyy for your two different trunk names that you create in the next part of this blog and make sure that the Diversion: header includes triangle brackets around tel:ext.

 

Next you need to do the same for the s-DIRECTDIAL block:

exten => s-DIRECTDIAL,n,SIPAddHeader(Diversion:<tel:${MEXTEN}>\;reason=no-answer\;screen=no\;privacy=off)
exten => s-DIRECTDIAL,n,Dial(SIP/xxxx&SIP/yyyy) /* xxxx/yyyy here are the two trunk names, one for each TCP listening port */
exten => s-DIRECTDIAL,n,Hangup

 

As you can see, the three blocks of inserted code are all the same apart from the s-WORD value at the start of each.

 

One block of code is missing through from the FreePBX defaults. If you call an extension and it is busy Asterisk runs the code starting s-BUSY, but if the call is ignored then Asterisk attempts to find and run code starting s-NOANSWER and as this is missing it will route ignored calls to Asterisk voicemail. To route ignored calls to Exchange Server add the following block of text:

exten => s-NOANSWER,1,Noop(NOANSWER voicemail - Exchange UM)
exten => s-NOANSWER,n,Macro(get-vmcontext,${MEXTEN})
exten => s-NOANSWER,n,SIPAddHeader(Diversion:<tel:${MEXTEN}>\;reason=no-answer\;screen=no\;privacy=off)
exten => s-NOANSWER,n,Dial(SIP/xxxx&SIP/yyyy) /* xxxx/yyyy here are the two trunk names, one for each TCP listening port */
exten => s-NOANSWER,n,Hangup
exten => s-NOANSWER,n,Goto(exit-${VMSTATUS},1)

 

This new block is again a copy of s-BUSY (or the other two) and just the s-WORD bit changed to s-NOANSWER. For completion the Noop line (line 1 above) is also changed to NOANSWER so that the correct text is written to the Asterisk console and log files.

 

No other changes are needed in extensions_override_freepbx.conf. So save the file and restart Asterisk by using amportal restart from the console.

 

There is now one more thing to do. That is to create the SIP Trunks to Exchange Server. This is detailed in Part 8, and once you have a way to connect to Exchange Server you are able to route voicemail requests to Exchange and complete your unified messaging lab.

Building An Exchange Unified Messaging Lab (Part 3)

Posted on 2 CommentsPosted in 2010, draytek, exchange, firewall, rtp, sip, unified messaging, voicemail

This blog is part of a series on creating a unified messaging lab for Microsoft Exchange Server. Configuring Unified Messaging was not as easy as I thought it would be and there was a lack of information that brought all the settings into one place, and a lot of incorrect information! The series started with Part 1 for the requirements and Part 2 for the initial configuration of AsteriskNOW and FreePBX.

Up until now the changes you have made have been pretty much the same for everyone. Sure, you have set an IP, keyboard and timezone that are different but everything else has been pretty much standard. Now we need to change some Asterisk configuration files to support Exchange Server Unified Messaging.

Configuring Asterisk for Internal and External Calls

As we have chosen to install FreePBX as well, we will edit the configuration files that FreePBX does not control. If you are doing your configuration without FreePBX installed there will be different files to change.

Before we make the changes though, you need to decide a few things. Some of these will be determined by your current environment. The first thing you will need to know is the number of digits in your dialplan. A dialplan is the internal extension number configuration at your office. For example if you dial 1xxx to reach one office and 2xxx to reach another then you have a four digit dialplan and sequences starting 1 and 2 are already reserved. In my lab I am going to use a four digit dialplan where 8xxx is going to be allocated to physical telephone handsets (extensions) and 8000 is going to be the number I call to listen to my voicemail (the Pilot Number) when I am using Exchange 2010 and 8500 when I am using Exchange 2013. Two numbers for voicemail allows me to use two different Exchange labs from one set of SIP phones.

Once you have picked your dialplan you can start to configure the various components of your PBX for your telephone network. These changes include forwarding your pilot number (8000 and 8500 in this blog) to Exchange and configure your telephone extensions.

In Asterisk we need to do these configuration changes by editing the config files. We can do this in a few different ways. We can edit the config files directly in the Linux console (using text editors such as vi), use WinSCP from a Windows PC if you don’t want to edit the files in Linux directly or use FreePBX for some of the changes. You must use FreePBX to change any file that has the FreePBX banner at the top of the config file.

SIP.Conf Changes for NAT and Exchange Server

Firstly, if you have a NAT’ed network you need to tell Asterisk your external IP address. Edit /etc/asterisk/sip_general_custom.conf to contain:

nat=yes
;externip needs to be your public IP
externip=w.x.y.z
;localnet=internal_IP_network/subnet_mask
localnet=192.168.5.0/255.255.255.0

You also need to add the following to the same file:

context = default
bindport = 5060
bindaddr = 0.0.0.0
tcpbindaddr = 0.0.0.0
tcpenable = yes
promiscredir = yes

Amongst these changes some of them tell Asterisk to listen on TCP, bind to all IP addresses and listen on port 5060 for UDP. Exchange Server and Lync Server require TCP support from the IP PBX that they connect to and without these settings Asterisk will only do UDP. Asterisk 1.8 will only listen on 5060 for TCP and there is no config setting to change this. The bindport setting controls the listening port for UDP.

Notice that we changed the sip_general_custom.conf file and not sip.conf. If you did not have FreePBX installed you would make all your changes to Asterisk in the config files and so could edit sip.conf directly. FreePBX overwrites some config files with its settings whenever you click Apply Config in the web GUI. To avoid having your settings overwritten you need to make them to files that are referenced by include statements in the master file.

For this example, if you open sif.conf (in /etc/asterisk) then in the [general] section (where the above edits are needed) you will see #include sip_general_custom.conf. This tells Asterisk to load sip_general_custom.conf as part of sip.conf, and we know that sip_general_custom.conf will not be overwritten by FreePBX because it does not tell us this at the top of the file.

To determine the file that you need to make the change in for other config files open the master file that you need to edit (i.e. sip.conf in this example) and see if there is a FreePBX banner at the top of the file. If not, then edit the file as required. If there is a banner telling you not to make changes then look for the section that your change will be inside (for example in sip.conf above we made our initial changes in the [general] section) and locate the #include statement that follows that section. This statement tells Asterisk the name of additional config files to load and to consider as part of the master file that you are currently reading. Some of these include files contain the FreePBX banner as well but others don’t for example to make changes to the [general] section of sip.conf we will edit sip_general_custom.conf, the custom config file for the general section in the sip.conf file.

RTP.Conf Changes For Your Network

SIP is the protocol that is used to manage connections between the parties involved in the call. RTP is the protocol used to transfer the voice data. You need to edit /etc/asterisk/rtp.conf so that the rtpstart and rtpend values are suitable for your network.

For each call connections will be made to 5060 and two additional ports. These two additional ports need to be sequential, and the odd numbered port will carry RTP data (voice traffic) into your PBX and the even numbered port carries RTCP packets (data about the connection). Outbound SIP/RTP traffic is determined by settings on the other parties PBX, so you typically need to allow all outbound ports from your PBX.

Therefore you need to configure Asterisk to have a start and end range for RTP that is a minimum of two ports (for one concurrent call) and a max of the number of concurrent calls you can make to through your PBX. Your external firewall will need to be configured to publish all these ports to your IP PBX so don’t make the range too big – but equally you need two ports per concurrent call so don’t make the range too small.

The range will always be the higher of the max number of calls your SIP Trunk provider allows and the number of physical handsets you have (plus some overhead to allow for parked calls). So if you have a five call SIP trunk, ten staff members, and 12 handsets you would need to support at least 12 concurrent calls. Therefore configure RTP to start at 10010 and finish at 10034 (two ports for each of the twelve concurrent calls you can support). Then increase it a bit for your sanity!

Edit /etc/asterisk/rtp.conf so:

rtpstart=10110
rtpend=your calculated value

 

Make sure your firewall forwards these ports to this PBX server and if you have other PBX servers ensure that you do not use the same port range. The following shows an example firewall configuration for this PBX. In the picture and in my config files I am using 5065 for SIP as I have two PBX’s and the other is using 5060.

 

image

 

Once we test calls to the outside world, if you start getting “one way traffic” (that is you can be heard but you cannot hear the caller or the reverse) then you need to check your firewall rules.

 

In Part 4 the fun will start. In this part we will configure a few telephone extensions so that we can make internal calls and then configure a SIP Trunk provider so we can make external calls. Part 5 will look at configuring Exchange Server 2010 and Part 6 the same, but for Exchange Server 2013. Part 7 will look at connecting these calls to your Exchange Server when we want to record a voicemail message.