Skip to content

Instantly share code, notes, and snippets.

@giovannicandido
Created December 24, 2018 19:18
Show Gist options
  • Save giovannicandido/a940727de576578c642fdb0f2fe957b0 to your computer and use it in GitHub Desktop.
Save giovannicandido/a940727de576578c642fdb0f2fe957b0 to your computer and use it in GitHub Desktop.
Change default network on windows to bypass proxy in cable company
param (
[Parameter(Mandatory=$true)]
[boolean]$wifiPrimary
)
# Get-NetIPInterface
$wifiIndex = 12
$cableIndex = 10
$primaryMetric = 10
$secondaryMetric = 35
if($wifiPrimary) {
Write-Host "Setup wifi as primary network"
Set-NetIPInterface -InterfaceIndex $wifiIndex -InterfaceMetric $primaryMetric
Set-NetIPInterface -InterfaceIndex $cableIndex -InterfaceMetric $secondaryMetric
New-NetRoute -DestinationPrefix "172.19.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.21.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.22.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.23.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.24.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.25.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.26.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.27.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.29.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.30.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.31.0.0/16" -InterfaceIndex $cableIndex
New-NetRoute -DestinationPrefix "172.32.0.0/16" -InterfaceIndex $cableIndex
}else {
Write-Host "Setup cable as primary network"
Set-NetIPInterface -InterfaceIndex $cableIndex -InterfaceMetric $primaryMetric
Set-NetIPInterface -InterfaceIndex $wifiIndex -InterfaceMetric $secondaryMetric
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment