Windows route add default gateway


Displays and modifies the entries in the local IP routing table. If used without parameters, route displays help at the command prompt.

Usage

ROUTE [-f] [-p] [-4|-6] command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]

Flags

  -f           Clears the routing tables of all gateway entries.  If this is
               used in conjunction with one of the commands, the tables are
               cleared prior to running the command.

  -p           When used with the ADD command, makes a route persistent across
               boots of the system. By default, routes are not preserved
               when the system is restarted. Ignored for all other commands,
               which always affect the appropriate persistent routes.

  -4           Force using IPv4.

  -6           Force using IPv6.

  command      One of these:
                 PRINT     Prints  a route
                 ADD       Adds    a route
                 DELETE    Deletes a route
                 CHANGE    Modifies an existing route
  destination  Specifies the host.
  MASK         Specifies that the next parameter is the 'netmask' value.
  netmask      Specifies a subnet mask value for this route entry.
               If not specified, it defaults to 255.255.255.255.
  gateway      Specifies gateway.
  interface    the interface number for the specified route.
  METRIC       specifies the metric, ie. cost for the destination.

All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.

If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.

If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The '*' matches any string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.

Pattern match is only allowed in PRINT command.
Diagnostic Notes:
    Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
    Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
             The route addition failed: The specified mask parameter is invalid. (Destination & Mask) != Destination.

Examples:

    > route PRINT
    > route PRINT -4
    > route PRINT -6
    > route PRINT 157*          .... Only prints those matching 157*

    > route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
             destination^      ^mask      ^gateway     metric^    ^
                                                         Interface^
      If IF is not given, it tries to find the best interface for a given
      gateway.
    > route ADD 3ffe::/32 3ffe::1

    > route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2

      CHANGE is used to modify gateway and/or metric only.

    > route DELETE 157.0.0.0
    > route DELETE 3ffe::/32

Examples

For more examples check learn.microsoft.com

Display the entire contents of the IP routing table

C:\Users\crypt0rr>route print
===========================================================================
Interface List
  9...00 1c 42 b0 90 e2 ......Parallels VirtIO Ethernet Adapter
 14...02 00 4c 4f 4f 50 ......Npcap Loopback Adapter
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      10.211.55.1      10.211.55.6     15
      10.211.55.0    255.255.255.0         On-link       10.211.55.6    271
      10.211.55.6  255.255.255.255         On-link       10.211.55.6    271
    10.211.55.255  255.255.255.255         On-link       10.211.55.6    271
        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
      169.254.0.0      255.255.0.0         On-link    169.254.136.15    281
   169.254.136.15  255.255.255.255         On-link    169.254.136.15    281
  169.254.255.255  255.255.255.255         On-link    169.254.136.15    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    169.254.136.15    281
        224.0.0.0        240.0.0.0         On-link       10.211.55.6    271
  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    169.254.136.15    281
  255.255.255.255  255.255.255.255         On-link       10.211.55.6    271
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
  1    331 ::1/128                  On-link
 14    281 fe80::/64                On-link
 14    281 fe80::2594:eebe:2b4d:880f/128
                                    On-link
  1    331 ff00::/8                 On-link
 14    281 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

Display the routes in the IP routing table that begin with 10

C:\Users\crypt0rr>route print 10.*
===========================================================================
Interface List
  9...00 1c 42 b0 90 e2 ......Parallels VirtIO Ethernet Adapter
 14...02 00 4c 4f 4f 50 ......Npcap Loopback Adapter
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
      10.211.55.0    255.255.255.0         On-link       10.211.55.6    271
      10.211.55.6  255.255.255.255         On-link       10.211.55.6    271
    10.211.55.255  255.255.255.255         On-link       10.211.55.6    271
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
  None
Persistent Routes:
  None

Add a default route with the default gateway address of 192.168.12.1

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

URL list

  • Learn.microsoft.com — route

Sometimes you need to manually add, change, or remove a route on a Windows machine. Here is quick guide to help you accomplish these tasks.

First start by opening a CMD prompt by going to start then typing cmd.

These commands should work for Win XP, Win Vista, Win 98, Win NT, Win 2000, Win 2008, Win 2012, Win 7, Win 8, Win 10.

Show the Current Routing Table

