Search My Techie Guy

Saturday, May 14, 2016

Adding a Static IP route in a Windows Routing Table

Summary: 

This short post is to show you how to add a static IP route in a windows routing table.

Problem or Goal: 

Statically add an IP route in a windows routing table.

Cause: 

For my case, my laptop had two interfaces (The Local Area Connection on cable and the Wireless Network Connection), and i wanted to force traffic to a certain destination network out the LAN cable interface.

Solution: 

Statically define an IP route to your desired destination network and force it through the gateway that connects to the right interface.

Syntax:
route ADD xxx.xxx.xxx.xxx MASK xxx.xxx.xxx.xxx  xxx.xxx.xxx.xxx
Means:
route ADD “network” MASK “subnet mask”  “gateway ip”
Example:
route ADD 10.10.10.0 MASK 255.255.255.0 192.168.1.12
You can use this command to print the status of your routing table:
netstat -rn
Your routing table should now reflect that change, and all traffic to the 10.10.10.x network will now be sent through the interface that connects to the 192.168.1.12 gateway. 
The route add change will only stick across reboots if you add it with the -p flag, for example:
route -p ADD 10.10.10.0 MASK 255.255.255.0 192.168.1.12

Problem Solved?

YES

No comments: