Trunking From Skype for Business to Shoretel via FreePBX

Recently I was tasked with setting up Dial-in conferencing in Skype for Business using a Shoretel voip system and the PSTN Gateway. Seems simple, until you do some digging and find out that Shoretel 14 doesn’t support SIP over TCP, and S4B doesn’t support SIP over UDP.

I looked at the recommended option from Shoretel, which is a Mediant Session Border Controller to proxy between the two voip systems. I’m sure that would work fine if money was no object, but when the budget for the project is minimal, another option is required. The option I settled on was an open source PBX platform in the form of FreePBX, which is essentially a gui for Asterisk.

After a lot of research, posts with missing information and trial and error I finally got the solution working by following multiple guides for various products connecting to other products until I finally found a configuration that worked. The solution has been in place for roughly a month now and seen a reasonable amount of load while remaining stable. We haven’t had any call quality issues over PSTN either.

I should point out here though that this particular installation wasn’t configured to support enterprise voice and user extensions would still remain in Shoretel. If User Extensions on Skype is your end game, then maybe this solution isn’t for you. Feel free to follow along though.

Disclaimer: Some of the configuration detailed in this post is quite advanced and shouldn’t be attempted on a live system unless you are confident you know what you are doing. I am not responsible for any damage you cause to your own systems. The settings in this post are the settings used in our setup and work for us. The settings required for your setup may differ.

The version numbers of the components used are as follows.

  • Shoretel – 19.42.8801.0
  • FreePBX – 12.0.76.4
  • Skype For Business – 6.0.9319.0

FreePBX Installation

To start with I followed a guide on PowerPBX to get Asterisk installed on Ubuntu Server. I’d recommend doing the same if you don’t already have a FreePBX installation or are as new to FreePBX as I am. Some of the settings later in this post may conflict with settings currently in use if you already have a FreePBX installation that you intend to use.

Shoretel Trunk Setup

Next you need to make sure your Shoretel system is ready to use SIP trunks. This involves allocating switch ports for SIP trunks. To do this, you need to do the following:

  1. Open up Shoreware Director.
  2. Navigate to Platform Hardware > Voice switches > Primary.
  3. Click the name of the switch you want to allocate the SIP Trunks on.
  4. Change one (or more) of the ports to 5 SIP Trunks.
  5. Click Save.

Next you need to configure a Trunk Group on the Shoretel system. To do this you need to navigate to Trunks > Trunk Groups. Select the site that contains your switch with the SIP trunk port(s) configured and select SIP from the Type drop down before clicking Go.

I’ll list the settings used by our setup below. You may need to tweak these for your own deployment.

  • Name – Skype for Business.
  • Enable SIP Info for G.711 DTMF Signalling – Unchecked.
  • Profile – Default Tie Trunk.
  • Digest Authentication – {None}.
  • Username – siptrunkusername (Not my actual username).
  • Password – siptrunkpassword (Not my actual password).
  • Number of Digits from CO – 4.
  • DNIS – Unchecked.
  • DID – Unchecked.
  • Extension – Checked
    • Translation Table – Checked []
    • Prepend Dial In Prefix – Unchecked
    • Use Site Extension Prefix – Unchecked
  • Tandem Trunking – Checked
    • User Group – Skype (This is a custom user group we created to force outbound calls through a certain ISDN trunk group. If you need to change this from the default you will probably know how to create a new user group anyway.)
    • Prepend Dial In Prefix – 9
  • Destination – 1700: Default.
  • Outbound – Checked.
  • Access Code – 9.
  • Local Area Code – 1670 (Yours will be different).
  • Carrier Code – Blank.
  • Billing Telephone Number – Blank.
  • Trunk Services Section
    • Local – Unchecked
    • Long Distance – Unchecked
    • National Mobile – Unchecked
    • International – Unchecked
    • Enable Origin Called Information – Unchecked
    • Caller ID not blocked by default – Checked
    • Enable Caller ID – Checked [Blank]
    • Emergency – Unchecked
  • Trunk Digit Manipulation Section
    • Dial Local Numbers in National Form – Unchecked
    • Dial in E.164 Format – Checked
    • Prepend Dial Out Prefix – Blank
    • Off System Extensions – Click Edit
      • Click New
      • Enter an extension range to be used by Skype. We used a range of 50 extensions to allow for future expansion, one will do usually though. Make sure the range of extensions are not in use else where on your system. They don’t need to have a DDI on a different trunk as we will be using a DNIS map later to route a DDI to the off system extension. We used 8500-8550
      • Click OK
    • Translation Table – {None}
  • Click Save.

