In our Lync lab, we are always running into scenarios where we would like to test various functionality against known VOIP providers and equipment. This usually results in an increased levels of frustration as Lync does not play well in the land of UDP SIP. Enter FreeSWITCH.
Over the past two years, we have cooked up several FreeSWITCH configurations which support:
- UDP to TCP bridging which allows Lync to work with VOIP providers such as FlowRoute and PBXs such as 3CX.
- Full NAT support for those times when you just have to be behind a firewall.
- Much better support for direct inbound (private) phone numbers into a Lync system using extensions.
- Support for non-Lync conference phones such as the Polycom IP 6000.
- Support for Lync 2010 as well as Lync 2013!
Disclaimer
The configurations documented in this article are non-standard and, as such, are not supported by any of the vendors referenced within. These configurations are designed in, and for a test environment. Utilizing these configurations in a production environment will be undertaken at your own risk.
(OK, with that out of the way, on to the configurations)
IMPORTANT: It is recommend you read and understand this entire blog entry before making configuration changes… it’ll make your life much easier.
Article Assumptions about Lync Versions
Lync 2010, 2013, Enterprise, and standard, oh my!
For brevity, this article was written using screen shots of a Lync 2013 Standard Edition install. Most configuration instructions will directly apply to Enterprise Editions as well as Lync 2010 with some minor tweaking.
Prerequisites
- A functioning install of Lync front end server
- A DNS entry pointing to the location running FreeSWITCH
NOTE: In this article, the DNS entry is FREESWITCH.MYCOMPANY.COM
- Coffee or your caffeine of choice.
Configuring Lync Topology
- Launch Lync Server Topology Builder and load the current topology.
- Drill down to Mediation pools and highlight the mediation pool which will service outbound calls.
- Check the Enable TCP port and verify the TCP port range is set to 5068 – 5068

- Close the dialog
- Drill down to Shared Components –> PSTN gateways
- Right click on PSTN gateways and select New IP/PSTN Gateway from the menu

- At Define the PSTN Gateway FQDN, enter your FreeSWITCH DNS entry
our example is FREESWITCH.MYCOMPANY.COM

- At Define the IP address, take the defaults
- At Define the root trunk, make the following changes:
Set the SIP Transport Protocol to TCP
Set the Listening port for IP/PSTN gateway to 5060
Set the Associated Mediation Server port to 5068 (it should already be set, but check it)
- Publish your topology
Configure Lync Voice Routing
- Launch the Lync configuration web page and select Voice Routing

- Click Trunk Configuration, double click the Global record

- Set the following details for the trunk configuration
Encryption support level to Not Supported
Refer support to None
Uncheck Enable media bypass
Check Centralized media processing
Uncheck all others.

- Click OK to save the trunk configuration
- Create PSTN routes to your preferences
See http://technet.microsoft.com/en-us/library/gg399027.aspx for complete details
Configure FreeSWITCH
- Install FreeSWITCH using the Complete / Full option
IMPORTANT: Be sure to install FreeSWITCH on the server pointed to by your DNS entry!
- Locate the \conf directory under the FreeSWITCH install and delete ALL the files
- Download the FreeSWITCH XML configuration file
Configuration file (.ZIP’d) is available at http://blog.armgasys.com/wp-content/uploads/2013/05/FreeSWITCH-with-Lync-Configuration.zip
- Modify the FreeSWITCH configuration file to meet your needs and copy it into the \conf directory
See FreeSWITCH Configuration XML below for more details
- Locate the FreeSWITCH Multi Protocol Switch service and set the service to Startup type of Automatic
FreeSWITCH Configuration XML
Include Section
- published-name=SIPGateway
This defines the name FreeSWITCH will respond with during SIP communication.
Can be set to any value you desire
- inbound-sip-port=6000
The inbound SIP port used by external VOIP traffic.
Make sure you configure you VOIP provider to communicate with FreeSWITCH using this port.
- outbound-sip-port=5060
The port used by your internal Lync and VOIP devices.
- codec-prefs
The default codec preferences for FreeSWITCH
- internal-ip
The internal IP for your FreeSWITCH server.
Under a NAT/Firewall scenario, this will usually be a non-routable IP such at 169.1.1.1
- external-ip
The external IP address exposed outside your firewall
Inbound Gateway Profile
See <profile name=”Inbound”>
- username=none
Lync does not support user name registration. Leave as none
- password=none
Lync does not support user name registration. Leave as none
- proxy
Set to the IP address and port of your Lync server. I.E. 169.1.1.1:5068
Outbound Gateway Profile
See <profile name=”Inbound”>
- username=none
Username provided by your VOIP provider
- password=none
Password provided by your VOIP provider
- proxy
IP or URL of your VOIP provider
- register=true/false
Set according to your VOIP providers configuration.
Dial Plans
See the .XML file for example inbound and outbound routing.
NOTE: All examples assume Lync is configured with three digit extensions
FreeSWITCH, Lync 2013 and AppFabric
Astute observers will have noticed the inbound (outside your firewall) SIP Port is set to 6000 in the FreeSWITCH configuration file. This is not by accident. Lync 2013 uses AppFabric under the hood. As of this writing of this article, AppFabric will attempt to use several ports between 5060 and 5080. If FreeSWITCH starts BEFORE Lync, the Lync Server Front-End service will fail to start. There are two solutions:
Solution #1: Make sure nothing other than Lync’s own services use ports between 5060 and 5080.
This is the solution we selected as it is quick and easy.
Solution #2: Make sure FreeSwitch starts AFTER Lync Server Front-End service has started.
Happy calling!