Friday, January 13, 2012

Going to MVP Summit

I got accepted into the Microsoft MVP program for Lync a few weeks ago, and have just booked passage to my very first MVP Summit in Seattle the week of February 27 to March 2, 2012.

Since I have to keep up with the Hoff persona, you can expect to find me driving up to the beach in my '80's black Pontiac Trans-Am, stripping down to some red shorts and running down the beach in slow-motion.  My chest hair will keep me warm in Seattle's February climate.

If you're going to be at the summit, I'm sure I'll get the chance to meet you!  See you there.

Friday, January 6, 2012

Lync Edge Server Static Routes

If you're following the Technet articles on how to setup your edge server, you will eventually get to the point where you have to setup your NICs on your edge server.  According to the Set Up Network Interfaces for Edge Servers page:, you should set the default gateway on the external interface, but not the internal. The guide then helpfully tells you to....
Create persistent static routes on the internal interface to all internal networks where clients, Lync Server 2010, and Exchange Unified Messaging (UM) servers reside.
If you're not a Windows networking expert, this might stump you a bit.  Doing some searches might help, but here's a simple way to ensure that all internal networks are covered, even if you aren't aware of exactly which ones are in use.  This can easily happen if you're a consultant doing a Lync deployment for a large, multi-site company.

There are 3 well-known IP subnets that are reserved for internal use.  Any networking person can tell you what they are, and should be using these for their internal corporate network.  If not, then I would recommend running away.  The 3 well-known subnets are, and

I typically add static routes for all 3 subnets even if they aren't all in use.  This will future-proof your deployment  in case the company adds or changes their subnetting scheme.  To add these static routes on the internal interface of your edge server, do the following:
  1. Using the Network Connections interface, make sure your NICs have descriptive names that make sense (Ie. Internal and External)
  2. Open a command prompt in Administrative Mode on the edge server.
  3. Make sure you know what the internal default gateway should be.  In this example, we will use
  4. Type the following commands in the command window:
netsh interface ipv4 add route "Internal"
netsh interface ipv4 add route "Internal"
netsh interface ipv4 add route "Internal"
When you do a netsh interface ipv4 show route, you should see the new routes show up at the bottom of the list.  If you make a mistake, you can delete a route by using the same command above, and replace add with delete.  Now,  your Lync edge server should be able to route to any internal address, both now and in the future.

UPDATE:  Apparently, I'm part Amish, and I was using ROUTE ADD instead of the updated netsh commands shown above.  Thanks to @twharrington on Twitter for pointing out the error to this ol' timer.  I'M DOIN' IT OLD SKOOL!

Tuesday, January 3, 2012

Complete Guide to the Lync Optimizer

UPDATE (21-Aug-2013): Improved UI and additional control options for rule creation. See this post for more information.
UPDATE (09-Jan-2013): Least-cost and failover call routing is now built into the Optimizer.  See this post for information.
UPDATE (05-Dec-2012): Added true customized local dialing rules for the UK.  See this post for information.
UPDATE (31-May-2012): Significant optimizations to North American local rulesets, and fix of normalization rule bug affecting 7-digit dialing rules. See this post for more information.
UPDATE (16-Mar-2012): Now creates separate dialing rules for toll-free and premium calls. Makes it easier to limit dialing to some groups while granting additional dialing rights to others. 

UPDATE (29-Feb-2012): Will allow you to run multiple Optimizer output files against a site to provide localized dialing rules for international users.  See this post for more information.
UPDATE (17-Feb-2012): Program will now create separate dialing rules/usages for mobile networks in non-North American dial plans. Allows for administrators to easily control who is able to dial mobile numbers, which usually cost more than land-lines.

Whenever I've added new features to the Lync Dialing Rule Optimizer, I've created a post outlining the new functionality.  This has led to information being scattered across several different posts and isn't readily available.  I figured it would be best to create a single, all-encompassing post that outlines how to get the most out of the Lync Optimizer.  It will be updated over time as new features are added.

