Sunday, April 29, 2007

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:


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



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.

ext config

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


Anonymous said...

FYI VMWare Trixbox2.2 (different credentials)

login: root
password: trixbox

Ryan said...

Thanks! I've updated the post.


Anonymous said...

I don't undrerstand why you are using trixbox AND sipx?

Trix can handle sip too..
wouldn't using Sipx simply be complicating things? Just make an extension on the Trxibox for the Xlite - and a siptrunk to for the zap - then point UM at it?
Am I missing something here?

Love the overview BTW.... well written.

Melbourne, Aust. (too)

Ryan said...

Hi Michael,

Exchange communicates using SIP over TCP only. Asterisk communicates using SIP over UDP only. SipX does both, and therefore can be used as a gateway between the systems.

SIP/TCP support is being developed for Asterisk, but as I understand it is in very early days.


Jose said...

Can you have voicemail just for a certain number of users to be forward to exchange or is it a all or nothing? We like to migrate users but some still like asterisk mainly for access to light up the light on the phones when user gets a voicemail.

Jose said...

Can you forward voicemail for for a certain number of users? We like to keep some users on asterisk for phone lamp light.

Ryan Newington said...


Short answer: Not using trixbox as it stands. We have to hack it to make it use an external email system rather than its internal systems.

Long Answer: Its possible to do. You would need to configure a different voicemail macro for both groups of users. I dont think freepbx would like it very much, and you would need some asterisk experts to be able to do it.


Yves said...

First I would say thanks a lot for this great integration notes. I have one question. If I use the follow me option on the trixbox, I still get in to the tb voicemail and not to the um. Any idea?
Thanks Yves

Ryan Newington said...

Hi Yves,

Please see my post

that provides a custom application required for voicemail using followme



Genaro said...

Hi, excelent article, i find a mistake in the image that describe PEER details, the image saids, type=friends in places of peers

Ryan Newington said...

Thanks for picking up on that Genaro.

zavage said...

this is such an amazing guide!!! thank you for all your help in building this lab Ryan.

i'll be testing for more configs...



Connecting two asterisk servers in same network

We have two asterisk servers in a same LAN , we can able to make calls using both the asterisk servers individually . But we need to communicate between two asterisk servers and to make call to the number exist in the another server. i.e. if Server A has number 1111 and server B has number 2222, i have to make call from 1111 to 2222 .
I have searched online for several times and tried the options given , but nothing seems to be working. Please guide me in this issue

Justin Hamade said...

Asterisk 1.6 is going to support SIP over TCP ... yay!!!

Matthias said...


I have a problem and i really checked every thing like 100 times.

when i test with 300 client on sipx everything works 222, 299, missed call no problem but when i use 400 on asterisk i can register and dial the 222 i get call established but i cannot hear anything same with 299, but when i go into owa and use play on phone and but the 400 extension on the asterisk i receive the call and hear the exchange.

the problem is i cannot dial to the exchange from asterisk but exchange can dial the extensions on asterisk.


Ryan Newington said...

Hi Matthias,

You will need to start with a SIP packet capture using wireshark to see what is going on.

Am happy to help review it if you get stuck.


GregT said...

Hi Ryan,

Thanks for the guide, they really helped a lot.

We are trying to route calls inbound using a 3com V7111 that has two POTS lines connected. This is driving us nuts as the only response you get is a dial tone from the TRIBOX.

Can you recommend a good FXO gateway? Cheap? That works?


Ryan Newington said...

Hey Greg,

The audiocodes gateways come highly recommended by people who have worked with them, and the support exchange/ocs.



Matthias said...

Hi Ryan,

I finally was able to connect the trixbox to my voip provider and to the exchange.

When i call from an internal extension to the exchange and wait i am redirected to the voicemail and can leave my message but when i call from an pstn number i also get redirected but after 1 sec i get disconected , but i see in outlook the missed call.

do you know what this can be?


and this is really a great tutorial


Ryan Newington said...

Hi Matthias,

It's hard to say without a SIP capture, but it could be a reinvite problem. Ensure canreinvite=no is set in the trunk connected to the provider, and make sure compatible voice codecs are used (alaw and ulaw are pretty safe)


harold crane said...

Hi Ryan,


Do you know of a way to get Exchange UM to turn on/off the message Waiting Indicator (MWI) on the trixbox attached phone?

Ryan Newington said...

Hi harold,

Unfortunately, Asterisk does not current provide a mechanism for receiving MWI message from a remote server through SIP NOTIFY events. Asterisk itself expects to be the voicemail system.


Charles said...

I've got all this working with inbound VOIP calls via Sipgate.

Does anyone know if its possible to auto detect and receive fax messages into an Exchange mailbox using this Trixbox, SipX setup?


remco wisselink said...


It's said before. A great post.

I had it all working. Exchange 2007, sipx and asterisk. Then had to reinstall everything. Instead of virtual server I'm know running everything on ESX.

I can call to 299 and 222 from my sipphone (300) connected to sipx to exchange.

But when I connect with 400 and try to call to my exchange server I get the message. all circuits are busy now.

Unfortunately I don't know where to look.

I'm an exchange guy not a telfony guy unfortunately.


blackshocks said...

In reply to remco wisselink:

i had exact same problem; I hadn't defined a DNS server for the trixbox and so it couldn't find either sipx or exchange servers - now all working flawlessly!!!