Asterisk 1.6 with Office Communications Server 2007

I’ve personally been waiting for this release of Asterisk for some time now! After researching a little, I found out that Asterisk 1.6 now supports TCP & TLS.  Currently it is still considered experimental – but hey, it’s always fun to play!

For those of you who are only familiar with Trixbox or FreePBX, there is no support for any graphical interface on 1.6 as of yet.  But,I will keep this simple and to the point.  Installing Asterisk on a Linux box with Kernel 2.6 is fairly straightforward.  In this Lab, I deployed CentOS 5 - Kernel 2.6.18 with Asterisk 1.6.  When installing the OS you will also need the Kernel Sources and Kernel Headers packages.

First step of course is to build a Linux Box – I built mine in a VM, but installing on hardware will work just the same. 

You can download Asterisk from On your Linux box make a directory under /usr/src – called pbx.  From that directory you can use the following command:


Next step is to unpack the package:

tar zxvf asterisk-1.6.0.tar.gz

With that done – we use the common method to build the source:

Change into that directory – cd asterisk-1.6.0



make install

make config

make samples

Start Asterisk by running /etc/init.d/asterisk start

Then run asterisk –vr.  This will bring you into the Asterisk CLI:

Now you know Asterisk is up and running and we can get into modifying some configuration files.  For this Lab there are only 2 files we need to be concerned with; SIP.CONF & EXTENSIONS.CONF which can be found under /etc/asterisk.

Starting with the Sample Config files that were created we can just select and delete everything and then paste these example configs in:



context = default

bindport = 5060

bindaddr =

tcpbindaddr =

tcpenable = yes



type = peer

host =

qualify = yes

transport = tcp,udp



type = friend

callerid = Linux User <5001>

secret = 5001

host = dynamic

canreinvite = no

dtmfmode = rfc2833

mailbox = 5001

disallow = all

allow = ulaw

transport = udp











exten => _+XXXX,1,Answer()

exten => _+XXXX,n,Set(CALLERID(name)=You Did It)

exten => _+XXXX,n,Set(CALLERID(num)=${CALLERID(num):1})

exten => _+XXXX,n,Goto(${EXTEN:1},1)


exten => 5001,1,Answer()

exten => 5001,n,Dial(SIP/5001,20,tr)

exten => 5001,n,Hangup


include => outbound



exten => _NXXNXXXXXX,1,Set(EXT=+${EXTEN})


exten => _NXXNXXXXXX,n,Busy



Next we will use X-Lite SoftPhone to register extension 5001 to Asterisk.




Configure the SIP Account on the SoftPhone:



When you hit the Apply button you will be registering the SoftPhone with Asterisk:



You can also see the registered extension from the Asterisk CLI/Console:



Now onto the OCS Configuration (In my lab I have a single SE server, and I installed a Mediation Server).  Let’s start with the Mediation Server. 


As you see below, there are 2 IP Addresses on the Mediation Server.  Both of them are on the same network.  Of course you can place them on different networks if needed.  Note, if they are in the same Network make sure that the External or PSTN facing interface set to not register with your internal DNS:



On the Next Hop Connections Screen, you can see that we are pointing this back to the Asterisk PBX and the Inbound Routing is pointing back to the OCS Pool.



The Mediation Server configuration is not any different than other configuration when setting up Enterprise Voice pointing to any other SIP Gateway.

Now, onto the Global Forest Property and Pool configurations.


I have added this Location Profile Normalization Rule for this test:



Now that you have a Normalization Rule built you will need to make a Policy and Route.  Here is an example of the Route I built for Testing:



One final step before making a call from the OCS MOC Client to the Softphone is to configure your OCS User for Enterprise Voice.


Under your OCS Pool, select Users then right click to get to the Properties of the user.  Click Configure on the User Properties Screen.

When you log in from you MOC 2007 Client, you will be able to dial 5001.  This will get normalized to +5001 and Dial out via the Mediation Server then through Asterisk to the SoftPhone. 


On the PC with the SoftPhone you will a pop-up for the call will appear and you can answer or ignore it:



Now let’s make a call in the other direction.  On the “MOC Side” you will get the toast indicating a call is coming in:




Well that’s about it! I am sure I could have gone into more detail regarding setting up OCS and the Mediation server.  But I wanted to concentrate on showing how to configure Asterisk, since the configuration for OCS is the same as when configuring it for any other SIP Proxy/SIP Trunk (Mediation Server/Media Gateway).


Also there is so much you can do with Asterisk.  No physical TDM cards were used, but in a production environment one could easily add Analog and/or T1 TDM and make phone calls across the PSTN.



