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.
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.
The `route add` command in CMD is used to manually add a route to the local routing table, allowing you to specify the destination network, subnet mask, and gateway for packet routing.
route add <destination> MASK <subnet_mask> <gateway> [metric <metric>] [IF <interface_index>]
Replace `<destination>`, `<subnet_mask>`, `<gateway>`, `<metric>`, and `<interface_index>` with the specific values for your network configuration.
Understanding Networking Basics
What is Networking?
Networking refers to the practice of connecting computers and other devices to share resources and information. At the core of networking are components such as switches, routers, and protocols that work together to facilitate communication. Understanding basic networking concepts is essential as it provides the foundation for effectively managing and troubleshooting network connections.
What are Routes?
A route is a path that network packets follow to reach their destination. Routing enables data to travel across networks, guiding information on the most efficient paths. Configuring routes correctly is crucial for maintaining optimal network performance, minimizing latency, and ensuring reliable connectivity.
Mastering Ip Route Cmd: A Quick Reference Guide
What is the `route` Command?
Introduction to the `route` Command
The `route` command is a tool available in Command Prompt (cmd) used to view and modify the IP routing table on a Windows operating system. The routing table holds essential information about how data packets should be directed through the network. Common use cases for the `route` command include adding, deleting, and modifying routing entries.
Syntax of the `route add` Command
The syntax for the `route add` command is as follows:
route ADD destination MASK subnet_mask gateway metric
This structure allows users to specify various parameters to define how the command should execute, detailing where the route leads and which gateway to utilize.
Trace Rout Cmd: Mastering Your Network Path in Cmd
How to Use the `route add` Command
Basic Command Structure
To effectively use the `route add` command, it’s vital to understand the role of each parameter:
- destination: This is the IP address or hostname of the target route. It represents where the data is intended to go.
- subnet_mask: This defines the range of addresses contained in the destination network. A mask of `255.255.255.0` often indicates a class C subnet, usable for smaller networks.
- gateway: This specifies the next-hop IP address through which packets will travel en route to the destination. It’s crucial that this address be reachable on the local network.
- metric: An optional parameter that specifies the cost of using the route, allowing for priority between multiple routes.
Example of Basic Usage
Here’s an example of adding a basic route using the `route add` command:
route ADD 192.168.1.0 MASK 255.255.255.0 192.168.1.1
Explanation: The command above creates a route for the IP range `192.168.1.0` with a subnet mask of `255.255.255.0`, routing traffic through the gateway `192.168.1.1`. This command is particularly useful for directing packets within a local area network (LAN).
Mastering the Route Cmd Command in Minutes
Advanced Routing Scenarios
Using Metrics
Importance of Metrics
Metrics play a vital role in route selection by indicating the “cost” associated with using a particular route. Lower metrics are preferred over higher ones. For instance, if you have two routes to the same destination, the system will choose the one with the lower metric.
Example Usage of Metrics
route ADD 10.0.0.0 MASK 255.255.255.0 10.0.0.1 METRIC 5
In this example, the command adds a route to the IP range `10.0.0.0` using `10.0.0.1` as the gateway, with a metric of `5`.
Adding Persistent Routes
What are Persistent Routes?
Persistent routes are routes that remain in the routing table even after a reboot. Having persistent routes can be beneficial for ensuring consistent and reliable routing configurations.
Command to Add a Persistent Route
To add a route that persists across reboots, use the `-p` switch:
route -p ADD 192.168.2.0 MASK 255.255.255.0 192.168.2.1
This command ensures that the route to `192.168.2.0` is maintained in the routing table after a system restart.
Mastering Cmd Route Print for Networking Insights
Viewing and Modifying Routes
Viewing the Current Routing Table
To view the routing table entries that are currently configured, the following command can be used:
route PRINT
This command provides a detailed list of all routes, including the destination, mask, gateway, and metric, allowing users to verify current configurations.
Modifying Existing Routes
If you need to change an existing route, use the `route CHANGE` command:
route CHANGE 192.168.1.0 MASK 255.255.255.0 192.168.1.254
This example modifies the route for `192.168.1.0`, directing traffic to a new gateway, `192.168.1.254`.
Deleting a Route
To delete a route from the routing table, you can use the `route DELETE` command:
route DELETE 192.168.1.0
This command effectively removes any route entries associated with `192.168.1.0`, ensuring that data packets will no longer be directed through that path.
Add User Cmd Windows 10: Your Quick Start Guide
Common Errors and Troubleshooting
Common Errors with `route add`
Users may encounter common errors when using the `route add` command, such as:
- Mismatched subnet masks: Ensure that the subnet mask accurately represents the route being added.
- Incorrect gateway address: Verify that the specified gateway is reachable; otherwise, packets will be dropped.
How to Troubleshoot with CMD
To troubleshoot routing issues, utilize cmd tools like `ping` and `tracert`. The `ping` command tests connectivity to a specific IP address, while the `tracert` command displays the route packets take to reach a destination, pinpointing any potential bottlenecks or failures.
Mastering The Startup Cmd: A Quick Guide
Conclusion
The `add route cmd` command is an invaluable tool for effectively managing network configurations. By mastering how to add, modify, and delete routes, users can significantly enhance their network efficiency and reliability. Practice using these commands and explore further resources to deepen your understanding of command prompt functionalities related to networking.
Sometimes you need to create static route entries to make communication with different networks that are connected via a different gateway. A gateway is simply a network router that routes the network traffic between different networks. When you have more than one gateway (router) on your network, then you may need to implement static route technique on Windows 10/Windows 11 or Windows servers/any Operating system.
A static route will tell the Operating System to send network packets to the appropriate router instead of sending them to the default router. This simple guide shows how to add, delete and modify a static route to the routing table on Windows 11/10 and Microsoft Server Operating Systems.
There are a few useful commands you must know. Route delete, add and print. These commands will be handy to any user who has administrative access and know which router/gateway should be used for which network.
Why Add Static Route?
It mostly depends on the network setup. Usually, you can add these static routes on your default router (if it can support) or core switch. When you have this kind of proper network setup, you do not need to add a static route to each computer separately on the network. But in a few exceptional cases, you may need to implement static routes on individual computers. Here are a few examples.
- You have more than one internet router on the network and you need to send traffic to certain websites (based on their IP addresses) via a different router than the default gateway. Let’s say, for example, all traffic to Netflix can be sent via the 2nd internet router where other website traffic can go through the 1st internet router.
- There are several VLANs or subnets available on the network. Before building the proper routing table on the router or core switch, adding a static route on your Windows computer will help you to test the connectivity see the traffic flow.
- For network security or isolation purpose, certain routes can’t be added to the default gateway device. In this case, as a network administrator, you can add the static route on a local computer to make network communication.
Route Add on Windows 11/10 and Windows Servers
Though there are major changes and interface upgrades in the latest Windows 11, the below steps remain the same.
Make sure you run the below commands on command prompt (or PowerShell) which is opened as Administrator.
Here is the command to add a static route to the routing table.
route ADD destination_network MASK subnet_mask gateway_ip metric_cost
route add 10.10.10.0 mask 255.255.255.0 10.10.29.1
It indicates that any packets to 10.10.10.0 (in class C – 255.255.255.0) network should be forwarded to the 10.10.29.1 router (gateway).
Obviously, the PC/server in which we run this command is in the 10.10.29.0/24 network because it should communicate to the gateway from the same network.
The issue with the above command is when you shut down or restart the computer, these route entries will be removed. To make it permanent and add to the Windows OS routing table, we should use the –p key with the add command. So, adding a persistent (or permanent) static route on Windows 10 command will be like this;
route add –p 10.10.10.0 mask 255.255.255.0 10.10.29.1
Route Print
Route print command is another useful command to view the entries on the routing table and which routes are active at the moment. If you need to modify an entry that is already in the routing table, better to confirm the entries before changing. To do it, use the route print command.
Route print
Also, we can view the persistent routes in a Windows OS by checking the following registry path. Look for the entries in this area before or after modifying any routing table entries.
HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet-> Services->Tcpip->Parameters->PersistentRoutes
Route Delete on Windows 11/10 & Windows 2022/2019/2016 Servers
The below command is to delete an existing persistent route from a computer. Even though we added a route entry with the network, network mask and gateway, but to delete, we need to mention the network only. So, it goes like this;
route delete 10.10.10.0
That will delete the 10.10.10.0 route entry from the computer. You do not need to restart the computer to take effect. Adding and deleteting route entries take effect instantly.
Let’s say that after the recent network change, now the network 10.10.10.0 should be routed through the 10.10.29.200 gateway. Obviously, you have to modify the existing route for this network and change the gateway to 10.10.29.200.
So, how to modify the existing route entry? You can’t modify an existing entry.
The simple method is to delete it and add the new entry. So, in this case, you would perform the below commands.
Route delete 10.10.10.0 Route add –p 10.10.10.0 mask 255.255.255.0 10.10.29.200
We hope this simple guide is helpful in understanding the route add, delete and print commands in Windows 10/Windows 11 client PC and other server Operating Systems. Make sure you open the command prompt or PowerShell as Administrator to perform these commands. If you want to use cosmetic variables to identify the fast hops to reach a network, you can use the metric key as described at the Microsoft site here.
Для добавления статического маршрута в Windows, необходимо в командной строке (Пуск –> Выполнить или Ctrl+R) набираем команду
route ADD -p 10.10.0.101 MASK 255.255.255.0 192.168.1.1 METRIC 1
и нажимаем «Enter»
Пояснения:
route программа работы с маршрутами;
ADD – команда для добавления маршрута на указанный адрес. У нас на 10.1.1.1;
-p – этот ключ нужен, что бы сохранить маршрут. Если его не прописать, то после перезагрузки таблица маршрутов обносится;
10.10.0.101 – адрес назначения;
MASK – маски сети;
192.168.1.1 – адрес основного шлюза. Чаще всего это ip-адрес модема;.
METRIC 1 – параметр, определяющий приоритет указанного выше шлюза. 1- наивысший приоритет.
Проверить прописанные маршруты можно командой route print. Для этого заходим в командную строку (Пуск –> Выполнить –> cmd –> Ok). В открывшемся окне набираем команду route print
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