The command: "route" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available
The examples for the command "route"
The route command is used to view or modify the routing table of a Windows computer. Here are some examples of using the
"route" command:
### View routing table:
Example 1: View the entire routing table:
route print
This command shows the complete routing table including network interfaces, network addresses, gateway addresses and metrics.
Example 2: View the routing table for a specific destination host:
route print -4 192.168.1.1
This command shows the routing table for the specific destination host (here 192.168.1.1).
### Adding routes:
Example 3: Adding a static route:
route add 10.0.0.0 mask 255.0.0.0 192.168.1.1
This command adds a static route for network 10.0.0.0 with subnet mask 255.0.0.0 and gateway 192.168.1.1.
Example 4: Adding a persistent route:
route -p add 172.16.0.0 mask 255.255.0.0 192.168.1.1
This command adds a persistent static route for network 172.16.0.0 with subnet mask 255.255.0.0 and gateway 192.168.1.1. The
`-p` option makes the route persistent so that it is retained after a reboot.
### Deleting routes:
Example 5: Deleting a static route:
route delete 10.0.0.0
This command deletes the static route for network 10.0.0.0.
Example 6: Deleting all persistent routes:
route -p delete *
This command deletes all persistent routes. Be sure to use this with caution as it will remove any persistent routes.
### More options:
Example 7: Changing the metric of a route:
route change 192.168.1.0 mask 255.255.255.0 metric 10
This command changes the metric of the route for the 192.168.1.0 network to 10.
These examples are intended to give you an idea of ??how the
"route" command can be used in different scenarios. Depending on your specific needs and network settings, the parameters may vary. Use
`route/?` for a full list of options and parameters.
"route" Excerpt from Microsoft Windows Help
Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.
C:\\WINDOWS>
Manipulates network routing tables.
ROUTE [-f] [-p] [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.
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*.
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 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 PRINT
> route PRINT 157* .... Only prints those matching 157*
> 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 PRINT
> route DELETE 157.0.0.0
> route PRINT
Important information, tips for the "route" command
There are a few important points to keep in mind when using the `route` command, particularly with regard to security and network configuration:
### Security and Authenticity:
1. Access Rights: Note that modifying the routing table requires administrative privileges. Therefore, run the command with elevated privileges by opening Command Prompt as administrator.
2. Persistent Routes: When adding or deleting persistent routes (`route -p`), make sure you clearly understand the impact on network connectivity. Incorrectly configured persistent routes can cause network problems, especially after a reboot.
### Network configuration:
3. Correct use of options: Use the correct options and parameters for your needs. Incorrect configurations can lead to connection problems.
4. Validity of Routes: Ensure that the routes added make sense and are valid. Incorrect routing entries can lead to network connectivity errors.
### Error handling and monitoring:
5. Logging: When adding or modifying routes, carefully review the log data to ensure that the routes are configured correctly and there are no errors.
6. Network Latency Monitoring: For larger networks or routing table changes, it is important to monitor network latency to ensure that the changes do not result in significant performance issues.
### Route deletion:
7. Caution when deleting: When deleting routes (`route delete`), you should ensure that you delete the correct route to avoid network problems.
8. Existing connections: Note that deleting routes may affect existing network connections. It is advisable to do this outside of production times.
### Network Security:
9. Firewall Impact: Changes to the routing table may impact the firewall configuration. Make sure the firewall is configured appropriately to accommodate the new routes.
### General Considerations:
10. Backup: Before making any major changes to the routing table, create a backup of the current configuration. This allows for quick recovery in the event of problems.
11. Documentation: Maintain accurate documentation of all changes to the routing table so that you can keep track of them and revert to the previous configuration if necessary.
These points should help you use the `route` command safely and effectively. It is recommended that you make changes to the routing table carefully to avoid network problems.