Accessing Exchange 2007 Unified Messaging: Part 6 – Configuring Asterisk/Trixbox

------------------------------------------------------
Update: 28/7/2007
Updated with new screen shots, instructions for using Exchange UM for Voicemail and for more appropriately enabling two way communication between Exchange, sipX and Asterisk

Update: 4/10/2007
Changed SIP type definition in extensions from 'friend' to 'peer' to allow Play on Phone to work correctly

------------------------------------------------------

Initial Configuration

Start your Trixbox VMWare virtual machine. Log in as root, with the password trixbox (or password for an older Trixbox 2.0 VM) and change the root password by typing passwd at the command line. Remember this password, as you will not be able to log into the server without it. Unlike with the sipX server, you are not prompted to configure the network card at system start up. Instead, you will need to type netconfig at the command line. When prompted if you want to setup networking, choose Yes and assign a manual IP address to this PC.

You should now check for operating system and package updates by typing the following at the command line.

yum –y update

This may take some time depending on how many updates are needed. There are significantly fewer packages in this distribution, and the update process should only take a few minutes. Once the packages have been updated, restart the server using the following command:

reboot

After the server reboots, open your browser and navigate to the Trixbox server i.e http://asterisk.lithnet.local. You should now see the screen below

To get into administrative mode, click switch up in the top right corner. Enter the username maint and the password password when prompted.

Configuring Voicemail

The first thing you will want to do is configure Trixbox to use Exchange UM for voicemail, rather than its internal systems. To do this we need to install the voicemail module.

Once you have logged into the admin mode, click Asterisk in the top menu bar, and then click on FreePBX. Click Tools on the top menu of FreePBX, then on the left hand side, click Module Admin. Scroll down to the Basic section, and click on Voicemail. Select Install as the action, and press the Process button at the bottom of the screen. When the module has installed, click Setup at the top of the FreePBX menu to return to the main configuration screen.

Now we need to modify the Asterisk configuration file extensions.conf, and we can do this from the Trixbox Admin mode web page by clicking Asterix then Config Edit, followed by extensions.conf on the left hand side.

Locate the [macro-exten-vm] section and comment out the line:

exten => s,n,Macro(vm,${VMBOX},${DIALSTATUS})

so that it reads:

;exten => s,n,Macro(vm,${VMBOX},${DIALSTATUS})

Beneath the newly commented-out line, add the following two lines, replacing 222 and sipx.lithnet.local with the Exchange Subscriber Access number and your sipX FQDN respectively (note the following text has wrapped because of my blog's template, but it should be all on one line in your config file):

exten => s,n,SIPAddHeader(Diversion: <tel:${EXTTOCALL}>\;reason=no-answer\;screen=no\;privacy=off)
exten => s,n,Dial(SIP/222@sipx.lithnet.local|30)

Click the Update button and then Re-load Configs.

Thanks to James Brooks for providing us with these voicemail configuration steps.

Configure the sipX Trunk

When talking about telephony, a trunk is basically a connection between two separate systems. In a traditional PBX, a trunk line is an external line to the PSTN, and an extension is an internal line to a handset. Trunks can be one way, or bidirectional. We need to configure a trunk for each connection we make to another system. In this guide, we will configure a trunk to the sipX system, as well as a trunk to our VoIP provider. Once we have our trunks setup and in place, we can then create routes, which tell the IP-PBX which trunk to use for various types of calls.

Once you have logged into the admin mode, click Asterisk in the top menu bar, and then click on FreePBX. In the FreePBX screen, click Setup in the top menu bar, followed by Trunks on the left hand side. The right hand side has a list of the trunks configured on the system. Click Add SIP Trunk. Enter the details shown below.

Leave Outbound Caller ID blank
Tick Never Override Caller ID
Leave Maximum Channels blank
Leave the Dial Rules box blank
Leave Outbound Dial Prefix blank
In the Trunk Name box, type sipXTrunk
In the Peer Details box type

host=sipx.lithnet.local
ype=peer
canreinvite=no
insecure=invite
context=from-internal 

Leave the User Context, User Details and Register String blank, and click Submit Changes.

Please note that while we are leaving the 'incoming settings' section blank, setting the value 'type=peer' above, allows the trunk to be used for both incoming and outgoing calls.

There is a default trunk ZAP/g0 that we do not need. Click on ZAP/g0, and click Delete Trunk g0 on the next screen

Note that after every change you make to the Asterisk configuration, a red box will appear at the top that you click to Apply Configuration Changes. Before testing any call to Asterisk, please make sure you press this button. You don't have to press it after every single change, but the changes you made since you last 'Applied Changes' won't take effect until you do. I'm not going to tell you every time you make a change to press this, so I'll leave it up to you to do this as appropriate.

Configure the sipX Outbound Route

Now we have our trunk (connection) to the sipX server setup, we need to tell Asterisk what type of calls it should forward to it. We do this by means of an outbound route. On the left hand menu, click Outbound Routes, followed by Add Route on the right of the screen. Enter the following information

Type sipXRoute for the Route Name
Leave Route Password blank
Leave Emergency Dialing unticked
Leave Intra company route unticked
In the Dial Patterns box, type [2-3]XX, which tells Asterisk to use this route for any 3 digit numbers starting with 2 or 3.
Select SIP/sipXTrunk in the first Trunk Sequence drop down box.

Click Submit Changes, and we are done.

Add an Extension

Now we create the extension we will use. On the left hand menu, click Extensions, then select Generic SIP Device and click Submit. Enter the following information.

User Extension: 400
Display Name: Your Name
Direct DID: 400
DID Alert Info: Leave blank
Outbound CID: Leave blank
Emergency CID: Leave blank
Secret: your password
Dtmfmode: rfc2833
canreinvite: no
context: from-internal
host: dynamic
type: peer
nat: yes
port: 5060
qualify: yes
callgroup: leave blank
pickupgroup: leave blank
disallow: leave blank
allow: leave blank
dial: leave as default (should be SIP/ext#)
accountcode: leave blank
mailbox: leave as default
Fax extension: freepbx default
Fax email: leave blank
Fax detection type: none
Pause after answer: 0
Privacy Manager: No
Record Incoming: On Demand
Record Outgoing: On Demand
Voicemail & Directory
Status: Enabled
Password: 12345 - not used but must not be blank

Leave the remain voicemail options at their default, they are not used. We only use the 'Status' value to see if voicemail is enabled for a particular user, and FreePBX won't let us save the extension without specifying a password.

Configure X-Lite to log onto the Asterisk server

Now that Asterisk is configured, we can change X-Lite to log onto the Asterisk server, and test the new routes we configured. At the top of the X-Lite screen, there are 3 buttons. The left button shows a drop down menu, which gives us the SIP Account settings option. Press the Properties button, and change the username to 400, and enter the password you entered above. Change the domain to asterisk.lithnet.local, and ensure the option to Register with domain and receive incoming calls is selected.

Press OK when done, and return to the main screen. The phone will now register with the Asterisk server, and be ready to make and receive calls. Make a test call to the OVA number (222) to make sure the routing works fine. When you have confirmed that is working, call the Auto Attendant, and when asked who you wish to contact, say your name. The Auto Attendant will then transfer your call to your extension, and X-Lite should start ringing on Line 2.

Other fun things you might like to do

Enabling inbound calls to Exchange UM from the PSTN using Asterisk and an external VoIP service provider

Enabling outbound calls from Exchange UM (OVA) to the PSTN using Asterisk

Adding SIP Aliases to Asterisk Extensions

Configure Asterisk to receive incoming SIP calls

Next: Troubleshooting
Previous: Part 5 - Configuring the SIP Client