Enable Location-Based Routing for Direct Routing
Before you follow the steps in this article, make sure you've read Plan Location-Based Routing for Direct Routing and completed the steps in Configure network settings for Location-Based Routing.
This article describes how to enable Location-Based Routing for Direct Routing. After you deploy Phone System Direct Routing and set up network regions, sites, and subnets, you're ready to enable Location-Based Routing. To complete the steps in this article, you'll need some familiarity with PowerShell cmdlets. To learn more, see Teams PowerShell Overview.
You have to enable Location-Based Routing for the following:
- Users
- Network sites
- Gateway configurations
- Calling policies
You can use the Microsoft Teams admin center or PowerShell to enable Location-Based Routing.
Using the Microsoft Teams admin center
Enable Location-Based Routing for users
Create a voice routing policy and assign PSTN usages to the policy. When you assign PSTN usages to a policy, make sure you do one of the following:
- Use PSTN usages associated to voice routes that use a PSTN gateway local to the site.
- Use PSTN usages associated to voice routes that use a PSTN gateway located in a region where Location-Based Routing restrictions aren't needed.
Assign the voice routing policy to users who require routing restrictions to be enforced.
To learn more about how to create voice routing policies and assign them to users, see Manage voice routing policies in Microsoft Teams.
Enable Location-Based Routing for network sites
Enable Location-Based Routing for your sites that need to enforce routing restrictions. To do this, in the left navigation of the Microsoft Teams admin center, go to Locations > Network topology, select a network site, click Edit, and then turn on Location based routing.
To learn more, see Manage your network topology.
Enable Location-Based Routing for gateways
Enable Location-Based Routing to gateways that route calls to PSTN gateways that route calls to the PSTN, and associate the network site where the gateway is located.
- In the left navigation, go to Voice > Direct Routing, and then click the SBCs tab.
- Select the SBC, and then click Edit.
- Under Location based routing and media optimization, turn on Enable location based routing.
- Specify the gateway site ID, and then set the bypass mode.
- Click Save.
Enable Location-Based Routing for calling policies
To enforce Location-Based Routing for specific users, set up the user's calling policy to prevent PSTN toll bypass. To do this, turn on the Prevent toll bypass setting in the calling policy.
To learn more, see Calling policies in Teams.
Using PowerShell
Enable Location-Based Routing for users
Use the Set-CsOnlinePstnUsage cmdlet to set PSTN usages. For multiple usages, separate each usage with a comma.
Set-CsOnlinePstnUsage -Usage <usages>For example:
Set-CsOnlinePstnUsage -Usage "Long Distance", "Local", "Internal"Use the New-CsOnlineVoiceRoutingPolicy cmdlet to create a voice routing policy to associate the user with the appropriate PSTN usages.
New-CsOnlineVoiceRoutingPolicy -Identity <voice routing policy ID> -Description <voice routing policy name> -OnlinePstnUsages <usages>When you assign PSTN usages to a voice routing policy, make sure you do one of the following:
- Use PSTN usages associated to voice routes that use a PSTN gateway local to the site
- Use PSTN usages associated to voice routes that use a PSTN gateway located in a region where Location-Based Routing restrictions aren't needed.
In this example, we create two new voice routing policies and assign PSTN usages to them.
New-CsOnlineVoiceRoutingPolicy -Identity "DelhiVoiceRoutingPolicy" -Description "Delhi voice routing policy" -OnlinePstnUsages "Long Distance" New-CsOnlineVoiceRoutingPolicy -Identity "HyderabadVoiceRoutingPolicy" -Description " Hyderabad voice routing policy" -OnlinePstnUsages "Long Distance", "Local", "Internal"The following table shows the voice routing policies defined in this example.
Voice routing policy 1 Voice routing policy 2 Online voice policy ID Delhi online voice routing policy Hyderabad online voice routing policy Online PSTN usages Long Distance Long Distance, Local, Internal Use the Grant-CsOnlineVoiceRoutingPolicy cmdlet to associate online voice routing policies to users who require routing restrictions to be enforced.
Grant-CsOnlineVoiceRoutingPolicy -Identity <User> -Tenant <TenantId>
Enable Location-Based Routing for network sites
Use the Set-CsTenantNetworkSite cmdlet to enable Location-Based Routing and associate voice routing policies to your network sites that need to enforce routing restrictions.
Set-CsTenantNetworkSite -Identity <site ID> -EnableLocationBasedRouting <$true|$false>In this example, we enable Location-Based Routing for the Delhi site and the Hyderabad site.
Set-CsTenantNetworkSite -Identity "Delhi" -EnableLocationBasedRouting $true Set-CsTenantNetworkSite -Identity "Hyderabad" -EnableLocationBasedRouting $trueThe following table shows the sites enabled for Location-Based Routing in this example.
Site 1 (Delhi) Site 2 (Hyderabad) Site name Site 1 (Delhi) Site 2 (Hyderabad) EnableLocationBasedRouting True True Subnets Subnet 1 (Delhi) Subnet 2 (Hyderabad)
Enable Location-Based Routing for gateways
Use the New-CsOnlinePSTNGateway cmdlet to create a gateway configuration for each gateway or network site.
New-CSOnlinePSTNGateway -Fqdn <FDQN registered for the SBC> -Identity <gateway configuration ID> -SipSignalingPort <listening port used> -Enabled $trueIf multiple gateways are associated with a system (for example, Gateway or PBX), modify each gateway to enable Location-Based Routing restrictions.
In this example, we create one gateway configuration for each gateway.
New-CsOnlinePSTNGateway -Fqdn sbc.contoso.com -Enabled $true -SipSignalingPort 5067For more information, see Configure Direct Routing.
Use the Set-CSOnlinePSTNGateway cmdlet to enable Location-Based Routing for your gateways that need to enforce routing restrictions.
Enable Location-Based Routing to gateways that route calls to PSTN gateways that route calls to the PSTN, and associate the network site where the gateway is located.
Set-CSOnlinePSTNGateway -Identity <gateway configuration ID> -GatewaySiteLbrEnabled $true -GatewaySiteID <site ID>In this example, we enable Location-Based Routing for each gateway that's associated to PSTN gateways in the Delhi and Hyderabad sites.
Set-CSOnlinePSTNGateway -Identity sbc.contoso.com -GatewaySiteLbrEnabled $true –GatewaySiteID "Delhi" Set-CSOnlinePSTNGateway -Identity sbc1.contoso.com -GatewaySiteLbrEnabled $true -GatewaySiteID "Hyderabad"Don't enable Location-Based Routing for gateways that don't route calls to the PSTN. However, you still have to associate the gateway to the network site where the system is located. This is because Location-Based Routing restrictions need to be enforced for PSTN calls reaching endpoints that are connected via this gateway. In this example, Location-Based Routing isn't enabled for each gateway that's associated to PBX systems in the Delhi and Hyderabad sites.
Get-CSONlinePSTNGateway -Identity sbc.contoso.com Identity: sbc.contoso.com GatewaySiteLbrEnabled: $false Get-CSONlinePSTNGateway -Identity sbc2.contoso.com Identity: sbc2.contoso.com GatewaySiteLbrEnabled: $false
Enable Location-Based Routing for calling policies
To enforce Location-Based Routing for specific users, set up the users' voice policy to prevent PTSN toll bypass.
Use the Grant-CsTeamsCallingPolicy cmdlet to enable Location-Based routing by preventing PSTN toll bypass.
Grant-CsTeamsCallingPolicy -PolicyName <policy name> -id <user id>
In this example, we prevent PSTN toll bypass to User1's calling policies.
Grant-CsTeamsCallingPolicy –PolicyName "AllowCallingPreventTollBypass" -id "User1"

