Series: Exchange 2013 and Lync 2013 Integration with AsteriskNOW PBX Pt. 2

In Part 1 of this series I went through the process of setting up our AsteriskNOW PBX. Now in Part 2 we need to connect the AsteriskNOW PBX to our Lync 2013 environment. We will break this down into 4 primary steps. First step will be to configure AsteriskNOW SIP trunk to route calls to Lync, Secondly we need to configure Lync to Normalize and Route calls to AsteriskNOW, third we need to enable Lync users for EV, and finally we will test calls in both directions.

Let’s open the FreePBX Admin page (http://asteriskserverip), click FreePBX Administration, and then type admin for both the username and password. Once you have connected click on Connectivity, select Trunks, and then choose “Add SIP Trunk”. Input the details below that pertain to your environment. A lot of the articles that I ran into left out 2 very important settings type=friend and insecure=very which caused my communication to fail. Also be sure to clear out both the USER Context and User Details boxes. After entering this data select Submit Changes at the bottom of screen (scroll all the way down) and then the red Apply Config at the top of the screen.

  • host=<IP address of Lync Server or SE FQDN\EE Pool Name>
  • transport=tcp,udp
  • port=5060
  • insecure=very
  • fromdomain=<IP Address of AsteriskNOW PBX Server>
  • type=friend
  • context=from-internal
  • promiscredir=yes
  • qualify=yes
  • canreinvite=yes

***Added the couple of commands below which were brought to my attention by the Anonymous User below and Ariel L (Microsoft)***

Depending on your version you might be able to do this via GUI. If in the GUI you see Settings - Advanced SIP Settings then click on that. Scroll down to "Other SIP Settings" and add the following two lines tcpenable = yes and transport = tcp. If you don't see those then you will need to edit the sip_custom.conf that Anonymous described below. To edit this file you can perform the following commands from Linux shell after logged in as elevated user or root.

vi /etc/asterisk/sip_custom.conf

Hit Insert on the keyboard and type tcpenable = yes and transport = tcp on 2 separate lines

Hit the Esc key on the keyboard to exit Insert mode and type :wq to save and exit

Now we need to configure our Inbound and Outbound routes. First our Inbound Route. Click Connectivity and select Inbound Routes. In the Description give your incoming route a name (FromLync) and under Set Destination select Trunks and select the trunk we created above (Fabrikam Lync Trunk). Click Submit and then Apply Config.

Next is our outbound route going to Lync. Click Connectivity and select Outbound Routes. In the Route Name give the route a name (ToLync) and under Trunk Sequence for Matched Routes select our Trunk (Fabrikam Lync Trunk). Now the most important part which I skipped over is we need to set our Dial Patterns that will use this Route. When we send calls to Lync they will need to be in E.164 format (e.g. +12673645102) so that Lync will recognize them. In the prepend field under dial patterns we need put our Lync TEL URI (including the +) excluding the extension (e.g. +1267364). Now in the match pattern field put the first digit of your extension followed by X’s for the remainder of the digits. Since I will be using 4 digit extensions starting with 5 I will insert 5XXX. See example below. Next select Submit Changes and then Apply Config. This completes our AsteriskNow configuration and we can now move to the Lync 2013 side.

Now that AsteriskNOW can route calls to Lync we need to configure Lync to accept the calls for EV enabled users and route calls back. We are going to start by creating a SIP Trunk to AsteriskNOW so lets open the Lync Topology builder on one of our Lync Servers. Once the topology build is opened choose Download Current Topology and choose a location where to save the file. Once the Topology Builder shows our servers expand Lync Server \ SiteName \ Lync Server 2013 \ Mediation pools. Right click the mediation pool that we will route this trunk through and select edit properties. Under Listening ports we need to set TCP to 5060-5060 (see below) and click OK.

Now under Shared Components right click PSTN gateways and choose New IP/PSTN Gateway. Under FQDN put the IP Address of the AsteriskNOW server and click next, again click next on the Define the IP Address screen, now on the define root change the listening port and mediation ports to 5060 and the SIP transport to TCP, and finally click finish. When clicking finish in addition to creating the IP/PSTN Gateway it will also create a SIP trunk under Trunks. Your settings should look similar to below based on your environment.

After creating these components we need to publish our Topology. To do this select Action \ Topology \ Publish and select Next \Finish to complete the Publish.

To configure the Voice Routing in Lync open the Lync Control panel on a Lync Server and go to the “Voice Routing” tab. Under Dial Plan we either need to create a new dial plan or use an existing one. The key here is to create normalization rules under the dial plan to convert our Lync numbers from AsteriskNOW to E.164 format and the AsteriskNOW numbers to just 4 digit extensions. If you use the global dial pan you won’t need to assign this to users but if you create a new “User” dial plan you will. I decided to create new, so click New and then User dial plan. Give it a name and then under Associated Normalization Rules click new and create 2 different translation rules similar to the screenshots below. After you create or edit the Dial plan be sure to click Commit \ Commit All.

Now change over to the Voice policy tab and double click the Global Voice Policy. Under Associated PSTN Usages click new. Give the Usage a name (PSTN Usage – AsteriskNOW) and below Associated Routes select New and again give it a Name (Voice Route - AsteriskNOW Router). In Starting digits for numbers that you want to allow type 3 and click Add. Keep clicking OK until you get back to the Voice Policy main screen and Commit \ Commit All.

Finally lets EV enable some Lync users and test a call. In the Lync Control Panel \ Users \ Click Find. Double click a user you want to EV enable. Under the user properties change telephony to Enterprise Voice, give the user a Line URI in the format tel:+12673655102;ext=5102, select the User Dial plan policy you created earlier (if you edited the Global policy you don’t have to change this), and click Commit. Do this for as many users that are required.

Now to test some calls. From the X-Lite Client (AsteriskNOW extension 3002) let’s call one of our Lync EV enabled users (User1 extension 5102). Success. Now let’s call from Lync to the AsteriskNOW extension 3002. Again Success.

We now have full VoIP connectivity from Asterisk to Lync and back. In the next part of this series we will tie Lync 2013 to Exchange 2013 UM.