C:\>route print
===========================================================================
Interface List
 11...54 ee 75 5b e3 c9 ......Intel(R) Ethernet Connection (3) I218-LM
 13...5c e0 c5 7f e4 c8 ......Intel(R) Dual Band Wireless-AC 7265
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0   192.168.177.1    192.168.177.30     10
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
     192.168.60.0    255.255.255.0         On-link      192.168.60.1    276
     192.168.60.1  255.255.255.255         On-link      192.168.60.1    276
   192.168.60.255  255.255.255.255         On-link      192.168.60.1    276
    192.168.177.0    255.255.255.0         On-link     192.168.177.1    276
    192.168.177.1  255.255.255.255         On-link     192.168.177.1    276
  192.168.177.255  255.255.255.255         On-link     192.168.177.1    276
===========================================================================
Persistent Routes:
  None

The default route is represented by A destination/netmask of 0.0.0.0. If there isn’t a route with a more specific destination and netmask, the default route is used.

Use this subnet calculator if you need help subnetting.

Add a Static Route

To add a route to the routing table use the route add command. An example looks like this:

route add 10.0.0.0 mask 255.0.0.0 192.168.177.1

You can optionally add a metric 2 to the end if you want to add a specific weight to the route. The routes with the lowest metric will take precedence over higher metrics. By default, static routes have a metric of 6.

You can also optionally add a IF 2 to the end. This will force the route to use interface 2. You can see what interface numbers you have with the route print command.

Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
         10.0.0.0        255.0.0.0         On-link     172.16.177.30      6

Remove a Static Route

To remove a route you must use the route delete command and the destination.

route delete 10.0.0.0

Change a Static Route

If you simply want to update a static route you can use the route change command.

route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2

Troubleshooting

If you get the following error:
The requested operation requires elevation.

To resolve this you will need administrator access to the system. Go to the start menu and when you type cmd right click on the cmd.exe program and click Run As Administrator. This opens a CMD prompt with more privileges.

For any further help you can use the built in help the route command provides. Simply type route and hit enter.

C:\>route

Manipulates network routing tables.

ROUTE [-f] [-p] [-4|-6] command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]

  -f           Clears the routing tables of all gateway entries.  If this is
               used in conjunction with one of the commands, the tables are
               cleared prior to running the command.

  -p           When used with the ADD command, makes a route persistent across
               boots of the system. By default, routes are not preserved
               when the system is restarted. Ignored for all other commands,
               which always affect the appropriate persistent routes. This
               option is not supported in Windows 95.

  -4           Force using IPv4.

  -6           Force using IPv6.

  command      One of these:
                 PRINT     Prints  a route
                 ADD       Adds    a route
                 DELETE    Deletes a route
                 CHANGE    Modifies an existing route
  destination  Specifies the host.
  MASK         Specifies that the next parameter is the 'netmask' value.
  netmask      Specifies a subnet mask value for this route entry.
               If not specified, it defaults to 255.255.255.255.
  gateway      Specifies gateway.
  interface    the interface number for the specified route.
  METRIC       specifies the metric, ie. cost for the destination.

All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.

If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.

If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The '*' matches any string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.

Pattern match is only allowed in PRINT command.
Diagnostic Notes:
    Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
    Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
             The route addition failed: The specified mask parameter is invalid.
 (Destination & Mask) != Destination.

Examples:

    > route PRINT
    > route PRINT -4
    > route PRINT -6
    > route PRINT 157*          .... Only prints those matching 157*

    > route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
             destination^      ^mask      ^gateway     metric^    ^
                                                         Interface^
      If IF is not given, it tries to find the best interface for a given
      gateway.
    > route ADD 3ffe::/32 3ffe::1

    > route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2

      CHANGE is used to modify gateway and/or metric only.

    > route DELETE 157.0.0.0
    > route DELETE 3ffe::/32

Check out this article for more cool Windows CLI commands.

Have you ever connected to a VPN and realize that you cannot access some of the network resources that you have at home? Maybe you are not able to access Printer in your local network, or something else.

And other situation is you have a windows machine that is connected to two different networks and you Are not able to access some of the network resources and some of them are working fine.

Then you have a problem with your network routing, in this blog I am going to cover how you can solve those above issues by Reconfiguring the windows routing table.