Next you will need some individual trunks within the trunk group:

  1. Navigate to Trunks > Individual Trunks.
  2. Select the same site as the Trunk Group you have just created, and then select the Trunk Group from the drop down menu, followed by Go.
  3. Enter a Name for the trunks. Shoretel will increment the name with numbers if there is more than one individual trunk.
  4. Select the switch to use for the SIP trunks. This will be the switch you configured earlier.
  5. Enter the number of individual trunks you want in the group. A trunk is required for each phone call or participant of a conference. Don’t exceed your licensed amount of SIP Trunks unless you know how the licensing on Shoretel works..
  6. Enter the IP address of your Free PBX server.
  7. Click Save.

FreePBX System SIP Configuration

Now for the FreePBX configuration. Providing you followed the guide mentioned earlier, and didn’t have any problems, you should have a working FreePBX server installed and running. You will need to tweak some of the system SIP settings to make this solution work.

  1. Login to FreePBX Administration.
  2. Navigate to Settings > Advanced Settings.
  3. Scroll down to the Dialplan and Operations section.
  4. Set SIP Channel Driver to chan_sip.
  5. Navigate to Settings > Asterisk SIP Settings.
  6. Set Allow Anonymous Inbound SIP Calls to Yes.
  7. Enter your internal networks. For Example 192.168.1.0 / 24.
  8. Click Submit (bottom) followed by Apply Config.
  9. Click Chan SIP at the top right of the page.
  10. Set NAT to no.
  11. Set IP Configuration to Static IP.
  12. Set Override External IP to the IP address of your FreePBX server.
  13. Scroll down to Other SIP Settings and click Add Field once. In the two sets of fields add the following:
    • tcpenable = yes
    • tlsenable = yes
  14. Click Submit Changes followed by Apply Config.
  15. Reboot the FreePBX server.

FreePBX Trunk Configuration (Shoretel)

Once the server has rebooted ensure you can log back in to FreePBX and that you have no errors displayed on the home page. If everything is OK, then it is time to create the Trunks on the FreePBX end.

  1. Navigate to Connectivity > Trunks.
  2. Click Add SIP (chan_sip) Trunk.
  3. Enter a name for the Trunk. Ours is simply Shoretel.
  4. Set Maximum Channel to the number of individual trunks you created in Shoretel earlier.
  5. In the top Dialed Number Manipulation Rules row add a dot (.) in the match pattern field.
  6. In the Outgoing Settings section specify the Trunk Name Again.
  7. In the PEER Details section you need to add the following information, substituting anything in () for your details setup earlier. I’d recommend pasting the text into notepad to edit it.

    type=friend
    secret=(siptrunkpassword)
    host=(shoretelswitchIP)
    disallow=all
    allow=ulaw
    dtmfmode=rfc2833
    username=(siptrunkusername)
    insecure=very

  8. Click Submit Changes followed by Apply Config.

Now, hopefully, if you navigate back to Reports > System Status you should see the graph line for Trunk Reg has increased to 1 from 0.

FreePBX Trunk Configuration (Skype)

Next you need to create the trunk in FreePBX that connect to Skype for Business. The steps are similar to the steps for the Shoretel trunk with a few tweaked settings.

  1. Navigate to Connectivity > Trunks.
  2. Click Add SIP (chan_sip) Trunk.
  3. Enter a name for the Trunk. Ours is simply Skype.
  4. In the top Dialed Number Manipulation Rules row add a pattern that matches your Off-System Extension range added in Shoretel earlier in the match pattern field. Ours is set to 85XX which will match any four digit extension starting with 85.
  5. In the Outgoing Settings section specify the Trunk Name Again.
  6. In the PEER Details section you need to add the following information, substituting anything in () for your details setup earlier. I’d recommend pasting the text into notepad to edit it.

    type=friend
    tcpenable=yes
    transport=tcp
    qualify=yes
    promiscredir=yes
    port=5060
    insecure=very
    host=(skypepoolhostname)
    canreinvite=yes
    context=trunk_in

  7. Click Submit Changes followed by Apply Config.