The Lync Optimizer began its life in February 2009 as a locally run VBScript designed to create optimized dialing rules for Dialogic and Audiocodes gateways, as detailed in this post dug up from ancient times (2010).  Its primary purpose was to figure out what phone numbers were local and which were long distance for any given area.  People who knew me would email me the phone number they would want optimized and I would run the program and email the results.  The earliest known versions of this code are now archived in the Smithsonian for future historians.  It has since grown and evolved into the well-oiled Lync-centric online machine it is today.

There are tons of documentation available on how to setup Enterprise Voice in Lync Server 2010/2013, but reading through them all can be daunting and there is not very much guidance on the WHYs as much there is on the HOWs.  The Lync Dialing Rule Optimizer is designed to take care of 95% of the typical setup required to make Enterprise Voice work in Lync Server 2010/2013.  It takes advantage of the knowledge gained from multiple deployments from several Lync professionals on the best way to do things in Lync. All this knowledge is funnelled down into a simple set of options that outputs a Powershell script that takes care of almost all the work for you.

For some more background on Lync Enterprise Voice Best Practices, I encourage you to read through some of my posts on the subject:

Tested Scenarios
The Optimizer has been tested to work with the following topology combinations:
  • Single central site
  • Multiple central sites
  • Multiple central sites with multiple branch sites
  • Single central site with multiple mediation pools
  • Multiple central/branch sites with multiple mediation pools/PSTN gateways
Before You Start
Before you jump in and use the Optimizer, its best to make sure your Lync environment is up to speed.
  1. Make sure that all your user's phone numbers in Active Directory are in E.164 format, as described in my post on E.164 formatting.  
  2. Make sure you have a PSTN gateway defined in your Lync topology for each Lync site you wish to run the Optimizer.
  3. Don't mess around with any of the Enterprise Voice sections at this time.  It will just complicate your life.  If practical, delete any routes/usage/policies you've already defined.
  4. If you do have existing policies/routes etc. back them up by going to Action - Export Configuration under the Voice Routing section of the Lync Control Panel.
Using the Lync Optimizer
  1. Ensure the Lync site you wish to apply the rules have at least one PSTN gateway assigned to it.  If you don't, the script will not run.
  2. Go to  
  3. Pick your country from the drop-down list.

  1. For North American (including Hawaii and Alaska) and Caribbean users, enter the area code and local exchange information for the Lync site you want to apply the script to.  For other countries, pick the city or area where your Lync server resides from the list provided.
North American Area Code Selection

International Area Code Selection (UK example)
  1. To use simplified call routing which uses only a single all-encompassing route for all calls, instead of the default local, national, international etc routing, select the Simple Ruleset checkbox. You'll notice the Rule example will update to show the effect on the ruleset. Keep in mind that least-cost routing is not possible in this configuration. 

  1. To force English language rulenames and descriptions for countries that would normally use the local language, select the Force English Rulenames checkbox. This option only appears on countries where the default language is other than English. Again, you'll see the effects on the Rule example line.

  1. The rule naming convention can be changed if desired.  The country abbreviation prefix and rule type suffix can't be modified to ensure least-cost routing calculations can function normally. Select the Change Rulename Base checkbox and type the new rulename base to use for all rules.
Toronto Rule Name Change Examples
  1. Some countries (Brazil for example) requires a carrier access code to be dialed when dialing long distance phone numbers.  If your country requires a carrier access code (Brazil is the only one in the Optimizer so far), you can enter it here.  The carrier access code will be added to the dialed number after the national/international access code and before the subscriber number.  For example, if you select 19 as the carrier access code, then long-distance numbers will be sent to the PSTN as 019xxxxxxxxx, instead of just 0xxxxxxxxxx.

  1. If you have to enter 9 (or some other digit) to get an outside line, enter it in the External Access # box. This should only apply to connections to an existing PBX.  Don't enter numbers you would normally have to use to make a call from outside the office (ie. 00).

  1. If you want your users to be able to enter an extension to reach someone, select the Use Extensions checkbox. When you select the checkbox, it will show an Edit Extensions button.  Clicking it will bring up the Extension Entry screen.

