Monday, February 29, 2016

Add Routes in Windows Command Prompt to Control Traffic in PC

If you want to connect to internet using Wi-Fi and connect to the local network using LAN this is the way to do it in Windows.

Open the Command Prompt as administrator

Hit route print

Here is the current routing table of my PC when I connected to both Wi-Fi & LAN networks.

Best path to a destination will be chosen by 2 simple rules

Longest match will be preferred
If there are 2 routes to same destination & mask, lowest metric will be preferred

If you hit ipconfig you can get your gateway IPs. My Wi-Fi gateway is & LAN gateway is

Problem is that there are 2 routes pointed to which is to internet and the lowest metric route is to go through the LAN interface which actually cannot reach internet.

Let's delete all routes to internet (default routes)
Complete command is route delete <destination> mask <mask> <gateway>
To delete all the routes to through any gateway you can hit route delete

Let's add a route to internet with a metric of 5 to go through Wi-Fi gateway (
Metric of 5 is just a random number which is lower than any route in my routing table. You can give any other number which will suit your routing table.

Complete Command is;
route add <destination> mask <mask> <gateway> metric <metric> if <interface>
Interface is not necessary, It will be added automatically to match the gateway. It is just your IP on the regarding NIC.
Hit route add mask metric 5

Now let's add 3 more routes to private ip addresses with a metric of 5 to go through LAN gateway (

Hit the following commands
route add mask metric 5
route add mask metric 5
route add mask metric 5

Now you can hit route print again to see the Windows routing table. Task is completed..

To permanently add routes, use -p after route add commands. It will be stored in persistent routes area under the routing table of route print output.

Commands I entered?

route delete
route add mask metric 5
route add mask metric 5
route add mask metric 5
route add mask metric 5


  • July 2, 2017 at 3:42 PM
    Anonymous says:

    Neat Web-site, Carry on the great job. Thank you so much.


Post a Comment