Another post that I’m basically making for my future self. I have a local network that is a common network, and if I VPN into it and the network I’m at (hotel, friends house, etc) could be the same network range – we have a problem. I was going to renumber my entire LAN, but opted to add a static route on my laptop. When I’m VPN’d I only need to go to a few (possibly 1 IP).
Let’s find out the name of the interfaces:
netsh interface ipv4 show interface
Once we have that, I want the index or Idx to reference it with the route.
In this case I want to add a persistent route to the routing table. So if I’m RDP’ing to 192.168.1.102 AND while VPN is up, I want it to go through the VPN interface.
route -p add 192.168.1.102 mask 255.255.255.255 0.0.0.0 if 42
-p = persistent
192.168.1.102 is my target IP in the VPN network
255.255.255.255 is single IP mask
0.0.0.0 all IPs associated with that VPN interface (I have a VPN network, so need to ensure all IPs in that network handle this route)
if = if the interface is up
42 = Idx of the interface
View the route table
route print
If the route needs to be deleted:
route delete 192.168.1.102