Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
In network management, the ability to control and manipulate routing tables is crucial for ensuring efficient data flow. The route add
command is a powerful tool in Windows that allows system administrators to add static routes to the routing table. This is particularly important for directing traffic through specific gateways, optimizing network performance, and troubleshooting connectivity issues. In this article, we will discuss how to use the route add
command in Windows, its significance, and provide practical examples to illustrate its usage.
Examples:
Basic Syntax of route add
Command:
The basic syntax for the route add
command in Windows is as follows:
route add [destination] MASK [subnet mask] [gateway] [metric] IF [interface]
destination
: The destination network or host.MASK [subnet mask]
: The subnet mask for the destination.gateway
: The gateway through which the destination network can be reached.metric
: (Optional) The metric or cost for the route.IF [interface]
: (Optional) The interface index to use.Adding a Simple Route:
To add a route to the network 192.168.2.0
with a subnet mask of 255.255.255.0
through the gateway 192.168.1.1
, you can use the following command:
route add 192.168.2.0 MASK 255.255.255.0 192.168.1.1
Adding a Route with a Specific Metric:
To add the same route with a specific metric value of 5
, the command would be:
route add 192.168.2.0 MASK 255.255.255.0 192.168.1.1 METRIC 5
Adding a Persistent Route:
By default, routes added with the route add
command are not persistent and will be removed after a system reboot. To make a route persistent, use the -p
flag:
route -p add 192.168.2.0 MASK 255.255.255.0 192.168.1.1
Specifying an Interface:
To add a route specifying a particular network interface, use the IF
parameter. First, find the interface index using the route print
command, then add the route:
route add 192.168.2.0 MASK 255.255.255.0 192.168.1.1 IF 2
Viewing the Routing Table: To view the current routing table and verify the added routes, use:
route print
Deleting a Route:
If you need to remove a route, use the route delete
command followed by the destination network:
route delete 192.168.2.0