What is routing?

If you are not familiar with routing then don’t worry, routing is a mechanism to connect two different network Segments to each other.

Suppose you have a network 192.168.1.0/24 and another 10.1.1.0/24. By default, both of those networks cannot talk to each other because both are two different subnets. For both the network to talk to each other, you need to use static routing.

There is something called dynamic routing, which is used by the network devices such as routers, firewall and layer3 switch and even some of the windows server machine.

In this blog, we are focusing on the end host level especially windows static routes.

What is static routing in windows?

A static route is a specific subnet route that is defined by the admins manually to reach a certain destination. You can specify the destination subnet that you want to reach from the host and point to a default gateway.  You can add as many static routes as you like.

You can define for example, to reach 192.168.1.0/24 you can go via 10.1.1.1

The static route is usually not needed when you host has only a single interface, the default route will take care of that.

Read also,
Windows 11 on KVM – How to Install Step by Step?
How To Extend Windows Storage in KVM ?
KVM Windows No Sound? – Let’s fix it.
10 Easy Steps To Install Windows Server in Linux KVM
How To Set Static IP On Ubuntu? (GUI and CLI)

What is default route in windows?

If you don’t know the subnet that you want to reach, that’s when you use something called default routes.  The default route is mainly configured to reach the internet.

We don’t know the IP addresses that are available on the internet, right?

That means you cannot specify the routes in the routing table, and on the internet, there are millions of IP addresses, and how do I reach those IP address from your local machine?

You can type 0.0.0.0 as the IP subnet and 0.0.0.0 as the mask and point the route to the default gateway.  This basically tells the windows host that to reach any subnet apart from the specific subnet you use the default route.

Usually the default route is added to a window hosts or any end hosts for that matter is by configuring the default gateway. If you define a default gateway on the system, that would add a default route pointing to the default gateway.

However, In some situations, it can create a problem, because you may have multiple LAN ports and all are configured with DHCP, as soon as the host receive the IP address via DHCP on all ports, it also add default gateways for all those interfaces. The result is multiple default routes towards multiple gateways. This would create a problem when the end hosts wanted to reach the internet.

how to view the routing table in windows?

Like any network devices, the windows machine also has a local routing table. It can tell you lot of information about the routes that this windows box is aware of.

To view the windows routing table, you can enter the command route print in windows command line prompt. However, that you would display both the IPv4 and IPv6 routing table, and you can also get the route output specific to the IP version.

how do I see ipv4 routes in windows?

If you wanted to see just the IPv4 routes in windows you can type the command route print -4.

how do I see ipv6 routes in windows?

Just like the IPv4 you can also see the IPv6 routes alone in the windows routing table by typing route print -6.

How do you read a Windows routing table?

It’s quite common for anyone to look at the windows routing table and get confused with the information displayed. Let’s go through and explain each one of the items in the windows routing table.

  1. Interface ID – each interface that you have on your machine will be identified with a unique ID.
  2. The mac address of the machine – this is the physical address of your network interface card. You can also get the mac address detail by typing ipconfig /all.
  3. The name of the interface.
  4. IPv4 routing table – Here you can view the IPv4 routing table.
    • Network destination – It shows the destination subnet that this machine can reach currently.
    • Netmask – the subnet mask of the network destination IP.
    • Gateway – you can see the remote gateway as well as on-link where you are learning this route from.
      On-link means, the directly connected routes from its own NIC.
    • Interface is the place you can see the IP address of each network interface.
      • The IP address 127.0.0.1 is the machine’s loopback interface.
    • Metric – It is the value that defines the priority of the route, the lower the metric the better.
  5. Persistent route – This route is defined by the admins and it would never be removed even when you power down the system, read on to learn more about it.
  6. IPv6 routing table – You can view the IPv6 routing table here.
  7. IPv6 persistent routes – The same persistent routes available in the Ipv4.

How do I manage multiple gateway in windows?

When you have two interfaces installed on the windows machine, you will have to manage the multiple gateways using static routes. Lets look at how we can configure multiple gateways using the static routes. below are the examples that we are going to configure.

  • Validate the internet connectivity.
  • Configure primary default gateway for windows 10.
  • How to delete the route in windows?
  • How to add two default routes in windows?
  • How do I add a static route in Windows?
    • How do I add a persistent route in Windows?

