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.
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
Below is the output of the route print after adding the static route.
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.
Last Updated :
01 Nov, 2022
Like Article
Save Article
If you’re connecting to a work network and your home network, it might be handy to manually control how traffic is routed.
Quick Links
- What Are Routing Tables?
- View the Windows Routing Table
- Add a Static Route to the Windows Routing Table
- Remove a Static Route from the Windows Routing Table
Key Takeaways
- Adding a static route to the Windows routing table can be useful in specific situations, such as managing multiple internet connections or directing traffic to specific subnets.
- You can view the Windows routing table using the Command Prompt by typing «route print» and see the destinations and gateways for packets.
- To add a static route, use the command «route add destination_network MASK subnet_mask gateway_ip metric_cost» and make it persistent with the «-p» option. To remove a static route, use «route delete destination_network».
In some specific types of environments, you might find it useful to add a static route to the routing table. Here’s how to go about it in Windows 10 and Windows 11.
What Are Routing Tables?
A routing table dictates where all packets go when they leave a system — whether that system is a physical router or a PC. Most routers — including the one built into your Windows PC — use some form of dynamic routing, where the router is capable of selecting the best place to forward packets based on information it gets from other routers. You can see it at work if you use the traceroute command to watch the connections a packet makes as it reaches it’s final destination.
Most routers also allow you to add a static route (one that doesn’t get dynamically updated) if you want to always forward certain traffic to a specific router or gateway. Why? Well, most people using Windows in their home or small business probably won’t — but this can be useful under certain circumstances, such as:
- You have two internet connections — maybe one for regular use and one for connecting to a work network — and you want all traffic to a certain IP address range to go out over one of those connections.
- You have set up multiple subnets on your network and need to direct traffic to a particular subnet. Static routes can be particular useful in testing these types of environments.
- You’re actually using a Windows PC as a router for your network and you want finer control over it.
If any of those apply to you, read on. You’ll need to dive into the Command Prompt to add a static route to the Windows routing table, but it’s easy and we’ll walk you through the steps.
View the Windows Routing Table
Before you get started adding routes, it may be helpful to view the routing table first. Fire up Command Prompt or PowerShell by hitting Windows+X and then selecting «PowerShell (Admin)» or «Command Prompt (Admin) on the Power Users menu.
You’ll probably see PowerShell instead of Command Prompt in the Power Users menu. It is switch back to showing the Command Prompt if you want, or you can give PowerShell a try. You can do pretty much everything in PowerShell that you can do in Command Prompt, plus a lot of other useful things.
In the Command Prompt or PowerShell, type the following command and hit Enter:
route print
You’ll see a long list of network destinations and the gateways to which packets are forwarded when they are headed to that destination. Unless you’ve already added static routes to the table, everything you see here will be dynamically generated.
Add a Static Route to the Windows Routing Table
To add a static route to the table, type a command using the following syntax:
route add destination_network MASK subnet_mask gateway_ip metric_cost
The subnet_mask
and metric_cost
components are optional to the command. If you don’t specify a subnet mask, 255.255.255.0 will be used automatically. If you don’t specify a metric cost, a cost one greater than the 0.0.0.0 destination entry will be used. The metric cost value is just a cost that is relative to other costs in the table and is used when Windows decides between multiple routes that could reach the same destination.
So, for example, if you wanted to add a route specifying that all traffic bound for the 192.168.35.0 subnet went to a gateway at 192.168.0.2 and you just wanted to use the automatic metric cost, you would use the following command:
route add 192.168.35.0 MASK 255.255.255.0 192.168.0.2
If you were to use the route print
command to look at the table now, you’d see your new static route.
That’s all easy enough, but there is one extra little catch. When you add a static route, by default it only lasts until the next time you start Windows. The reason for this is that many companies use a coordinated list of static routes that gets updated fairly often. Rather than adding and updating all those routes on every machine, they just distribute a batch script file that adds the newest routes during Windows startup. This keeps the routing table relatively uncluttered.
You could certainly use the batch script method yourself. Writing batch scripts isn’t hard. But if you’re just adding one or two static routes that you don’t expect to change often, you can instead just add the -p
option to the command to make the route persistent. A persistent route stays in place even when Windows starts up. Using the same command we used earlier, you could make that route persistent with the following modification:
route -p add 192.168.35.0 MASK 255.255.255.0 192.168.0.2
Remove a Static Route from the Windows Routing Table
Of course, there will come a time you might want to remove a static route from your table. All you have to do is type a command using the following syntax:
route delete destination_network
So, to delete the route we created earlier with the destination network 192.168.35.0, all we’d have to do is type this command and hit Enter:
route delete 192.168.35.0
Yes, using static routes is a bit esoteric when it comes to managing most home and small business networks. But if you do need to do it, it’s a pretty easy process. And if you don’t need to do it right now, at least you know it’s an option in the future.
In this article, we will look at what a ‘static route’ is and why it should be added at all. We will use the so-called ‘Root’ — meaning we will prescribe routes using the ‘route add’ command in the Windows command line. Let’s recap the theory and in what cases using the ‘route add’ in this way may be useful for you.
‘Static routing’ is a type of routing in which routes are explicitly specified when configuring a router. All routing occurs without the participation of any routing protocols.
A ‘static route’ is an administrator-defined route causing packets that move between the source and destination to go along the specified path. It is an explicitly indicated path that a packet must travel from point A to point B.
Why do we need to be able to add static routes? It is very common for security to use Virtual Private Networks (VPN). VPNs are used both by organizations — for the organization of their secure networks — and by providers — to provide access to the global Internet to simple users. This sometimes causes minor inconveniences, however, to organizations and among ordinary users.
For example, if you have two computers at home, the first of which has access to the Internet via VPN, it is also connected to the second computer’s local network. Every time it connects to the Internet, the connection between the two computers is lost because the first computer (the one connected to the VPN) is already on another network and therefore unavailable to the second computer. This can be corrected just by configuring a static route.
Routes are network settings that are used by the operating system for organizing network traffic, as well as accessing the local network and the Internet. With help of the information on this page, you will learn how to view, delete, and add routes on a computer running a version of Windows — from XP to 10.
1. View Active Routes in Command Prompt Tool
To simply see the routing table on your computer, type the following at the command prompt Start ⇨ Run ⇨ cmd:
route print
2. How to Remove All Static Routes
This is done in the following way: run the command line and type the following command:
route -f
3. Add Static Route in Command Line Shell
To add a static IP route, in the command line running as administrator, enter the command:
route -p add 0.0.0.0 mask 0.0.0.0 192.168.95.1
Where:
route
— the program itself that works with the routing table;-p
is a key that says that the route will be permanent, because (Important note!) without this key, all routes that you add will be deleted after rebooting, so if you want to use the route always, write this key if only once, then you can not write;add
— the command itself that adds an entry to the routing table;0.0.0.0
— the network with which you want to have a connection;mask 0.0.0.0
— subnet mask;192.168.95.1
— the gateway address, usually the modem address.
4. How to Remove Specific Static Route
To remove static route open command line and type this command:
route delete 0.0.0.0 mask 0.0.0.0 192.168.95.1
How to Manage Static Route with Action1
The first thing you need to do is login to the Action1 dashboard.
Next, on the left side menu, select the Managed Endpoints item and mark the endpoint for which you want to block the port.
Then click on the More Actions button and select the Run Command option.
In the window that opens, enter the command route -p add 0.0.0.0 mask 0.0.0.0 192.168.95.1 to add a static route you need.
In case you need to delete a route use this command route delete 0.0.0.0 mask 0.0.0.0 192.168.95.1
After clicking the Next Step button, you need to select the endpoints for which you are going to add or remove static route. To do this, click Add Endpoints and select the desired endpoint.
Click Next Step and in the next step you can schedule the execution time of your command. Then click Finish.
Consider Using Action1 Cloud RMM Solution
Action1 allows IT professionals to efficiently manage configurations for computers within and outside the local network. In addition, the platform offers total control of patch management, software distribution, remote desktop, as well as many other features to run your IT security and administration as seamlessly as possible.
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.
Adding a static route in Microsoft Windows 10 or Server is done by using the route add
command.
The following is the general syntax of the route add
command we need to follow to add a permanent static route in Windows:
route add -p <destination> mask <subnet-mask> <gateway>
For example, the following route command tells the windows to add a new persistent route to the 192.168.1.0/24
network, using 10.0.0.1
as the gateway to reach the network.
route add -p 192.168.1.0 mask 255.255.255.0 10.0.0.1
When you want to add a static route to a single host, use the netmask 255.255.255.255
.
For example, the following command adds a static route to the destination host 192.168.1.100
with the gateway address 10.0.0.1
.
route add -p 192.168.1.100 mask 255.255.255.255 10.0.0.1
The most important part of the route add command is the -p
option. Without the -p
switch, our new route would not be persistent. It will disappear the next time you reboot your Windows PC/Server.
We can print the windows routing table using the route print
command. Under the Persistent Routes header, you will see the list of permanent static routes.
Following is another static route example with a metric value:
route add -p 192.168.1.0 mask 255.255.255.0 10.0.0.1 metric 5
In case if you have more than one network interface, you could also specify the interface ID using the if
command option.
route add -p 192.168.1.0 mask 255.255.255.0 10.0.0.1 if 1
When specifying the network interface, you have to provide the interface ID which you can find using the route print command.
Windows hold permanent static routes in the following registry
location: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi
.
ces\Tcpip\Parameters\PersistentRoutes