Meta

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:

Open up Shoreware Director.

Navigate to Platform Hardware > Voice switches > Primary.

Click the name of the switch you want to allocate the SIP Trunks on.

Change one (or more) of the ports to 5 SIP Trunks.

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:

Navigate to Trunks > Individual Trunks.

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.

Enter a Name for the trunks. Shoretel will increment the name with numbers if there is more than one individual trunk.

Select the switch to use for the SIP trunks. This will be the switch you configured earlier.

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..

Enter the IP address of your Free PBX server.

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.

Login to FreePBX Administration.

Navigate to Settings > Advanced Settings.

Scroll down to the Dialplan and Operations section.

Set SIP Channel Driver to chan_sip.

Navigate to Settings > Asterisk SIP Settings.

Set Allow Anonymous Inbound SIP Calls to Yes.

Enter your internal networks. For Example 192.168.1.0 / 24.

Click Submit (bottom) followed by Apply Config.

Click Chan SIP at the top right of the page.

Set NAT to no.

Set IP Configuration to Static IP.

Set Override External IP to the IP address of your FreePBX server.

Scroll down to Other SIP Settings and click Add Field once. In the two sets of fields add the following:

tcpenable = yes

tlsenable = yes

Click Submit Changes followed by Apply Config.

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.

Navigate to Connectivity > Trunks.

Click Add SIP (chan_sip) Trunk.

Enter a name for the Trunk. Ours is simply Shoretel.

Set Maximum Channel to the number of individual trunks you created in Shoretel earlier.

In the top Dialed Number Manipulation Rules row add a dot (.) in the match pattern field.

In the Outgoing Settings section specify the Trunk Name Again.

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.

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.

Navigate to Connectivity > Trunks.

Click Add SIP (chan_sip) Trunk.

Enter a name for the Trunk. Ours is simply Skype.

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.

In the Outgoing Settings section specify the Trunk Name Again.

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.

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:

Expand Skype For Business > Site Name > Skype for Business Server 2015 > Mediation Pools.

Right-Click the mediation pool you want to use and click Edit Properties.

Ensure Enable TCP Port is Checked.

Set TLS: to 5067 – 5067.

Set TCP: to 5060 – 5060.

Click OK.

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

Expand Skype For Business > Site Name > Shared Components and select PSTN Gateways.

Right-Click the Container and select New IP/PSTN Gateway.

For FQDN enter the IP address of your FreePBX server, then click Next.

Click Next unless you need to change any settings for your environment.

Set Trunk Name to FreePBX.

Set Listening Port to 5067.

Set SIP Transport Protocol to TLS.

Select the Skype pool you want to associate as the Mediate Server.

Set Associated Mediation Server Port to 5067.

Click Finish.

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

Expand Skype For Business > Site Name > Shared Components and select Trunks.

Right-Click the Container and select New Trunk.

Enter a Trunk Name.

Select your PSTN Gateway from the drop down menu.

Set Listening port for IP/PSTN gateway to 5061.

Set SIP Transport Protocol to TCP.

Select your Associated Mediation Server to the pool you want to use.

Set Associated Mediation Server port to 5060.

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:

Navigate to Voice Routing > Voice Policy.

Double click Global.

Check all check boxes in the Calling Features section.

Under Associated PSTN Usages section click New.

Set Name to Shoretel and click OK.

Set Call forwarding and simultaneous ringing PSTN usages to Route using the call PSTN Usages.

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:

Click New.

Type a Name of your choice. We chose Shoretel.

Type .* (DotAsterisk) into the Match this pattern field.

In the Associated trunks section click Add…

In the Associated PSTN Usages section click Select…

Click Shoretel Followed by OK.

Click OK.

Click Commit > Commit All.

Now comes some Trunk Configuration:

Navigate to Voice Routing > Trunk Configuration.

Double click Global.

Ensure Encryption support level is set to Optional.

In the Associated PSTN Usages section click select…

Click Shoretel and click OK.

Click OK.

Click Commit > Commit all.

Time for the Dial Plan:

Navigate to Voice Routing > Dial Plan.

Double click Global.

Specify a Dial-In Conferencing Region. We chose UK since that is where we are.

Chose an External access prefix if you desire. We went with 9.

In the Associated Normalization Rules section click new.

Specify a Name of your choice.

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

Uncheck Internal extension.

Click OK.

Remove any other normalization rules.

Click OK.

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.

Navigate to Conferencing > Dial-In Access Number.

Click New.

Enter the Display number as a the DDI you plan to use for your dial-in conferencing number for external parties. e.g. +441618444444.

Add a Display name of your choice.

in Line URI add tel:#### to represent the extension you want to use. In our case it reads tel:8500.

In SIP URI add the sip address you want to assign. we went with sip:conferencing @ sipdomain.com.

Select your Pool.

Select the Primary Language for this particular number.

In the Associated Regions section click Add…

Select the region created in the dial plan and click OK.

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.

Navigate to Connectivity > Inbound Routes.

Click Add Incoming Route in the top right of the page.

Populate the settings below. Any I miss assume they are left as default:

Description – ShortelIn8500

DID Number – 8500

Set Destination – [Trunks][Skype (sip)]

Click Submit.

Then I created an Incoming Route for anything else:

Navigate to Connectivity > Inbound Routes.

Click Add Incoming Route in the top right of the page.

Populate the settings below. Any I miss assume they are left as default:

Description – SkypeIn

Set Destination – [Trunks][Shoretel (sip)]

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:

Login to Shoreware Director.

Navigate to Trunks > Trunk Groups.

Select the trunk group that carries the DDI you wish to use. This was one of our ISDN groups.

Click Edit DNIS Map.

In the Received Digits field, enter the DDI in local format, ie excluding the country code and area code.

In the next field add a name for the map. We went with Skype conferencing.

Next select the Off System radio button and select the range you created in your SIP Trunk Group Extensions earlier.

In the next field type the extension number used by Skype. 8500 in our case.

Leave the Music on Hold as default.

Click Add this record to the left of the row you have just filled in.

Click Save.

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.