Validate the internet connectivity.

Before we begin, lets validate the internet connectivity on this host.

Open CMD with admin rights.

Click on the start menu, and type CMD. Right-click and Run as administrator. Click yes on the admin prompt.

Or

  • Windows key + R
  • Type CMD
  • Press CTRL+Shift+Enter

Note: To see the routing table, you don’t need to access the CMD with Admin rights, normal access would do.

Lets try to ping the internet IP, which is 8.8.8.8.

Yes, I can reach the internet and let me check which path it is taking by using a command called tracert

As you can see, it is taking the path 192.168.0.1.

If you look closely at the routing table, you can notice, there are two default routes with same metric. One towards 192.168.0.1 (interface 1)and the other towards 10.1.1.1 (Interface 2) with equal metric.

In this setup, for the first time when you try to access the internet, It will send the packet out to both the interfaces. And it elects the default gateway that it needs to use.

Configure primary default gateway for windows 10.

Since we don’t have access to internet via the interface 2 (10.1.1.1), we shouldn’t be using the default route towards it. To resolve multiple default gateways on your network, you got two options.

Change the metric for the windows interface or Delete the default gateway pointed to the interface 2.

We know that the interface which we wanted to use for the internet is interface 1 (192.168.0.1) and when we look at the metric, we can see that both the interface 1 and 2 has the same metric 281.

In normal windows machine you should be able to see the metric starting from 25, and if you are using windows as a VM you can notice its metric is by default 281. However, when you try to change the metric, you will be able to see windows machine by default would take the metric as 25 though you cannot see them.

To make the interface 1 as the priority one for the internet, you need to lower the metric of it.

All you have to do is, add the metric value of 1 for the interface 1., and that would change the windows metric value to 26 (25+1)

1.Get the interface ID.

When you enter the command route print -4, that will show you the interface list on the top.

And for our interface 1, the ID is 21, and interface 2 is it 25.

To validate the interface you can type ipconfig /all and compare the mac address with the interface list ID’s.

2. Change the interface metric.

3. Validate the configuration.

Lets check the routing table now.

As you can see, the metric changed to 26 for our main interface. From now on, all the internet traffic will go out via the interface 1.

What if the interface 1 goes out?, then by default windows machine will start using the interface2

To simulate the issue, I just unplugged the interface 1 and as you can see, I no longer have the default route towards the interface1.

How to delete the route in windows?

The above scenario will be useful, if you have internet access on both links where the interface 1 has more bandwidth than interface 2.

Since we don’t have internet access at all on interfac2, there is no point in keeping the default route so let’s go ahead plug the interface1 back in and remove the default route connected to the interface2.

  1. To delete a route in the windows routing table, you can use the command route DELETE.

As we are going to delete the default route pointed to 10.1.1.1, you can use the command below.

route DELETE 0.0.0.0 MASK 0.0.0.0 10.1.1.1

2. Verify the routing table.

We no longer have the default route pointed to 10.1.1.1 gateway.

How to add two default routes in windows?

In our previous scenario where everything was looking good, however when the internet on the interface 1 goes down there is no redundancy in place. So, you decided to add internet over secondary interface.

One of the use cases being, you have internet on interface 1 that has more bandwidth and internet 2 with less bandwidth, in the event of internet 1 goes down, the internet 2 on interface 2 should kick in.

In the routing table, we already have a default route in which we set the metric to 26 previously.

Let’s go ahead and add the second default route with more metric, that way the second default route will be less preferred over the primary link. And when the primary link goes down the secondary one will take care of the internet traffic.

To add the default route you can add the below commands.

route ADD 0.0.0.0 MASK 0.0.0.0 10.1.1.1 -p  METRIC 50 -p

The reason I added the metric 50 because, if you add another default route without a metric it would just pick up the default metric that is already used by the other default route.

The newly added route now has the metric of 75 now.

When you have connected to wifi and wired at the same time on your windows 10 PC, you will have two default route with different metric and if you are thinking about prioritising the wifi network over wired, then you check out the article here to know how.

How do I add a static route in Windows?

