Skip to content

Instantly share code, notes, and snippets.

@p0onage
Last active June 30, 2022 10:29
Show Gist options
  • Save p0onage/a36d6356929fc63982b918cd1ac69763 to your computer and use it in GitHub Desktop.
Save p0onage/a36d6356929fc63982b918cd1ac69763 to your computer and use it in GitHub Desktop.
Add Teams Media IP subnets into the route table
$intIndex = "" # index of the interface connected to the internet
$gateway = "" # default gateway of that interface (change this)
# Query the web service for IPs in the Optimize category
$destPrefix = "52.120.0.0/14", "52.112.0.0/14", "13.107.64.0/18" # Teams Media endpoints
# Add routes to the route table
foreach ($prefix in $destPrefix) {New-NetRoute -DestinationPrefix $prefix -InterfaceIndex $intIndex -NextHop $gateway}
@p0onage
Copy link
Author

p0onage commented Apr 19, 2021

Get Parameters

In the above script, $intIndex is the index of the interface connected to the internet (find by running get-netadapter in PowerShell; look for the value of ifIndex) Note: you can add multiple network adapters. I.e when I plug into my docking station I don't use the laptop's network adapter I use the docking station adapter.

$gateway is the default gateway of that interface (find by running ipconfig in a command prompt or (Get-NetIPConfiguration | Foreach IPv4DefaultGateway).NextHop in PowerShell).

You will need to execute the powershell script in administrator mode and you will most likely have to bypass the execution policy. You can run the below command to do this

powershell.exe -ExecutionPolicy Bypass -File .\TeamsRouting.ps1

Testing The Change

Once the script has been executed you can test the path via the local ISP to this endpoint that should resolve to an IP in the Teams ranges we have configured for split tunneling.

Powershell : tracert worldaz.tr.teams.microsoft.com

Full MSDN Documentation

@davebutterworth
Copy link

It's simple to remove them, you can type "route print" to print the routing table
then do 

route -p delete 52.120.0.0/14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment