Windows - Add a route with specific interface

Howto add a route with a specific interface into the windows routing-table. 

This can be useful for example if you have a tunnel-all vpn connection active but want to route certain traffic through the normal default gateway, not through the vpn:

1. Open "cmd" and use "route print" to see the current routing-table:

2. The interface list shows the currently available interfaces. 

Example with single destination ip:

3. If you want to send all traffic to e.g. 192.168.1.254 using another interface than the default route, which is for example your vpn connection, then:
-lookup the numer of the interface in the interface list, e.g. 14

-change the number from decial to hexadecimal: 14 = 0xe
-check the ip-address of the routing device of that interface, e.g. 192.168.117.254
-use the following command
 
"route ADD 192.168.1.254 MASK 255.255.255.255 192.168.117.254 IF 0xE"
  
With that all traffic to the IP 192.168.1.254 is sent over interface 0xe (interface 14) via
192.168.117.254.

4. Check with "route print" if the route was set correctly.


Example with a subnet as destination:

3. If you want to send all traffic to a certain subnet, simply change the ip and subnet. Example: 

"route ADD 192.168.1.0 MASK 255.255.255.0 192.168.117.254 IF 0xE"
  
With that all traffic to the IP 192.168.1.0/24 is sent over interface 0xe (interface 14) via
192.168.117.254.

4. Check with "route print" if the route was set correctly. 


More can be found here, examples, how to use metrics and persistent routes: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490991(v=technet.10)


No comments:

Post a Comment

Azure Managed Identities (technical service accounts)

Explaination Azure Managed Identities = technical service accounts Password is automatically managed, as it was the case in managed service ...