Alright the internet part has been taken care with default route, now lets talk about the specific static routes towards the server from 1 to 6.

In the servers list, to reach server 1-3 you must go via the interface 2 and the server 3-7 should reach via interface 1.

Lets start with the server1, 10.2.2.10 by pinging.

As you can see, we are not able to reach the IP, lets look into the IP table, and I don’t see any IP inside the routing table which is not good.

Currently what’s happening is that, since we do not have a specific route towards 10.2.2.0 it is taking the default route with lower metric on the interface1.

As you can see from the traceroute below.

We need to point the 10.2.2.0 towards interface 2.

In CMD add the route as below.

route add 10.2.2.0 mask 255.255.255.0 10.1.1.1

Verify the route table again.

Ping the IP address, as you can see, we are able to reach the iP address via interface 2 now.

How do I add a persistent route in Windows?

We just added a static route in windows and it is working as expected, however what happens if you reboot the machine?

When you reboot the machine, whatever the changes that you made for the routing will be removed. For those routes that are temperoroly it should be fine, but not good for the permanent destination.

To avoid that you can use persistent route in windows. That way the changes that you make on the windows routing table are retained even after you reboot the machine. To add a persistent route, you just have to add -p at the end of the route statement.

route add 10.2.2.0 mask 255.255.255.0 10.1.1.1 -p

From now on all the routes that we are going to add using the persistent command only.

You should be able to see the persistent route on the bottom of the routing table.

Lets add rest of the other IP addresses, before we add the routes, lets verify the reachability.

No, both destinations are not reachable now, so lets go ahead and add the routes.

route add 192.168.6.10 mask 255.255.255.0 10.1.1.1 -p

route add 172.16.2.10 mask 255.255.255.0 10.1.1.1 -p

The servers over the interface2 can be reached now, you may test the connectivity using the ping again and it should work just fine.

You can also verify the added routes in the windows routing table.

Can we reach the servers 4-6 in interface1 now? As you know we don’t have specific routes for it. If you said the answer is Yes, then you are right!.

let’s send ping to server 4,5 and 6.

As you can see, I am able to reach all three servers just fine, how come we are able to reach those servers even though we don’t have a specific static route for the same.

Its because, it is using the same default route on the interface1, so the PC would send the route to the default gateway, and because the gateway knows about the connected route 10.0.0.0/24, 198.168.3.0/24 and 172.0.0.0/24 the windows PC can reach all the servers on the interface1.

This is working great, right?

Yes but no, let me explain.

It is working fine now, but what if you decided to remove the default route on the interface 1, then it will be a problem. Those servers 4-6 going via interface 1 over the default route cannot get to the remote anymore.

It is recommended to add specific static routes that we added for the interface 2 and it should take care of everything. So even if you decide to remove the internet on the interface 1, you can peacefully remove the default route and specific routes will take care of the server reachability.

To add the rest of the servers subnet into the routing, you may add the route statement as below.

route add 10.0.0.0 mask 255.255.255.0 192.168.0.1 -p

route add 172.0.0.0 mask 255.255.255.0 192.168.0.1 -p

route add 192.168.3.0 mask 255.255.255.0 192.168.0.1 -p

Validate the routes.

Last Updated :
01 Nov, 2022

A routing table is a part of a computer’s operating system. It contains the details of the best way to reach different networks, such as your home or office network. The table helps your computer send data to different networks and devices. Windows uses a routing table to determine the best way to send data to a specific destination. A routing table is used in every operating system. It contains the details of the best way to reach different networks, such as your home or office network. The table helps your computer send data to different networks and devices. Windows uses a routing table to determine the best way to send data to a specific destination. You can add a static route to the routing table to save time if your home or business is frequently visited. You can also add alternate routes to your home or business if you have trouble reaching the original location via the routing table.

Interfaces and Route Table on Windows:

The Command route print prints the list of All Interfaces and the IPv4/v6 Routing Table. It is followed by a comma-delimited argument, which describes the command to run (e: -f). If there are no arguments then it reports all installed ports for each configured interface; if not supplied this would report only the ones present on that port range. The format uses spaces as normal in names. Below is the Snapshot after running route print on Windows.

Interface list

 
IPv4 Routing Table

 
IPv6 Routing Table

 

