How to add Static Route to Windows

Sometimes you need add static route to Windows, I will show you how it could be done.

Why you need add route ?

  • you have two internet connection and you want to route all your connection to one of them
  • testing router configuration
  • you are use your windows as router ( BAD IDEA )

View the Windows routing table

Open your command line (Win+X) -> command prompt (admin)

 route print


===========================================================================
Interface List
 21...c8 5b 76 02 31 c9 ......Intel(R) Ethernet Connection I219-V
 23...3c 18 a0 05 af 93 ......Thinkpad USB 3.0 Ethernet Adapter
 11...00 50 b6 7f 84 45 ......ThinkPad OneLink Pro Dock Giga Ethernet
 18...44 85 00 f8 3e 3d ......Microsoft Wi-Fi Direct Virtual Adapter
  5...44 85 00 f8 3e 40 ......Bluetooth Device (Personal Area Network)
 10...44 85 00 f8 3e 3c ......Intel(R) Dual Band Wireless-AC 8260
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0   192.168.21.254   192.168.21.195     25
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
     192.168.21.0    255.255.255.0         On-link    192.168.21.195    281
   192.168.21.195  255.255.255.255         On-link    192.168.21.195    281
   192.168.21.255  255.255.255.255         On-link    192.168.21.195    281
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link    192.168.21.195    281
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link    192.168.21.195    281
===========================================================================
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
          0.0.0.0          0.0.0.0   192.168.88.100       1
===========================================================================

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    331 ::1/128                  On-link
 11    281 fe80::/64                On-link
 11    281 fe80::3c49:7579:a2b8:1b04/128
                                    On-link
  1    331 ff00::/8                 On-link
 11    281 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

Add static route to routing table

route ADD destination_network MASK [subnet_mask] gateway_ip [metric_cost]

The subnet_mask and metric_cost components are optional to the command. Default subnet mask is 255.255.255.0, metric cost will be one greater than 0.0.0.0 destination entry from routing table.

route ADD 192.168.88.0 MASK 255.255.255.0 192.168.88.1

if you add route by this command it will lasts until the next reboot, so if you need add this route persistent add -p switch to command

route -p ADD 192.168.88.0 MASK 255.255.255.0 192.168.88.1

Remove static route

You just need specify destination network to delete

route delete destination_network
route delete 192.168.88.0

This is all. Manage routes in windows is quite simple.

Leave a Comment

Your email address will not be published. Required fields are marked *