Comments (31)
  1. Anonymous says:


    What a good article, much better than the Asterisk 1.4 <-> sipX <-> OCS config I had previously.

    I am kind of stuck when it comes to making the call from the SIP Phone to MOC. There isn’t a route back through to MOC, is there?



  2. Geoff Clark MSFT says:


    When making the call from SIP Phone – there should be a route on the Asterisk Server to go out the Trunk pointed to the Mediation Server.

    Is the call making it to the Mediation Server?  You can email me directly for assistance on this if needed.


  3. Geoff Clark MSFT says:


    What version of Asterisk are you running.  Some issues have come up with certain versions of Asterisk that has caused one way communication.

    The latest works great.


  4. Anonymous says:

    Hi, nice article.

    There’s a fix for the UNREACHABLE thingy in Asterisk 1.6. This may fix trunk related issues.

  5. Anonymous says:


    I should make an ocs-asterisk as shown in this article, I followed all the steps needed, but I get only a communication between asterisk-ocs and not vice versa. I have performed all necessary steps, I gave the profile in the front-end server but I have a one-way communication asterisk-ocs. What I forgot to set?

    thanks rob

  6. shady says:

    where is the configuration on the Asterisk server to go to the Trunk pointed to the Mediation Server ??

  7. Gilberto Verastegui says:

    Thanks a lot Geoff…good article

  8. Anonymous says:

    Last week I discussed how to connect Asterisk with OCS Mediation Server over TCP. I figured since we

  9. Geoff Clark MSFT says:

    On the issue of making sip calls from Asterisk to OCS you need to modify the trunk to look like the following.


    type = peer

    host =

    qualify = yes

    transport = tcp,udp

    The configuration above is the Trunk that points to the Mediation Server.  Host is the IP Address of the gateway side of the Mediation Server.


  10. shady says:

    I can’t make any calls from the sip account to the OCS,

  11. Anonymous says:

    First time I see a complete recipe on how to put to work two things.

    Great article, and by the way, Asterisk works like a charm with OCS.  In production right now.

  12. skulmat says:

    Is it possible, to have them integrated to the extent that they are passing calls back and forth? Including office communicator displaying presence when an extension is on the phone, etc…

    From here it just looks like it is asterisk is being used just to get the call out or in.


  13. OJ says:

    Did you manage to see the calerid(name) of the caller in OCS and not just the number?

  14. Geoff Clark MSFT says:

    If the appropriate CU3 updates to R2 – yes you can get Inbound Name & Number.

  15. OJ says:

    Can you please explain this in more detail? What do you mean with CU3 updates to R2?

    I only see the callerid(num) from Asterisk in my Communicator, but not the Asterisk callerid(name) using OCS2007R2 and Asterisk

  16. Geoff Clark MSFT says:

    This KB explains how to pass outbound Caller-Id Name,  but to get what you want you just need to apply CU3 to all roles and clients…/972721

    Currently we are at CU6, so just apply these updates to your Server Roles (FE, Mediation, Edge, Back End and Clients).…/details.aspx

    For Server install the ServerUpdateInstaller.exe, Back End needs to be updated with OCS2009-DBUpgrade.msi.  Also make sure you are running the latest client, as it is needed to support the Caller-Id Name.


  17. OJ says:

    Hi Geoff,

    the first link leads me to the same page as the second link when trying to download the patch.

    Seems to be like UcmaRedist.msp is the patch that should fix this issue?

    I upgraded my backend server with OCS2009-DBUpgrade.msi and ran ServerUpdateInstaller.exe on my backend server and on my mediation server and installed all updates that the tool suggested.

    But still the callerid-name is not displayed in my OCS client.

    Then I ran Microsoftupdate on all machines (backend, mediation server, client) and installed all OCS-related updates that were offered, but still I don't see the callerid name in my OCS client.


  18. Geoff Clark MSFT says:

    The first link was to show the changes to be made via config file.  But if everything is updated – what version client are you running?  Should be CU6 as well.  Also next step would be look collect traces from Mediation to make sure the name is being passed to the FrontEnd Server.


  19. OJ says:

    Everything is updated with the latest patches available that i found at microsoftupdate and i used the latest version of Office Communicator 2007 R2.

    Does it work for you with your asterisk installation?

  20. Geoff Clark MSFT says:

    Yes it works for me.  Send me your email and we can catch up on Monday and get you going.


  21. Teo says:

    I applied the steps above to my AsteriskNow PBX with FreePBX installed.  The only piece not working is the call from the MOC client to Asterisk.  How do I configure my extension through asterisk so that it will pick up calls from the SIP trunk?

  22. Geoff Clark MSFT says:

    Are you seeing the calls hit the Asterisk Server?  If not, you can collect SIPStack,MediationServer logs from the Mediation Server using OCSLogger to find out why it is failing.


  23. paul says:

    I was wondering is when you completed this setup, is presence information passed back to the ocspool?  We want to have the users presence in the MOC to reflect if someone lifts up their physical phone handset that is provisioned from Asterisk.

  24. Geoff Clark MSFT says:

    No you can not implement this feature with Asterisk for Free.  You are looking for a CSTA gateway to interface between OCS and Asterisk.  There are some companies that make a product, but I have not found a free product as of yet.

    Good luck with your search.

    Geoff Clark

  25. camilo says:

    Whats up?? hey man i have a question, i can perform that procces with lync??, do you know something??

  26. Geoff Clark MSFT says:

    Is the question can you integrate Asterisk and Lync?  – Answer: Yes.  


  27. Tim says:

    thank you very much. I did it according to your article. thanks again!

  28. Tim says:

    thank you! I did it according to this article. my environmet is lync 2010 integrating asterisk.

  29. Tam Vo says:

    Hi gclark,

    Good job.

    Could you please give me your email or yahoo messenger id ?

    I have some questions needing your answer.


    Tam Vo

  30. Geoff Clark MSFT says:

    Just post your questions here – so everyone can learn from your environment.


  31. crostie says:

    How about the following CSTA on Source Forge:…/files

Comments are closed.

Skip to main content