Skype PSTN Gateway Configuration

Now you will need to make a topology change to your Skype for Business installation. You probably have some form of change control in place for these kind of changes so go and grab the required signatures and head back here.

Open up Skype Topology Builder and load your current topology ready to edit it. I won’t go into detail on how to do this here as any Skype Admin should know how to do it. Once open, you need to tweak the settings of your Mediation Pool in order to support this type of configuration. Heres how:

  1. Expand Skype For Business > Site Name > Skype for Business Server 2015 > Mediation Pools.
  2. Right-Click the mediation pool you want to use and click Edit Properties.
  3. Ensure Enable TCP Port is Checked.
  4. Set TLS: to 5067 – 5067.
  5. Set TCP: to 5060 – 5060.
  6. Click OK.

Next you need to add the PSTN Gateway to your Skype topology. Follow the steps below to add the PSTN Gateway:

  1. Expand Skype For Business > Site Name > Shared Components and select PSTN Gateways.
  2. Right-Click the Container and select New IP/PSTN Gateway.
  3. For FQDN enter the IP address of your FreePBX server, then click Next.
  4. Click Next unless you need to change any settings for your environment.
  5. Set Trunk Name to FreePBX.
  6. Set Listening Port to 5067.
  7. Set SIP Transport Protocol to TLS.
  8. Select the Skype pool you want to associate as the Mediate Server.
  9. Set Associated Mediation Server Port to 5067.
  10. Click Finish.

Next it’s time to create a trunk in Skype:

  1. Expand Skype For Business > Site Name > Shared Components and select Trunks.
  2. Right-Click the Container and select New Trunk.
  3. Enter a Trunk Name.
  4. Select your PSTN Gateway from the drop down menu.
  5. Set Listening port for IP/PSTN gateway to 5061.
  6. Set SIP Transport Protocol to TCP.
  7. Select your Associated Mediation Server to the pool you want to use.
  8. Set Associated Mediation Server port to 5060.
  9. click OK.

Now you need to publish your topology in order to make the changes. I’ll leave that part up to you again incase you cause undesirable downtime or break something.

In theory, your trunks should come up shortly after the topology is published. You can check this from the home page of the FreePBX administration portal by checking the graph line for Trunk Rag has increased from 1 to 2.

Coffee Break

You’re probably getting bored with this post by now so I’d recommend a nice strong cup of coffee. I know I’m heading to grab one now while I’m typing it! I might even watch an episode of The Grand Tour while I drink it…

Skype Configuration

For the next part of the configuration you will need access to the Skype For Business Admin portal. Specifically the Voice Routing and Conferencing sections.

All of the steps in this section were performed on a Skype installation with no previous voice configuration. If your system already uses voice features I’d recommend leaving this bit to somebody that knows what they are doing if you don’t already.

First of all you need to create a Voice Policy:

  1. Navigate to Voice Routing > Voice Policy.
  2. Double click Global.
  3. Check all check boxes in the Calling Features section.
  4. Under Associated PSTN Usages section click New.
  5. Set Name to Shoretel and click OK.
  6. Set Call forwarding and simultaneous ringing PSTN usages to Route using the call PSTN Usages.
  7. Click OK.

Next comes a Route. Navigate to Voice Routing > Route. If you already have routes listed then I suggest you stop following this post and consult the person responsible for voice routing in Skype if you don’t understand how it works. If you don’t have any routes, go ahead and follow these steps:

  1. Click New.
  2. Type a Name of your choice. We chose Shoretel.
  3. Type .* (DotAsterisk) into the Match this pattern field.
  4. In the Associated trunks section click Add…
  5. In the Associated PSTN Usages section click Select…
  6. Click Shoretel Followed by OK.
  7. Click OK.
  8. Click Commit > Commit All.

Now comes some Trunk Configuration:

  1. Navigate to Voice Routing > Trunk Configuration.
  2. Double click Global.
  3. Ensure Encryption support level is set to Optional.
  4. In the Associated PSTN Usages section click select…
  5. Click Shoretel and click OK.
  6. Click OK.
  7. Click Commit > Commit all.