If none of your users are directly dialable (ie. have to go through a receptionist), then enter the full main phone number and the corresponding extension range.  In the above example, if a user dials 244, it will normalize to +14165551111;ext=244.  This assumes that you've assigned the phone number to the user in the format tel:+14165551111;ext=244.  If you entered it as just 244, this will not work.  See my post on Extensions for more information.

If your extension range maps to an external DID, select the DID checkbox and enter the prefix and extension start/end range.  This will create a normalization rule that will translate typed extensions to the full DID.  As in the above example, if a user dials 3055, the number will be normalized to +14165553055.  Again, this assumes you've assigned the phone number to the user in the format tel:+14165553055.  If you've used the extension only, this will not work.

You can enter up to 10 extension ranges here.  If you need more, please send me a note, and I will see about increasing the limit.  Make sure you press Submit when done, or else it won't save your work.
  1. If you are using a SIP trunk that accepts E.164 phone numbers, select the SIP Trunk Connection option.  If selected, the program will not create trunk translation rules.  All numbers will be sent to the next hop formated as E.164.  It will also set encryption on the trunk to Optional and will disable REFER support, as this is not supported by most SIP providers.  Note: Don't select both an external access number AND SIP trunk options.  The two options are mutually exclusive. 

  1. If you want Lync to block premium rate phone numbers (like 900 in North America) for all users, select the Block Premium Numbers checkbox.  The program will use the Announcement service to let the user know they can't dial those numbers.  This will apply to ALL users in the company, so don't use this option if you want to be more selective.  See the original post for more information.

  1. If you want to use the Call Park feature, select the Enable Call Park option.  When selected, you will be able to enter a range for the call park orbit.  The range must be 2-digits or longer and can include * or # at the beginning.  To ensure the call park orbit doesn't conflict with an existing normalization rule, the program will create a Call Park specific normalization rule to make sure those numbers are not normalized to something else.  Check out the Call Park Deployment Guide for more information on Call Park.

  1. If your North American local dialing area supports 7-digit dialing, select the 7-Digit Normalization checkbox.  If you're unsure if your local dialing area supports 7-digit dialing, leave this blank. Selecting this option when 7-digit dialing isn't available can lead to unpredictable results.  Doesn't apply to other countries other than North America.

  1. To receive updates should the ruleset change, enter your email address.  Only applies to North American users.
  2. After pressing Generate Rules, wait a minute for the rules to be generated.
  3. The program will generate a single .PS1 file.  Save this file onto your desktop.  
  4. Right-click the .PS1 file and click Properties.  Click the Unblock button to allow the script to be run.  Alternatively, run the Powershell command Set-ExecutionPolicy -ExecutionPolicy Unrestricted on your Lync server.

  1. Run the .PS1 file by typing .\Filename.ps1. For the above example, use .\Toronto-ON-416678-Lync.ps1. You will be prompted to select the site to apply the dialing rules.

  1. If there are multiple mediation pools or PSTN gateways in the specified site, the script will prompt you to select one.  
  2. If the Optimizer detects multiple Lync sites, it will ask if you want to apply least-cost/failover routing to the new voice policies.
  3. If the Optimizer detects the presence of Lync network sites, it will ask if you want to enable location-based routing at a site (Lync 2013 only).  See this post for more information.  You will also be prompted to select the network site to apply location-based routing, as well as which class of calls to allow users at that site.
  4. The script will then create all the necessary dial plans, routes, usages etc. to get you going.

After Running the Optimizer Script
  • If you have multiple mediation pools and/or PSTN gateways in the site, you can re-run the script and select the other gateway.  The script will add the gateway to the existing routes.  Calls using that route will round-robin between the gateways.
  • If you want least-cost/failover routing applied to all the sites where you've applied Optimizer-generated scripts, run each of the scripts again, ensuring you select the option to configure least-cost/failover routing.  It will update the voice policy to include the additional PSTN usages.  See this post for more information.
  • If you have users from different countries using a single Enterprise Voice deployment, run the Optimizer for each country and run the resulting script.  It will create user-level dial plans so those users can have localized dialing rules, as described in this post.

Verifying Settings
To verify the settings were applied properly, go to the Voice Routing section of the Lync Control Panel.

Dial Plan Settings
The script creates a site level dial plan for the site you selected in the script.  All users assigned to the Lync servers in that site will have this dial plan automatically applied to them.

Drilling down into the details of the dial plan shows the normalization rules applied to the dial plan.  You'll note the External access prefix has been set in this example.  For more information on what this does, see my post on internal extension dialing.

If you've setup localized dialing rules against a central Lync deployment, there will be user-level dial plans here.  This will allow people homed in different countries to use their local dialing rules, instead of the rules assigned to the central pool.  You will have to manually assign the dial plan to the appropriate users, or use a Powershell script.

The normalization rule for call park is highest in the list (if selected), followed by internal extensions (if selected), then national, international, service and in the specific case of Canada, 310 numbers.

Voice Policy Settings
The script then creates multiple voice policies.  Voice policies are used to assign calling features to groups of users.  A site-level policy is assigned to everyone by default and allows local, national and international calls. Three user-level policies allow varying degrees of calling rights.  The Local policy allows only local calls (excluding mobile phones in non-NA countries), the National policy allows local, mobile and national calling, and the International policy allows all calls, including premium rate calls.

NOTE: If you selected the Simple Ruleset option, then none of this applies, because only a single voice policy that allows all calls is assigned.

The calling rights assigned to each policy is summarized in the table below:

Calling Rights

You can elect to change any policy to allow any combination of dialing abilities. You do this by editing the appropriate policy and adding or removing the appropriate PSTN usage records as shown below.  You can also change the calling features available to users.  You can always create new policies if the default ones don't match your needs.

Each route created are assigned to a PSTN gateway as selected at the beginning of script execution (if there are more than one choice).  If you have multiple PSTN gateways assigned to a mediation pool, you can run the Optimizer script multiple times, selecting a different PSTN gateway each time.  The script will add the gateway to each route.  With multiple PSTN gateways in a route, calls will round-robin between the gateways.

PSTN Usages
Usages are the links between voice policies and routes.  A usage can have multiple routes assigned to it, and can be assigned to multiple voice policies.  This provides a very flexible and easily modified structure for voice rules.  There are 5 usages for each site (6 for non-NA countries):  Local (if local dialing available in selected country), National, International, Mobile (for non-NA countries), Premium and Service.  Each usage has the appropriate routes assigned (ie. the Local usage has routes for local, internal and toll-free numbers). 

Trunk Configuration
The trunk configuration does final outgoing phone number manipulation before sending the call to the PSTN gateway.  Since all phone numbers are coming to the gateway in E.164 format, its simple to strip digits as required.  For instance, local calls strip the national prefix, international calls add the international prefix for the selected location, and so on.
If the SIP Connection option was selected in the Optimizer, there will be no modification of outbound phone numbers.  Everything will be sent to the SIP provider in E.164 format.  Also, REFER support will be turned off, and encryption will be set to Optional.  

Blocked Premium Numbers
If you selected the Block Premium Numbers option, the program will automatically setup the unassigned number range and relevant announcement for your country.  For more details on this feature see my post on blocking premium numbers in Lync.

Call Park
If you selected the Call Park option, the script will create the relevant call park orbit, and also a normalization rule to ensure the number range is never normalized to something else.

Next Steps
If you only have a single Lync site, then your work is pretty much done.  You can enable users for Enterprise Voice and things should work just fine (assuming your PSTN gateway connection is setup properly).

If you have multiple sites, and selected the option to apply least-cost/failover routing, ensure the ordering of the usages meets your requirements.  Change the order as required.

This should give you a good overview on what the Lync Dialing Rule Optimizer does.  As mentioned earlier, this page will be updated as new features are added.  If you have any questions, feel free to drop me a line.

Also, if you find the Lync Optimizer useful, please consider donating using the PayPal link on the bottom of the Optimizer page.  I've invested a significant amount of my own time putting this tool together (and continue to do so), and I do have hosting costs to consider.