다음을 통해 공유


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 (https://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.

Comments

  • Anonymous
    January 01, 2003
    @Fabrice - yes you can put any number you want. Be sure to change the voice policy and outbound route from Asterisk

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Great Tutorail! Thanks!

  • Anonymous
    January 01, 2003
    @Paul - Just posted :)

  • Anonymous
    January 01, 2003
    Can't wait for the Pt. 3!

  • Anonymous
    September 14, 2013
    Great Tutorial!.. congratulations!.. all work fine here with my implementation (follow your 2 parts) and waiting the 3rd part! again... great work..   thanks Daniel R.

  • Anonymous
    October 01, 2013
    Great tutorial - any idea when part 3 is out? This has solved so many integration issues we were having - thank you! p

  • Anonymous
    November 02, 2013
    The comment has been removed

  • Anonymous
    January 15, 2014
    In Part 1 and Part 2 of this series we configured AsteriskNOW PBX and connected it to our Lync 2013 environment

  • Anonymous
    January 18, 2014
    HelloI followed all but the part 2 did not work

  • Anonymous
    January 18, 2014
    The comment has been removed

  • Anonymous
    January 30, 2014
    It didn't work for me

  • Anonymous
    February 27, 2014
    The comment has been removed

  • Anonymous
    February 28, 2014
    Fixed.

    Need to added the PSTN Gateway into the Associated Trunks for the Voice Route.

  • Anonymous
    March 05, 2014
    Call from X-Lite to Lync not succeeded (Failed to dial) can anyone help :(

  • Anonymous
    March 20, 2014
    This is brillant. How do i connect to call PSTN number. This is all connected internal. Thanks once again very detailed solution.

  • Anonymous
    July 02, 2014
    The comment has been removed

  • Anonymous
    November 28, 2014
    The comment has been removed

  • Anonymous
    January 08, 2015
    Just set this up in my lab. Excellent walkthrough, thanks very much. The one issue I did run into was Asterisk rejecting calls from Lync which was easy to see in the Asterisk logs. I had to go into Settings > Asterisk SIP Settings and allow Anonymous SIP Calls. I don't see this being required in your guide though, so did I miss something? I would expect that creating the SIP Trunk would no longer make this an anonymous connection.

  • Anonymous
    January 08, 2015
    Also in case anyone doesn't have the Asterisk VM connected to the internet. You will receive Fatal Errors when trying to create the Extensions until you connect the VM to the internet and re-run the first boot command via the console (/etc/pbx_first_boot.sh).

  • Anonymous
    January 15, 2015
    You know, I've been struggeling with trying to interconnect Asterisk (which has the connection towards the SIP provider) and Lync 2013 a couple of days now without getting it to work (Lync consistently rejected the invite from Asterisk with 400 bad request, assuming now it has something to do with the normalization rules). This howto covered everything straight forward from top to bottoms! Your over 1 year old post has definitely saved my (...girlfriends.....) weekend! Thanks a lot for an excellent guide!

  • Anonymous
    February 02, 2015
    The comment has been removed

  • Anonymous
    March 30, 2015
    Hi, two strings is not enough, my asterisk didn't want to listen tcp port,
    add the third string: tcpbindaddr: 0.0.0.0

    sip_custom.conf
    tcpenable=yes
    tcpbindaddr=0.0.0.0
    transport=tcp,udp

    Pls pay attention, i am not sure, but some people told, that tcp should be before udp.

  • Anonymous
    July 29, 2015
    @James. You can manipulate the caller ID string which is passed to XLite on the Asterisk server within the dialplan. As I recall you do this by creating a custom context.

    @anyone. Getting this sort of integration working with O365 would be something.

  • Anonymous
    September 24, 2015
    @Tim, if you want to integrate it with O365, they only approach I known so far is Simplync
    It allows you to directly register lync client with on-house Lync Servers, or with Lync Online, without the need of gateways... Take a look athttp://www.simplync.net

  • Anonymous
    March 02, 2016
    We currently have this set up and running where I can call an asterisk phone and vice versa. I was wondering if it was possible to configure the following scenario

    when a external pstn call is made from astericks, have lync reroute that call out a different pstn gateway?
    right now, when we attempt to make an external call, it goes to lync and fails as it is looking for a user with that phone number in lync.

  • Anonymous
    March 02, 2016
    hhhh

  • Anonymous
    March 02, 2016
    ">