Time for the Dial Plan:

  1. Navigate to Voice Routing > Dial Plan.
  2. Double click Global.
  3. Specify a Dial-In Conferencing Region. We chose UK since that is where we are.
  4. Chose an External access prefix if you desire. We went with 9.
  5. In the Associated Normalization Rules section click new.
  6. Specify a Name of your choice.
  7. In the Build a Normalization Rule section input the following settings (you will need to click the edit button to modify the final two settings)
    • Starting digits – Blank
    • Length – At least 1
    • Digits to remove – 0
    • Digits to add – Blank
    • Pattern to match – ^(\d+)$
    • Translation Rule – $1
  8. Uncheck Internal extension.
  9. Click OK.
  10. Remove any other normalization rules.
  11. Click OK.
  12. Now click Commit > Commit all.

Skype Dial-In Access Number

While you are still in Skype you may as well configure the dial-in conferencing number. It won’t work yet but by doing so you will at least get some audible feedback to use to test your configuration while you complete the FreePBX and Shoretel routing later.

  1. Navigate to Conferencing > Dial-In Access Number.
  2. Click New.
  3. Enter the Display number as a the DDI you plan to use for your dial-in conferencing number for external parties. e.g. +441618444444.
  4. Add a Display name of your choice.
  5. in Line URI add tel:#### to represent the extension you want to use. In our case it reads tel:8500.
  6. In SIP URI add the sip address you want to assign. we went with sip:conferencing @ sipdomain.com.
  7. Select your Pool.
  8. Select the Primary Language for this particular number.
  9. In the Associated Regions section click Add…
  10. Select the region created in the dial plan and click OK.
  11. Click Commit.

Don’t forget your users will need to be allowed to use Dial-In conferencing in the conferencing policy applied to them.

FreePBX Routes

Now you need to head on over to the FreePBX admin portal again to create some routes. This is another part that caused a lot of confusion when I was initially trying to get this to work thanks to some other guides not being accurate. Again the settings here may differ slightly depending on your setup.

The easiest way I found to route all calls through the Shoretel trunk unless they were specifically for an extension I knew existed in Skype. First of all I created the Incoming route to catch the calls for Skype.

  1. Navigate to Connectivity > Inbound Routes.
  2. Click Add Incoming Route in the top right of the page.
  3. Populate the settings below. Any I miss assume they are left as default:
    • Description – ShortelIn8500
    • DID Number – 8500
    • Set Destination – [Trunks][Skype (sip)]
  4. Click Submit.

Then I created an Incoming Route for anything else:

  1. Navigate to Connectivity > Inbound Routes.
  2. Click Add Incoming Route in the top right of the page.
  3. Populate the settings below. Any I miss assume they are left as default:
    • Description – SkypeIn
    • Set Destination – [Trunks][Shoretel (sip)]
  4. Click Submit and then Apply Config.

Testing

Now in theory internal users should now be able to dial the extension assigned to Skype PSTN Conferencing and hear the auto attendant saying “Welcome to the audio conferencing center.”

You should also be able to start a Skype Meeting using the meet now feature in Skype and add a recipient by typing in their extension or telephone number and hitting enter.

Assigning a DDI

Since Shoretel allows you to add other internal people to a call anyway this solution won’t be much use unless you map a DDI to the extension setup for Skype. I did this using a DNIS mapping on the ISDN trunk that the DDI belongs to. To do this follow these steps:

  1. Login to Shoreware Director.
  2. Navigate to Trunks > Trunk Groups.
  3. Select the trunk group that carries the DDI you wish to use. This was one of our ISDN groups.
  4. Click Edit DNIS Map.
  5. In the Received Digits field, enter the DDI in local format, ie excluding the country code and area code.
  6. In the next field add a name for the map. We went with Skype conferencing.
  7. Next select the Off System radio button and select the range you created in your SIP Trunk Group Extensions earlier.
  8. In the next field type the extension number used by Skype. 8500 in our case.
  9. Leave the Music on Hold as default.
  10. Click Add this record to the left of the row you have just filled in.
  11. Click Save.
  12. click Save again.

At this point you should be able to dial the DDI you have just configured from a mobile phone and hear the same audio prompt from the Skype auto attendant.

Conclusion

No doubt this post was a little tedious to follow. Unfortunately there isn’t a technique I’m aware of to make SIP an interesting subject. I do hope it might have helped somebody though at the end of the day. Or prevented any premature hair loss.

One thought on “Trunking From Skype for Business to Shoretel via FreePBX”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.