Adding Static Route to the Routing Table:

To add a static route, press and hold the Windows key and the R key, then press Enter on your keyboard; this opens the Run dialog box. Type route print and press Enter on your keyboard. This opens Windows’ Routing and IP Configuration dialog box. In this dialog box, click on Add → Next → Next; this opens the Add Default Route window. In this window, enter the details for your new default route, then click on Add → Close → OK → Apply → Close→ OK → OK;  Now you are now finished adding a static route to the Windows Routing Table.

The command to add an entry from cmd is as below

route add Destination_Address 
MASK Subnet_Mask Gateway_IP Metric
Example: route add 192.168.39.0 
MASK 255.255.255.0 192.148.0.2
adding IP

 

Below is the output of the route print after adding the static route.

192.168.39.0 Default IP

 

Alternate routes can be useful for travelers or for businesses with multiple locations throughout town or regionally. For example, if you live far from work you may want an alternate route, so you don’t have to constantly drive back and forth all day long between home and work each day; alternatively, if you’re a business owner with several locations throughout town or regionally, alternate routes can be useful for customers who need several locations open for business each day they can easily reach their location by traveling along different roads through town or regionally instead of having to travel back-and-forth on one road each day between their locations. Adding an alternate route to your home or business is easy with a properly functioning routing table; however, many users neglect to add them until they experience problems reaching their location via that main route. Adding a static route can also be effective when adding an alternate route for quick access for frequent use by family members or friends; either way, adding a static route or alternate route is easy with just a few steps.

Add a Static TCP/IP Route to the Windows Routing Table

Here’s a best way to add a static route to the Windows Routing Table, make route persistent and delete static route from the Routing Table via Command Prompt.

Inside Article:

  • Open Command Prompt
  • route print Command in Windows
  • route ADD Command to Add a Static Route to the Windows Routing Table
  • Make a Static Route Persistent
  • Delete a Static Route from the Windows Routing Table
  • FAQs

A routing table is the one that performs routing of the packets or simply indexing of multiple routes with the instructions where all these packets will go when they leave a system. Whether it’s a physical router or a PC.

Most of the routers, including the built-in Windows PC router, use dynamic routing. As the router is an intelligent device and it selects the best route while sending packets.

You can look out everything in-depth detail with the “traceroute” command that will show you all the connections a packet makes and finally reaches its final destination.

Let’s try to understand somehow, what is a static route?

 A static route is the one, which is not updated dynamically.

Sometimes you want to add some certain traffic from your company/home router or gateway then we add a static route.

Almost all the routers allow us to add a static route to pass certain traffic.

Most people use windows PC at home just like me and want to add a static TCP/IP route to the Windows Routing Table.

For this, let’s take a scenario

You have two internet connections, one is for your regular use and the other is for official working. Now you want to send/receive some traffic to a certain IP address range using only one internet connection.

You also have done subnetting on your network and want to send traffic to a certain subnet.

Then static routes are most useful in such a testing environment.

You also want your Windows PC should be used as a router for your network and you want an overall control over it.

If you are facing any of the above situations then this article is for you.

Stay with me!

We will simply use the command prompt to add a static route to the Windows routing table.

How to View the Windows Routing Table

Before starting to add a static TCP/IP route to the Windows Routing Table, it is necessary for judgment to view the routing table first.

For this

  • Open up Command Prompt or hit Windows+X
  • Select Command Prompt (Admin)

Note:- If you see PowerShell, instead of Command Prompt on the power user menu, then you don’t need to worry about it, you can use PowerShell as you use the command prompt. The functionality of both is the same.

[su_highlight]You can also open a command prompt via short keys: (Windows Key + x + c)[/su_highlight]

After opening the Command Prompt, go ahead and type the following command and hit Enter:

[su_highlight]route print[/su_highlight]
You will be followed by:
add static route windows server 2012 r2

The output is divided into three sections:

  • Interfaces List
  • IPv4 Route Table
  • IPv6 Route Table

The Interface List comprises all your interfaces by MAC address while the IPv4 Route Table and IPv6 Route Table point to the Dynamic and persistent routes.

As you can see the list of the network with destinations and the default gateways in the above Windows PC routing table to which packets are forwarded whenever they are sent to some destination.

It is the default gateway which forwards all type of information to specific destinations.

Now let’s add a static TCP/IP route to the Windows Routing Table

Add a Static Route to the Windows Routing Table

To add a route we use the route ADD command in Windows 10 or other Windows versions that tell the Windows which Network to add and then we enter the Subnet mask and Gateway.

To add a static route to the table, You need to type the following command according to the syntax.

[su_highlight]route ADD destination_network MASK subnet_mask gateway_ip metric_cost [/su_highlight]

The above command in a more simple way:

[su_highlight]route ADD to this network with this mask via this gateway IP[/su_highlight]

The subnet mask and the “cost metrics” are optional to the command. If you do not mention the subnet mask then it will automatically take a Class C subnet mask that is 255.255.255.0.

Also, if you do not provide metric cost, a cost one greater than the 0.0.0.0 destination entry will be used

The cost metric value is used when Windows has to decide to select the best path among all the routes pointing towards the same destination.

Example:

Let’s suppose we’re on the 192.168.0.0 network whose default gateway is 192.168.0.3 and we want to add a static route to one of our management VLAN located on the 192.168.20.0 network.

Assuming our subnet mask is 255.255.255.0

Or in a more convenient way:

We want to add a Static Route to the Windows Routing Table saying that all the traffic should merge at 192.168.20.0 subnet through the gateway 192.168.0.3 with the automatic metric cost.

Then we could add a route like this:

[su_highlight]route ADD 192.168.20.0 MASK 255.255.255.0 192.168.0.3[/su_highlight]

Where

192.168.20.0 is the Network

255.255.255.0 is the Subnet Mask

192.168.0.3 is the Default Gateway

Now hit the Enter

route add windows 10

Now, again give route print command to see your windows routing table again, you will see a new static route to the table

[su_highlight]route print[/su_highlight]

route add command in windows 7

where 192.168.20.0 is the network destination, 255.255.255.0 is the network mask specifying class C IP address and 192.168.0.3 is the default gateway or the router’s IP address with 56 metric cost.

That’s it

You have added a Static Route to the Windows Routing Table.

But there is something necessary and you can’t skip that:

When you add a static route in Windows 10, with by default behavior its session ends until the next restart of your Windows PC. This means when you will restart the computer the added static route will poof.

That is why many major companies use a coordinated list of static routes that are often updated.

Instead of adding static routes every time on every machine, they use a batch script file that adds all the latest routes at the time of Windows startup. This technique keeps the windows routing table stable and organized.

You can write the batch script with your own hands. Because writing a script is an easy job to do.

But if your network is so small or you are a home user and you want to add just a few static routes to your windows routing table then you can add the –p option to the command to make the route persistent.

Now you might be wondering that how do I permanently add a route in Windows that should be consistent even I restart my computer?

How to Make a Route Persistent?

What is Persistent Route?

A persistent route is the one, which stays in place when the windows startup or when you Reboot the Windows.

And to make a static route persistent you need to add “-p identifier ” at the start or at the end in the Windows route add interface.

Here’s how you can add a persistent route in the Windows routing table and make that static route constant.

Syntax to add persistent route Windows

[su_highlight]route ADD to this network with this mask via this gateway IP -p[/su_highlight]

[su_highlight]route -p ADD 192.168.20.0 MASK 255.255.255.0 192.168.0.3 [/su_highlight]

You can also use -p identifier at the end of the Windows route add interface command like this:

[su_highlight]route ADD 192.168.20.0 MASK 255.255.255.0 192.168.0.3 -p [/su_highlight]

How do I permanently add a route in Windows? what is persistent static route in the windows routing table

How to Delete a Static Route from the Windows Routing Table

Once you add a static route to the windows routing table, it can be easily deleted. Because in the future, maybe you don’t need it and you have to remove it.

then here is how to delete a static route from the windows routing table.

Syntax:

[su_highlight]route delete destination_network [/su_highlight]

So, this is the static route, 192.168.20.0, we have just added to the windows routing table, now let’s delete it by entering the following command at the command prompt.

[su_highlight]route delete 192.168.20.0 [/su_highlight]

how to delete a static route from the windows routing table

Let’s check with the “route print”  command in the command prompt either the route has been deleted or not?

how to delete a static route from the windows routing table 2

That’s it

You can see the above table there is no static route entry because it has been deleted with the typed command.

Static routes are used for testing and other multiple-purpose at home or in every small and large scale organizations networks. Use it with your own consent.

See Also:

  • How To Restart Windows’ Explorer.Exe Using Taskbar And Start Menu
  • How to Add Control Panel Shortcut to Windows 10 Right Click Menu
  • How to Take Screenshot of Complete Webpage With One Click
  • How To Make Adobe PDF And Sumatra PDF Readers To Restore Last Opened Files
  • How To Access The Most Recently Opened Documents In MS Word

FAQs: Add Routes, Delete Routes, View and Clear All Routes

  1. What is Route add command in Windows?

The Rout add command is used to add a static route to the windows routing table which tells the Windows which Network to add. Also, we need to add Subnet Mask and the Gateway.

Here is the route add command in Windows 10:

route ADD this Network with this Subnet-Mask via this Gateway IP.

  1. How do I add a persistent route in Windows 10?

When you add a static route to the windows 10, it remains active until you restart your computer. After restart the static route disappears this is why you need to add a persistent route in Windows 10 so that it remain permanent.

Syntax add a persistent route in Windows 10?

route ADD this Network with this Subnet-Mask via this Gateway IP –p

Where –p is the modifier to make the added route permanent

  1. How do I setup a static route?

Here is how you can setup a static route in Windows

[su_highlight]route ADD destination_network MASK subnet_mask gateway_ip metric_cost [/su_highlight]

  1. How do I view a route table in Windows?

To view a route table in Windows, just open Command Prompt with the following command: [su_highlight](Windows Key + x + c)[/su_highlight]

Then enter the following Rout Print command

[su_highlight]route print[/su_highlight]

  1. How do I change the metric route in Windows?

Route.exe Change Tool in Windows

The route.exe tool is used to change the metric route in Windows. When we talk about metric route we mean metric of an adapter. It has limitations that you cannot set any metric number lower than the current metric value.

Suppose the IP for the Ethernet adapter is 192.168.2.5. Now let’s just change the metric route in Windows using Route.exe tool.

To increase the metric for an Ethernet adapter with an IP of 192.168.2.5, the command syntax is:

[su_highlight] route.exe CHANGE (Network Destination) MASK (Network Mask) (Interface IP) METRIC (NUMBER) IF (INTERFACE NUMBER) [/su_highlight]

Now let’s execute the command

  • Open the Command Prompt by (Windows Key + x + c) and type the following command
  • [su_highlight] exe change 0.0.0.0 mask 0.0.0.0 192.168.2.5 metric 5 IF 7 [/su_highlight]

The metric for the Ethernet adapter will become 25.

  1. How do I permanently add a route in Windows?

See the answer in the question no. 2

  1. How do I view a persistent route in Windows?

To view a persistent route in Windows just type “rout print” command in the command prompt.

Now go to the “Persistent Rout” section where you can view the persistent route.

  1. How to Delete Persistent Route in Windows?

To remove or to delete persistent route entry type the following command

 route -p delete 192.168.20.0

  1. What command do you use to display the routing table on a local system?

Open the Command Prompt and type the either one of the following commands

“netstat” –r or “route print”

  1. How to clear All Routes in Windows

You can delete all routes in windows by the following commands

  • route print

View all routes in windows (all versions)

You can see a list of 16 active networks and their routes here. Now let’s delete all routes in windows

Type the following Command

[su_highlight]route delete 192.168.16.0 mask 255.255.255.0 192.168.15.100[/su_highlight]

how-to-clear-active-routes-in-windows-10

Now type “route print”

Now you can see all the routes in the windows routing table are deleted by the command

delete-active-routes-in-windows-7

Final Words

We have learned “how to add a static TCP/IP route to the Windows Routing Table” and also how to delete a static route from the windows routing table.

Share it with your friends and your thoughts with us through the comments section that how it was helpful for you.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows winsxs temp inflight
  • Как показать скрытые файлы на флешке windows 10
  • Как проанализировать диск в windows 10
  • Windows 10 21h1 repack
  • Dell inspiron 5720 drivers windows 10