Skip to content

Instantly share code, notes, and snippets.

@tsprlng
Created November 28, 2016 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsprlng/1f47c1f8a676f7b08e67bd1dda1c4cf9 to your computer and use it in GitHub Desktop.
Save tsprlng/1f47c1f8a676f7b08e67bd1dda1c4cf9 to your computer and use it in GitHub Desktop.
windows-vpn-route-silliness

Config

Configure the VPN not to be the default route (Untick "Use default gateway on remote network", buried way down in the adapter TCP settings), otherwise this is a bit pointless.

Triggering

Set up scheduled tasks triggered on 'an event':

  • Log: Microsoft-Windows-NetworkProfile/Operational
  • Source: NetworkProfile
  • Event ID: 10000 and another for 10001

This will trigger the script on any connection/disconnection, which is mildly annoying, but works.

(ipconfig | findstr /R /C:"officeL2TP") && (
echo VPN IS ALIVE
route add 192.168.0.0 mask 255.255.0.0 0.0.0.0 metric 1 if 36
route add 10.0.0.0 mask 255.0.0.0 0.0.0.0 metric 1 if 36
ipconfig /flushdns
) || (ipconfig | findstr /R /C:"officePPTP") && (
echo VPN2 IS ALIVE
route add 192.168.0.0 mask 255.255.0.0 0.0.0.0 metric 1 if 35
route add 10.0.0.0 mask 255.0.0.0 0.0.0.0 metric 1 if 35
ipconfig /flushdns
) || (
echo VPN IS NOT ALIVE
route delete 192.168.0.0 mask 255.255.0.0
route delete 10.0.0.0 mask 255.0.0.0
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment