Delete all persistent windows routes. Description of the ROUTE command

Command route displays the entire contents of the IP routing table and modifies the entries. Run without parameters, the route command displays help.

ROUTE Utility Options Syntax

route [-f] [-p] [command [endpoint] [gateway] ] ]

  • -f - Clears the routing table of all entries that are not node routes (routes with subnet mask 255.255.255.255), network loopback route (routes with endpoint 127.0.0.0 and subnet mask 255.0.0.0), or multicast route (routes with endpoint 224.0.0.0 and subnet mask 240.0.0.0). When this option is used in conjunction with one of the commands (such as add, change, or delete), the table is cleared before the command is executed.
  • -p - When using this option with the add command, the specified route is added to the registry and used to initialize the IP routing table each time the TCP/IP protocol is started.
  • command - Specifies the command to be run on the remote system. One of the following commands is allowed: PRINT- Print route, ADD- Adding a route, DELETE- Deleting a route, CHANGE- Changing an existing route.
  • end_point - Defines the end point of the route. The endpoint can be a network IP address (where the host bits in the network address are 0), the IP address of the route to the host, or the value 0.0.0.0 for the default route.
  • mask net_mask - Specifies the netmask (also known as the subnet mask) according to the destination. The netmask can be the subnet mask corresponding to the network IP address, such as 255.255.255.255 for the host route, or 0.0.0.0. for the default route. If this parameter is omitted, the subnet mask 255.255.255.255 is used. The endpoint cannot be more precise than the corresponding subnet mask. In other words, a bit value of 1 in an endpoint address is impossible if the value of the corresponding bit in the subnet mask is 0.
  • Gateway - Indicates the IP address of the hop or next hop, where the set of addresses defined by the endpoint and subnet mask is available. For locally connected subnet routes, the gateway address is the IP address assigned to the interface that is connected to the subnet. For remote routes that are reachable through one or more routers, the gateway address is the directly accessible IP address of the nearest router.
  • metric - Specifies an integer route cost metric (ranging from 1 to 9999) for a route that is used when selecting one of several routes in the routing table that most closely matches the destination address of the forwarded packet. The route with the smallest metric is selected. The metric reflects the number of hops, path speed, path reliability, path throughput, and administration tools.
  • if interface - Specifies the index of the interface through which the destination is accessible. Use the route print command to list the interfaces and their respective indexes. Interface index values ​​can be either decimal or hexadecimal. Enter 0x before hexadecimal numbers. In the case where the if parameter is omitted, the interface is determined from the gateway address.

Route Command Examples

  • route print;
  • To display routes from the IP routing table that start with 10., enter the command: route print 10.*;
  • route add 0.0.0.0 mask 0.0.0.0 192.168.12.1;
  • route add 10.41.0.0 mask 255.255.0.0 10.27.0.1;
  • route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1.

Video - Working with the ROUTE utility

· No comments

It's amazing how quickly time flies. People think real computers are very high tech, but the TCP/IP protocol has been around in one form or another for over three decades. He had enough time to mature and become stable and reliable. But when it comes to computers, nothing can be reliable. Trouble sometimes occurs when specifying routes for packets on a network. In these situations, you should be familiar with the Windows routing tables. They determine the flow of packets from the required machine. In the article, I will talk about how to view tables and how to understand them.

Viewing routing tables

Routing tables are an important part of the TCP/IP protocol in Windows, but the operating system doesn't show them to the average user. If you want to see them, you need to open a command prompt and enter the ROUTE PRINT command. After that, you will see a window similar to the one shown in Figure A.

PictureA: This is what the routing tables look like.

Before I dwell on the tables in more detail, I advise you to enter another command at the command line:

This shows the TCP/IP protocol installed on the computer. You can also look at the TCP/IP section in the properties of the network adapter, but the first way is preferable. I have often come across a situation where the IPCONFIG command outputs completely different data than the data entered in the TCP/IP properties. It doesn't happen often, but mistakes happen because of this disagreement. In other words, the data entered in the TCP/IP properties determines the protocol setting for the selected network. And the IPCONFIG command shows how Windows actually configured the protocol.

Even if there are no errors, it will be useful to check the configuration through the IPCONFIG command. If your computer has multiple network adapters, it's hard to remember which settings apply to which adapter. The IPCONFIG command lists the various settings in an easy-to-read format based on the network adapter, as shown in Figure B:

PictureB: IPCONFIG /ALL command shows all TCP/IP settings based on network adapter

Checking routing tables

You might be wondering why I asked for a TCP/IP command if the article is about routing tables? Yes, because no one looks at the tables unless there is a problem with the computer. And if there is a problem, it is best to start the troubleshooting process by comparing the information provided by the IPCONFIG command with the information in the routing tables.

As you can see in Figure B, the IPCONFIG /ALL command shows basic TCP/IP information: IP address, default gateway, and so on. Routing tables, however, are not so easy to read. That is why I would like to discuss the issue of reading data from tables.

To understand the information contained in the tables, it is necessary to understand how the router works. The job of a router is to direct traffic from one network to another. Therefore, a router can consist of multiple network adapters, each connected to a different network segment.

When a user sends a packet to a different network segment than the one to which the computer is connected, the packet is routed to the router. Then the router determines the segment to which this packet must be directed. It doesn't matter if the router is connected to two network segments or ten. The decision process for a router is the same and is based on routing tables.

Looking at the screen that appears after entering the Route Print command, you can see that the tables are divided into 5 columns. The first column is networks. It shows all network segments to which the router is connected. The Netmask column shows the subnet mask, not of the network interface to which the segment is connected, but of the segment itself. This allows the router to determine the address class for the destination network.

The third is the gateway column. After the router has determined the destination network to send the packet to, it checks against the gateway list. This list "tells" the router through which IP address to send the packet to the destination network.

The interface column provides information about the network adapter connected to the destination network. It would be more accurate to say that this column provides information about the IP address of the network adapter that connects the router to the destination network. But the router is smart enough to figure out what the address is assigned to.

The metric column comes last. Metrics is a rather complex topic, however, I will try to explain what they are. The best way to do this is to use an airport as an example. Imagine you need to fly from Charlotte, North Carolina to Miami, Florida. The airport in Charlotte is very large, and there are several ways to get to the beach in Miami. You can take a Northwest Airlines flight. It will take me to Detroit, Michigan and then to Miami (Detroit is a little off the beaten track). You can take a Continental Airlines flight through Houston, Texas and then to Miami. Or you can just use American Airlines and get to Miami without intermediate landings. So which flight should you take?

In reality, several factors can influence the choice: ticket price, departure time, etc. But let's assume that everything is the same. If there is no difference other than the route, then, of course, it is better to take a flight without intermediate landings. This route is the fastest and will also avoid communication problems, lost luggage, etc.

Routing works the same way. There are several routes for sending packets. In this case, it makes sense to send it along the shortest path. This is where metrics come into play. Windows does not use metrics as long as there is only one route to reach the destination. Otherwise, Windows checks the metrics to determine the shortest path. This is a simplified explanation, but it allows you to understand the principle of operation.

Additional routing options

I already mentioned the Route Print command, but there are many uses for the ROUTE command. Its syntax is the following:

Switch -f is optional. It tells Windows to clear the routing tables of gateway entries. If this switch is used in conjunction with other commands, then the gate items will be removed before other instructions contained in the command are executed.

Switch -R makes a particular route permanent. Normally, when the server is rebooted, any routes defined via the ROUTE command are removed. The -p switch specifies that the route should be saved even when the system is rebooted.

The command part in the ROUTE syntax is simple. It can consist of 4 options: PRINT, ADD, DELETE, and CHANGE. I already talked about the ROUTE PRINT command, but it may have options. For example, you can use special characters in a command. If you want to print routes for the 192.x.x.x subnet, you can use the ROUTE PRINT 192* command.

The ROUTE DELETE command works in the same way as ROUTE Print. Just type ROUTE DELETE followed by the destination or gateway to be removed from the routing table. For example, if you want to delete gateway 192.0.0.0, enter ROUTE DELETE 192.0.0.0.

All of the above applies to the ROUTE CHANGE and ROUTE ADD commands as well. When entering this command, you must specify the destination, subnet mask, and gateway. You can also specify metrics and an interface. For example, you can add a destination with simple syntax like this:

ROUTE ADD 147.0.0.0 255.0.0.0 148.100.100.100

In this command, 147.0.0.0 is the destination, 255.0.0.0 is the subnet mask for the destination, and 148.100.100.100 is the gateway address. You can extend the command with the METRIC and IF parameters:

ROUTE ADD 147.0.0.0 255.0.0.0 148.100.100.100 METRIC 1 IF 1

The metric parameter is optional, but it specifies the metric and number of hops for the route. The IF parameter tells Windows which adapter to use. In our case, Windows uses the network adapter that is associated with it as interface 1. If this parameter is not present, the best interface is used.

Conclusion

In this article, I talked about how to use the ROUTE command to display routing tables and make changes to them. If you need more help, you can get more examples by typing ROUTE /? command.

www.windowsnetworking.com


See also:

Exchange 2007

If you would like to read previous parts of this article series, please follow the links: Monitor Exchange 2007 with System Manager ...

Introduction In this multi-part article, I want to show you the process I recently used to migrate from an existing Exchange 2003 environment...

If you missed the first part of this series, please read the link Using the Exchange Server Remote Connectivity Analyzer Tool (Part...

If you missed the previous part of this article series, go to Monitor Exchange 2007 with System Center Operations Manager ...

Yesterday I encountered a small problem - 2 network cards, 2 providers are installed on a machine with Win2k3. The problem turned out to be the following: the subnets intersect (more precisely, they coincide). It was decided to use the 1st provider for the main gateway, and walk through the intranet resources through the 2nd one. And everything would be fine, but the machine must serve incoming connections from both interfaces. But, thanks to static routes, responses to requests from the 10.0.0.0/8 subnet, which came from the first provider, went through the channel of the second provider, which, to put it mildly, was not what was needed. How to solve this problem under linux - I knew (and I will also tell in this note). After a little googling, a solution was found (in msdn "e we stumbled upon connection priority management). A colleague (WAJIM, hello) thought - and found the 2nd option. Then I thought a little (quite a bit) - and by analogy, the 2nd solution for linux appeared: )
In total, under the cut you will find 4 options for solving the routing problem for 2 providers - 2 for Windows and 2 for Linux.

  • 2 physical firewalls that are also gateways (192.168.1.10 and 192.168.2.10)
  • 2 network interfaces (lan1 - 192.168.1.101 and lan2 - 192.168.2.101)
  • the desire to make this good work the way we need
Well...let's get started.
  • Windows
    • Network connection priority management:
      You need to create 3 routes:

      route -p add 10.0.0.0 mask 255.0.0.0 192.168.1.10 metric 1

      Next, go to Network connections -> Advanced -> Advanced settings, move lan2 up so that this connection is above lan1. Ready.

    • Again - create 3 routes. Just change the metrics
      route -p add 0.0.0.0 mask 0.0.0.0 192.168.1.10 metric 1
      route -p add 10.0.0.0 mask 255.0.0.0 192.168.1.10 metric 2
      route -p add 10.0.0.0 mask 255.0.0.0 192.168.2.10 metric 1

      And no dancing with interface priority. I consider this method to be the best.
      UPD: The metric of the interface with the highest priority (see previous point) must not be the lowest.
  • linux
    • Priority in the routing table:
      This is almost the same as in the previous paragraph (only the syntax is slightly different)

      route add -net 10.0.0.0/8 gw 192.168.1.10 metric 1
    • iproute2:
      Actually, this solution requires the iproute2 package to be installed. On debian, apt-get install iproute.
      In this case we need 2 routes
      route add default gw 192.168.1.10 metric 0
      route add -net 10.0.0.0/8 gw 192.168.2.10 metric 0

      Let's create 2 routing tables:
      echo "10 lan1" >> /etc/iproute2/rt_tables
      echo "11 lan2" >> /etc/iproute2/rt_tables

      Add routing rules to these tables:
      ip route add default via 192.168.1.10 table lan1
      ip rule add from 192.168.1.101 table lan1
      ip route add 127.0.0.0/8 dev lo table lan1

      Ip route add default via 192.168.2.10 table lan2
      ip rule add from 192.168.2.101 table lan2
      ip route add 127.0.0.0/8 dev lo table lan2


      The last rules are to ensure that packets from the local interface are not lost.
    Also, do not forget that Linux cleans up tables and routing rules on reboot, so I recommend creating a tricky script in the /etc/network/if-up.d folder. I have a script like this:
    #!/bin/sh -e

    Case "$IFACE" in
    eth1)
    ip route add default via 192.168.1.10 table lan1
    ip rule add from 192.168.1.101 table lan1
    ip route add 127.0.0.0/8 dev lo table lan1
    ;;
    eth2)
    route del default gw 192.168.2.101
    route add -net 10.0.0.0/8 gw 192.168.2.10 1
    ip route add default via 192.168.2.10 table lan2
    ip rule add from 192.168.2.101 table lan2
    ip route add 127.0.0.0/8 dev lo table lan2
    ;;
    esac


    UPD: corrected the shoals in the indication of the metric.
The choice is yours. Let me just say that it was decided to stop at the second options for both systems (changing the metric for windows and iproute2 for debian).
Who is interested in the topic of routing in Linux - I recommend reading this thing

Since we often have to set up VPNs on other people's machines and provide access to some resources of our network, and most often these are just specific machines, we need to write down a cheat sheet for adding static routes in the Windows OS family (XP/7/8/8.1). Everything is elementary and simple. Syntax

route [-f] [-p] [ command [end_point] [Gateway] ] ]

Options:

-f Clears the routing table of all entries that are not host routes (routes with a subnet mask of 255.255.255.255), a network loopback route (routes with an endpoint of 127.0.0.0 and a subnet mask of 255.0. dot 224.0.0.0 and subnet mask 240.0.0.0). When this option is used in conjunction with one of the commands (such as add, change, or delete), the table is cleared before the command is executed.

-p When this option is used with the add command, the specified route is added to the registry and used to initialize the IP routing table each time TCP/IP is started. By default, added routes are not saved when the TCP/IP protocol is started. When used as an option with the print command, prints a list of persistent routes. All other commands ignore this parameter. Persistent routes are stored in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes

command Specifies the command to be run on the remote system.

List of valid parameters.

Command Purpose
add Adding a route
change Change an existing route
delete Delete a route or routes
print Print the route or routes

end_point Specifies the end point of the route. The endpoint can be a network IP address (where the host bits in the network address are 0), the IP address of the route to the host, or the value 0.0.0.0 for the default route.

mask netmask Specifies the netmask (also known as the subnet mask) according to the destination. The netmask can be the subnet mask corresponding to the network IP address, such as 255.255.255.255 for the host route, or 0.0.0.0. for the default route. If this parameter is omitted, the subnet mask 255.255.255.255 is used. The endpoint cannot be more precise than the corresponding subnet mask. In other words, a bit value of 1 in an endpoint address is impossible if the value of the corresponding bit in the subnet mask is 0.

Gateway Specifies the forwarding or next hop IP address at which the set of addresses defined by the endpoint and subnet mask is available. For locally connected subnet routes, the gateway address is the IP address assigned to the interface that is connected to the subnet. For remote routes that are reachable through one or more routers, the gateway address is the directly accessible IP address of the nearest router.

metric metrics Specifies an integer route cost metric (ranging from 1 to 9999) for a route that is used when selecting one of multiple routes in the routing table that most closely matches the destination address of the forwarded packet. The route with the smallest metric is selected. The metric reflects the number of hops, path speed, path reliability, path throughput, and administration tools.

if interface Specifies the index of the interface through which the destination is accessible. To list the interfaces and their respective indexes, use the command route print. Interface index values ​​can be either decimal or hexadecimal. Enter 0x before hexadecimal numbers. In the case where the if parameter is omitted, the interface is determined from the gateway address.

Notes

  • Large values ​​in the metric column of the routing table are the result of TCP/IP's ability to automatically determine routing table route metrics based on the configuration of the IP address, subnet mask, and default gateway for each LAN interface. Automatic interface metric detection, enabled by default, sets the per-interface speed and per-interface route metrics so that the fastest interface generates the routes with the lowest metric. To remove large metrics, disable automatic interface metric detection in the advanced TCP/IP protocol properties for each LAN connection.
  • Names can be used for parameter end_point if there is a corresponding entry in the Networks database file located in the system_root\System32\Drivers\Etc. In parameter Gateway you can specify names as long as they resolve to IP addresses using the standard host resolution methods such as querying the DNS service, using the local , located in a folder system_root\system32\drivers\etc, or NetBIOS name resolution.
  • If the command is print or delete, the parameter Gateway is omitted and wildcard characters are used to specify the destination and gateway. Meaning endpoint can be a wildcard value, which is indicated by an asterisk (*). If there is an asterisk (*) or question mark (?) in an endpoint description, they are treated as wildcards and only the routes that match the destination are printed or removed. An asterisk matches any sequence of characters, and a question mark matches any single character. 10.*.1, 192.168.*, 127.*, and *224* are valid examples of using an asterisk as a wildcard.
  • Using an invalid combination of endpoint and subnet mask (netmask) values ​​results in the following error message: "Route: Invalid gateway address subnet mask." An error occurs when one or more of the bits in the endpoint address is 1 and the corresponding bits in the subnet mask are 1. To test for this condition, express the endpoint and subnet mask in binary. The subnet mask in binary format consists of a sequence of 1's representing the endpoint's network address portion and a sequence of 0's representing the endpoint's host address portion. Check for 1 bits in the part of the destination address that is the host address (as determined by the subnet mask).
  • The -p option is only supported on the route command on Windows NT 4.0, Windows 2000, Windows Millennium Edition, and Windows XP operating systems. This option is not supported by the route command on Windows 95 and Windows 98 systems.
  • This command is available only if the Internet Protocol (TCP/IP) is set as a component in the properties of the network adapter in the Network Connections object.

To display the entire contents of the IP routing table, enter the command:

To display routes from the IP routing table that start with 10. , enter the command:

To add a default route with default gateway address 192.168.12.1, enter the command:

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1, issue the command:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a permanent route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1, issue the command:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1 and cost metric 7, issue the command:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1 and interface index 0x3, issue the command:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3

To remove the route to endpoint 10.41.0.0 with subnet mask 255.255.0.0, issue the command:

route delete 10.41.0.0 mask 255.255.0.0

To remove all routes from the IP routing table that start with 10. , enter the command:

The Russian Internet is developing rapidly, more and more people are gaining access to the Global Network, communication channels are expanding, allowing more subscribers to connect. In megacities such as Moscow, St. Petersburg, Yekaterinburg, Nizhny Novgorod, etc., Internet connection via a local area network or DSL modems is widespread, and ordinary modems are practically not used anymore. In such networks, there is often a problem with routing, since there is a separation between the local segment and the Internet connection (the user receives a real external IP address). In this article, we will look at the most common utilities for working with network routing, which are included in the standard package of Windows-based operating systems.

Ping

The first utility, oddly enough, is the ping command. It allows you to determine the presence of a computer on the network, for which it sends an ICMP echo request to a remote computer. If the computer does not block incoming ICMP packets (this can be done, for example, by the built-in Windows Firewall), then the utility calculates the response time from the computer, and if several packets are sent, it displays summary statistics. Most internal routers don't block ICMP requests, of course, so you can use this command to determine which host is reachable. Let's consider this utility in more detail.

To call up help on possible keys for launching the ping command, you must add the /? key. Calling the ping utility is best done from the command line (cmd), which, in turn, can be called via Start -> Run ->cmd(in the Windows Vista operating system, the function Run located in the search bar, at the very bottom of the menu Start).

By default, the ping command sends four packets to the remote host and, based on the data received as a result of sending, returns statistical information. The statistics clearly show how many packets were lost and the average send time (response time) as a percentage, as well as the maximum and minimum values. In cases where significant packet loss occurs on the local network, it is best to use the ping command with the -t switch. When executing the utility with this key, packets will be sent continuously until the user terminates the utility. You can stop the utility by simultaneously pressing the common Ctrl + C key combination. To display current statistics without stopping the utility, use the Ctrl + Break key combination. In this case, packets will continue to be sent, and the user will receive summary statistics on packets already sent.

The ping utility also allows you to set the number of packets sent to the remote host. To do this, you need to execute the ping command with the –n x switch, where x is the number of packets to be sent. In turn, if possible, the -a switch allows you to determine the domain name of a remote computer if only its IP address is known.

In some cases, small packets reach a node, but a large packet is lost. By default, the ping utility sends packets with a buffer size of 32 bytes. This volume can be changed from 0 to 65,500. To do this, use the -l x key, where x is the number of bytes sent to the node.

The ping utility also allows you to set the TTL (time-to-live) field parameter of each packet. To do this, use the -i x key, where x is the packet lifetime in the range from 0 to 255. The ping command allows you to set the waiting time for the sent packet. To do this, you need to run the utility with the –w x option, where x is the timeout, which is specified in milliseconds and can have a practically unlimited value.

Now let's move on to the most important thing. The ping utility provides not only statistics on the number of packets sent/received, but also the approximate route of each packet. To do this, when starting the utility, you need to specify the -r x key, where x is the number of hops for the package. This value for this command ranges from 0 to 10. After executing this command, the statistics will contain hop information for each packet sent. The utility can also show a time stamp for each jump. To activate this function, you need to run the utility with the -s x option, where x can take values ​​from 1 to 4.

Most of the route display functionality in the ping utility depends on the response received: if no response is received from the pinged computer, the user will not see any information.

Note that IPv6-related commands are not covered here, as IPv6 is not widely used yet, although its support is included by default in all the latest operating systems.

Tracert

The next useful command is the tracert utility. It allows you to trace a route to a specific node. In terms of its functions, this utility differs from the ping command in that it can display real-time statistics and does not require a response from the computer. That is, tracing is carried out even if the computer is unavailable. The utility shows all the intermediate links that are encountered on the path of the package. In its statistics, this utility not only indicates the main nodes through which the route to a given computer passes, but also displays the average response time for each of the nodes.

Using this command is very simple: just write tracert ya.ru on the command line, where ya.ru can be any domain name or IP address. As additional options, you can specify the –d switch, which prohibits accessing DNS servers and matching the IP addresses obtained as a result of the command execution with domain names, which can significantly increase the speed of the program. Also, this utility allows you to select a route from the specified list, which must be in a file, for example txt. Among other things, for tracing a route, you can specify the time to wait for a response from the computer. The time is specified with the –w x parameter, where x is the timeout in milliseconds. There are other additional options for this utility, but they all refer to the new IPv6 protocol, which has not yet become widespread.

Pathping

This utility is a hybrid of the tracert and ping utilities. Its main difference from tracert is that it is somewhat faster, since it first sends requests to the remote node through which the route goes. In this case, an already known route is used, and a new one is not laid, as in the tracert utility. The tracert program, on the contrary, re-lays the route, which takes more time to collect statistics. The pathping utility first displays the hosts through which the packet passes to the desired computer, and then collects statistics on the response time from each host and on the access time to the remote host as a whole. Note that this utility comes with most Windows operating systems, but some, such as Windows XP Home, do not.

Otherwise, its parameters are no different from the keys described in the tracert utility. The –n switch specifies that the utility only works with IP addresses, ignoring the mapping through DNS names for each host. This option significantly increases the statistics collection time.

route

Finally, one of the fundamental routing utilities is the route command. With its help, the user can register, delete or edit all static routes on the computer used. To display the current routing table, run the route print command on the command line. As a result, all information about the current interfaces and the routing table will be displayed in the form of a table. Since we are only discussing IPv4 in this article, we will not focus on the routing table for IPv6.

For each of the routes, in addition to the destination and the gateway through which the packet from the computer enters the route, there is such a thing as a metric in the routing table. The metric allows you to create a priority among the same routes, depending on the connection interface used. For example, there is a VPN connection that exposes the computer to the Internet, and a local network connection. By default, in the Windows operating system, the priority, that is, the metric, of connecting to the VPN server has a lower value, which implies a higher priority for the packet to pass through. For a VPN connection, the route metric will be 25, and for a local connection it will be 200. Accordingly, if a packet cannot reach its destination when passing through the VPN channel, then it is sent over the interface that has a lower priority (metric).

Adding a route is done through the command:

route add ip mask gateway metric x if y,

where ip is the destination address or network, mask is the subnet mask, gateway is the gateway through which the packet will go to the destination, x is the numerical value of the route metric, y is the serial number of the interface. Here it is worth paying attention to some features. The gateway must be on the same subnet as the network adapter through which the connection is made. If a specific IP address is specified as the destination address, then the subnet mask can be omitted, since it will always look like 255.255.255.255. Note that adding the -p switch at the end of the line means that the route will be registered as a permanent one and will remain in the routing table even after a reboot. If the if interface is not specified, the system will try to determine the best interface for the added route.

Removing a route is done through the command:

route delete ip,

where ip is the destination address in the routing table.

The route is modified by the command:

route change ip mask gateway metric x if y,

where ip is the destination address or network, mask is the subnet mask, gateway is the gateway through which the packet will go to the destination, x is the numerical value of the route metric, and y is the serial number of the interface. Route modification can be performed only in case of changing the gateway and/or interface metrics.

The route print 192.* command will print all routes starting with the IP addresses 192.*.*.* You can also print routes related to, for example, the network 192.168.192.0/24 - route print 192.168.192.*

The route -f command is used to completely clear the routing table. However, you should not abuse it, because in most cases, after executing this command, your network will be unusable.

Static routing, an alternative to dynamic routing, is a process in which the system network administrator manually configured network routers with all the information needed to successfully forward packets. The administrator creates in each device, placing entries for each network that can be a destination. Static data paths for network routes are immutable.

Definition

Static is a network administrator-managed method of network routing that involves manually configuring and selecting a network route. Used in scenarios where the network settings and environment must remain constant.

Routing is one of the most important data transfer procedures. This ensures that data moves from one network to another at optimal speed and minimum latency, and that its integrity is maintained in the process.

Broadly speaking, routing is done in two different ways:

  • Dynamic - Periodically updates its routing table with paths and their cost/metric, making optimal decisions based on changing network operating conditions.
  • Static - Considered the simplest form of this process, it executes routing rules with preconfigured data paths in a table that can only be changed manually by administrators.

Static routes are usually used in situations where the choice is limited or there is only one path available by default. In addition, a static technique can be used if there are only a few devices to set up a route and there is no need to change it in the future.

Varieties of routing

The device can use three ways to learn routes:

    Static routing is a method by which an administrator manually adds information paths to a spreadsheet/database.

    Default routing is a technique where all routers are configured to send all packets along the same path. This is a very useful technique for small networks or for networks with a single point of entry and exit. It is usually used in addition to the static and dynamic methods.

    A dynamic technique is a method in which protocols and algorithms are used to automatically propagate routing information. This is the most common and most difficult method.

Protocol classification

Routing protocols are classified as Interior Gateway Protocols (IGP) or External Gateway Protocols (EGP). IGPs are used to exchange process information across internetworks that fall under a single administrative domain (also called autonomous systems). EGPs are used to exchange information between different autonomous systems. Common examples of IGPs are Routing Protocol (RIP), Extended Interior Gateway Protocol (EIGRP), and Open Shortest Path First (OSPF).

A routing protocol uses software and algorithms to determine the optimal transmission of network data and communication paths between network nodes. Also known as a routing policy. They greatly facilitate the interaction of routers, as well as the overall network topology.

Most (IP) use the following routing protocols:

    Routing Protocol (RIP) and Interior Gateway Routing Protocol (IGRP): Provides a process for interior gateways through route or distance vector protocols. RIP is used to determine the shortest path from a source to a destination. This allows you to transfer data at high speed in the shortest possible time.

    Open Shortest Path First (OSPF): Provides a process for internal gateways through link state routing protocols.

  • Border Gateway Protocol (BGP) v4: Provides a public routing protocol through external communication with the gateway.

How to Configure Cisco Static Routing

To configure a static route, the device must be in global configuration mode.

Command line code: ip route prefix mask(address|interface)[distance]. Let's explain the main components of the code:

    network — target network;

    mask is the subnet mask for this network;

    address - IP address of the next hop router;

    interface — equipment interface for outgoing traffic;

    distance — the administrative distance of the route.

Administrative distance is used to apply a sort of prioritization on static routes so that different paths to a given destination will follow a specific activation pattern. The administrative distance is an integer between 0 and 255, where 0 indicates the first priority path and 255 indicates that traffic cannot pass through this route. By default, the administrative distance of directly connected interfaces is 0, and 1 for static routes.

Static routing example:

ip route 10.0.0.0 255.0.0.0 131.108.3.4 110, where 10.0.0.0 is the destination network, 255.0.0.0 is the subnet mask, and 131.108.3.4 is the next hop for the router in use, 110 is the administrative distance.

An example of creating a static route

As an example of when a static route is required, consider the following case:

    Your primary Internet access is via a cable modem to an ISP.

    You have an ISDN router on your home network to connect to the company you work for. The address of this device on your local network is 192.168.1.100.

    Your company's network address is 134.177.0.0.

    When you configure cisco static routing, two implicit static routes are created.

    A default data path has been created with your ISP as the gateway, and a second static route is created on the LAN for all 192.168.1.x addresses. In this configuration, when an attempt is made to access a device on the 134.177.0.0 network, the router forwards the request to the ISP.

    In this case, you must define a static route, telling the instrument that 134.177.0.0 should be reachable through the ISDN router at 192.168.1.100.

    Static and dynamic routers

    To work effectively on the internetwork, routers must be aware of other identifiers or be configured using the default path. In large networks, routing tables must be maintained so that traffic always travels along the optimal paths. How spreadsheets are supported determines the difference between static and dynamic routing.

    Static Routing

    A device with manually configured routing tables is known to users as static. The network administrator, who owns the internetwork topology, manually creates and updates the information path table by programming all the routes. Static routers may work well for small internetworks, but do not scale to large or dynamically changing internetworks due to their manual administration.

    A good example of a static device is a Windows 2000 multihomed computer (a computer with multiple network interfaces). Creating static routing in Windows 2000 is as easy as installing a few network interface cards, configuring TCP/IP, and enabling IP routing.

    Dynamic Routing

    A device with dynamically configured tables is known as a dynamic device. Dynamic routing consists of tables that are created and maintained automatically through constant communication between devices. This message is facilitated by a routing protocol, a series of periodic or on-demand messages containing information exchanged between routers. Dynamic devices, other than their initial configuration, require little ongoing maintenance and can scale to larger internetworks.

    Dynamic routing is fault tolerant. Dynamic data paths received from other devices have a limited lifetime.
    The ability to scale and recover from internetwork errors makes this the best choice for medium to large internetworks.

    A dynamic technique is one that provides optimal data routing. Unlike static, dynamic allows routers to choose paths according to changes in the logical network in real time. In a dynamic process, the protocol running on the device is responsible for creating, maintaining, and updating the spreadsheet of data. In static routing, all these tasks are performed manually by the system administrator.

    The dynamic technique uses many different algorithms and protocols. The most popular are the Routing Protocol (RIP) and Open Shortest Path First (OSPF).

    Routing cost is a critical factor for all organizations. The least expensive technique for this process is provided by the dynamic technique, which automates table changes and provides the best paths for stable data transfer.

    The operations of the dynamic routing protocol can be explained as follows:

    • The router provides and receives messages on the interfaces of the device.

      The received messages and information are shared by other devices that use exactly the same protocol.

    Routers change routing information to discover information about remote networks. Whenever a device finds a topology change, the routing protocol makes the topology change on other devices.

    Dynamic Routing is easy to set up in large networks and is more intuitive in choosing the best path for information transfer, detecting changes, and discovering remote networks. However, as the routers exchange updates, they consume more bandwidth than in the static technique. The processors and operating system of the hardware may also experience additional workloads as a result of more complex protocols. Dynamic routing is less secure than static routing.

    Comparative analysis

    Cisco static routing is not a routing protocol. It is simply the process of manually entering routes into the device data spreadsheet through a configuration file that is loaded when the device starts up. Alternatively, these data paths can be entered by the network administrator who manually configures them. Because these manually configured routes do not change once they are configured, they are called static.

    A static technique is the simplest form of routing, but it is a painstaking manual process. Use this method when you have very few devices to configure (less than 5) and you are confident that the information paths will probably never change.

    The cisco packet tracer static routing also does not handle random outages on external networks because any route that is manually configured must be manually updated or reconfigured to fix or restore lost connections.

    Dynamic routing protocols are supported by software applications running on the receiving/transmitting device (router).

    A device using a dynamic technique learns routes for all networks that are directly connected to it. The router then learns data from other devices that run the same protocol (RIP, RIP2, EIGRP, OSPF, IS-IS, BGP). Each router then sorts the list of routes and chooses one or more best paths for each network destination.

    Dynamic routing protocols then propagate the received data to other devices running the same protocol, thereby expanding the knowledge of which networks exist and can be reached. This gives dynamic protocols the ability to adapt to changes in the logical network topology or static routing router failures.

    Advantages and disadvantages

    Static routing has the following advantages:

      No additional processing and additional resources, as in the case of dynamic routing protocols.

      No additional bandwidth requirements caused by the transmission of excessive packets for the routing table update process.

      Additional security is provided by manually entering or rejecting information transfer paths to certain networks.

      Setting up static routing is more secure.

      There is no overhead to use static routes. With dynamic network bandwidth is used to link available networks between routers. With static routes, because the network administrator encodes the data, devices do not need to send routing information.

      Static routing is easier to set up for a small network. Let's assume that you have only two devices and you need to set up communication between them. This requires only two route operators to be configured, one on each router. With a dynamic protocol such as RIP, for example, two network operators would have to be entered on each device.

      Static routes do not require any significant router resources. A dynamic routing protocol such as OSPF can be resource intensive to calculate the shortest path through a network when there are a large number of connected devices.

    The disadvantages include the following:

      Network administrators must be familiar with everything in order to properly configure data paths.

      Topology changes require manually configuring cisco packet tracer static routing for all devices, which is very time consuming.

      Static routes do not scale as the network grows. This is because they are all manually configured by the administrator.

      With a dynamic technique, there is no manual intervention and traffic is automatically routed whenever a network outage occurs. It is also quite scalable and easy to manage.

    What is the difference between static and dynamic routing?

    Static IP routing is when you statically configure a device to send traffic to specific destinations in pre-configured directions. The dynamic way is when you use a routing protocol such as OSPF, ISIS, EIGRP, and or BGP to figure out what type of traffic should go through. There are very few situations in the real world where only one of the two methods is used. A typical network will use dynamic OSPF to determine the best routes within the enterprise, BGP to determine the best exit points for the rest of the Internet, and static routing to send specific traffic over dedicated paths.

    IP addressing and routing: how does it work?

    Routers, in order to be able to forward packets to their final destination, must maintain a routing table that stores all the necessary information, containing a combination of networks and output interfaces.

    Each time a device receives a packet, it checks the destination IP address and tries to find by looking at its data spreadsheet a possible path for the information to reach that IP address. Routers do not send broadcasts looking for remote networks: if a network is not listed in the table, the instrument simply drops the packets.

    When to Use Default Routing

    Default routing is only used on stub networks. Stubs are networks that have only one exit interface, and everything passing through these networks must cross a single exit point.

    Instead of a large number of static routes pointing to remote networks through a single egress interface, a single default path is configured that matches all possible routes.

    Using administrative distances

    The default administrative distance for static routes is 1. AD is used for prioritization. Different routes in a particular target network can be assigned different weights so that one of the data paths is used in priority. Routes with the same weight load separate traffic.

Command route displays the entire contents of the IP routing table and modifies the entries. Run without parameters, the route command displays help.

ROUTE Utility Options Syntax

route [-f] [-p] [command [endpoint] [gateway] ] ]

  • -f - Clears the routing table of all entries that are not node routes (routes with subnet mask 255.255.255.255), network loopback route (routes with endpoint 127.0.0.0 and subnet mask 255.0.0.0), or multicast route (routes with endpoint 224.0.0.0 and subnet mask 240.0.0.0). When this option is used in conjunction with one of the commands (such as add, change, or delete), the table is cleared before the command is executed.
  • -p - When using this option with the add command, the specified route is added to the registry and used to initialize the IP routing table each time the TCP/IP protocol is started.
  • command - Specifies the command to be run on the remote system. One of the following commands is allowed: PRINT- Print route, ADD- Adding a route, DELETE- Deleting a route, CHANGE- Changing an existing route.
  • end_point - Defines the end point of the route. The endpoint can be a network IP address (where the host bits in the network address are 0), the IP address of the route to the host, or the value 0.0.0.0 for the default route.
  • mask net_mask - Specifies the netmask (also known as the subnet mask) according to the destination. The netmask can be the subnet mask corresponding to the network IP address, such as 255.255.255.255 for the host route, or 0.0.0.0. for the default route. If this parameter is omitted, the subnet mask 255.255.255.255 is used. The endpoint cannot be more precise than the corresponding subnet mask. In other words, a bit value of 1 in an endpoint address is impossible if the value of the corresponding bit in the subnet mask is 0.
  • Gateway - Indicates the IP address of the hop or next hop, where the set of addresses defined by the endpoint and subnet mask is available. For locally connected subnet routes, the gateway address is the IP address assigned to the interface that is connected to the subnet. For remote routes that are reachable through one or more routers, the gateway address is the directly accessible IP address of the nearest router.
  • metric - Specifies an integer route cost metric (ranging from 1 to 9999) for a route that is used when selecting one of several routes in the routing table that most closely matches the destination address of the forwarded packet. The route with the smallest metric is selected. The metric reflects the number of hops, path speed, path reliability, path throughput, and administration tools.
  • if interface - Specifies the index of the interface through which the destination is accessible. Use the route print command to list the interfaces and their respective indexes. Interface index values ​​can be either decimal or hexadecimal. Enter 0x before hexadecimal numbers. In the case where the if parameter is omitted, the interface is determined from the gateway address.

Route Command Examples

  • To display the entire contents of the IP routing table, enter the command: route print;
  • To display routes from the IP routing table that start with 10., enter the command: route print 10.*;
  • To add a default route with default gateway address 192.168.12.1, enter the command: route add 0.0.0.0 mask 0.0.0.0 192.168.12.1;
  • To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1, issue the command: route add 10.41.0.0 mask 255.255.0.0 10.27.0.1;
  • To add a permanent route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1, issue the command: route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1.

Video - Working with the ROUTE utility

Command route turns out to be very useful in diagnosing routing problems on servers and clients. For example, a client might have a static routing table configured to access a test network that is accessible from the organization's public network.

If the IP settings on the router that provides the client with access to the test network change, the static routes on the client computer will need to be changed accordingly. In an ideal world, all static routes are stored on a central router for centralized administration.

An example of using static routes is connecting a corporate network to branch offices using the Routing and Remote Access service running under the Windows Server 2003 operating system.

A router may have multiple interfaces that can be brought up on demand to support connections to remote networks. This information can be specified in the form of static routes that need to be followed. The route command allows you to view, delete, and add static routes to the system's routing table.

Here is the command syntax route:

Route [-f] [-p]

route command options

Parameter

Usage

Removes from the routing table all routes that are not routes to hosts. Host routes consist of the following routing entries: routes with a subnet mask of 255.255.255.255, routes with a destination of 127.0.0.1 and a subnet mask of 255.0.0.0, and multicast routes (a destination address in the range 224.0.0.0 to 240.0.0.0 ). If this option is used with the command add, change or delete, before executing the command, the routing table is cleared

Used to make a new or modified entry permanent. This means that the routing information is retained in the system even after a reboot. No parameter -p the route entered in the routing table will be deleted during the next system reboot

Adds a new route to the routing table.

Changes the current route in the routing table

Removes a route from the routing table

Displays the contents of the routing table

When adding or modifying a route, this parameter is used to specify the destination network ID

mask

When adding or modifying a route, this parameter is used to specify the subnet mask for the destination network

When adding or modifying a new route, this parameter is used to specify the gateway (router) to which data destined for this destination network should be sent.

metric

Used to specify an integer between 1 and 9999 that is the cost metric for the route. If there are multiple possible routes for a particular destination network, the route with the lowest metric value will be used.

if

Used to specify the index number of the interface that is connected to the destination network. The list of available interfaces can be viewed using the command route print. The interface index number can be specified in decimal or hexadecimal form. When using the hexadecimal form, the index value must be specified after 0x

The route command is used in several diagnostic scenarios. Here are some examples of using this command.

  • Displaying the system routing table: route print
  • Displaying all routes to the 172.16.x.x network: route print 172.16.x.x
  • Adding a route for all networks of unknown networks using the gateway at 172.19.67.1: route -p add 0.0.0.0 mask 0.0.0.0 172.19.67.1
  • Adding a route for network 10.2.84.0 through router 10.2.75.1: route -p add 10.2.84.0 mask 255.255.255.0 10.2.75.1
  • Removing a static route from the routing table: route delete 172.16.12.0 mask 255.255.0.0

Displays and modifies entries in the local IP routing table. Run without parameters, the command route outputs a certificate.

Syntax

route [-f] [-p] [command [end_point] [mask netmask] [Gateway] [metric metrics]] [if interface]]

Options

-f Clears the routing table of all entries that are not host routes (routes with a subnet mask of 255.255.255.255), a network loopback route (routes with an endpoint of 127.0.0.0 and a subnet mask of 255.0. dot 224.0.0.0 and subnet mask 240.0.0.0). When using this option in conjunction with one of the commands (such as add, change or delete) the table is cleared before the command is executed. -p When using this option with the command add the specified route is added to the registry and used to initialize the IP routing table each time the TCP/IP protocol is started. By default, added routes are not saved when the TCP/IP protocol is started. When using a parameter with a command print displays a list of permanent routes. All other commands ignore this parameter. Persistent routes are stored in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes command Specifies the command to be run on the remote system. The following table provides a list of valid options. end_point Specifies the end point of the route. The endpoint can be a network IP address (where the host bits in the network address are 0), the IP address of the route to the host, or the value 0.0.0.0 for the default route. mask netmask Specifies the netmask (also known as the subnet mask) according to the destination. The netmask can be the subnet mask corresponding to the network IP address, such as 255.255.255.255 for the host route, or 0.0.0.0. for the default route. If this parameter is omitted, the subnet mask 255.255.255.255 is used. The endpoint cannot be more precise than the corresponding subnet mask. In other words, a bit value of 1 in an endpoint address is impossible if the value of the corresponding bit in the subnet mask is 0. Gateway Specifies the forwarding or next hop IP address at which the set of addresses defined by the endpoint and subnet mask is available. For locally connected subnet routes, the gateway address is the IP address assigned to the interface that is connected to the subnet. For remote routes that are reachable through one or more routers, the gateway address is the directly accessible IP address of the nearest router. metric metrics Specifies an integer route cost metric (ranging from 1 to 9999) for a route that is used when selecting one of multiple routes in the routing table that most closely matches the destination address of the forwarded packet. The route with the smallest metric is selected. The metric reflects the number of hops, path speed, path reliability, path throughput, and administration tools. if interface Specifies the index of the interface through which the destination is accessible. To list the interfaces and their respective indexes, use the command route print. Interface index values ​​can be either decimal or hexadecimal. Enter before hexadecimal numbers 0x. In the case when the parameter if omitted, the interface is determined from the gateway address. /? Displays help on the command line.

Notes

  • Large values ​​in a column metric routing tables are the result of TCP/IP's ability to automatically determine routing table route metrics based on the configuration of the IP address, subnet mask, and default gateway for each LAN interface. Automatic interface metric detection, enabled by default, sets the per-interface speed and per-interface route metrics so that the fastest interface generates the routes with the lowest metric. To remove large metrics, disable the automatic detection of the interface metric in the advanced properties of the TCP/IP protocol for each LAN connection.
  • Names can be used for parameter end_point if there is a corresponding entry in the Networks database file located in the system_root\System32\Drivers\Etc. In parameter Gateway names can be specified as long as they resolve to IP addresses using standard host resolution methods such as querying the DNS service, using the local Hosts file located in the system_root\system32\drivers\etc, or NetBIOS name resolution.
  • If the command is print or delete, parameter Gateway is omitted and wildcard characters are used to specify the destination and gateway. Meaning endpoint can be a wildcard value, which is indicated by an asterisk (*). If there is an asterisk (*) or question mark (?) in an endpoint description, they are treated as wildcards and only the routes that match the destination are printed or removed. An asterisk matches any sequence of characters, and a question mark matches any single character. 10.*.1, 192.168.*, 127.*, and *224* are valid examples of using an asterisk as a wildcard.
  • Using an invalid combination of endpoint and subnet mask (netmask) values ​​results in the following error message: "Route: Invalid gateway address subnet mask." An error occurs when one or more of the bits in the endpoint address is 1 and the corresponding bits in the subnet mask are 1. To test for this condition, express the endpoint and subnet mask in binary. The subnet mask in binary format consists of a sequence of 1's representing the endpoint's network address portion and a sequence of 0's representing the endpoint's host address portion. Check for 1 bits in the part of the destination address that is the host address (as determined by the subnet mask).
  • Parameter -p is supported in the route command only on Windows NT 4.0, Windows 2000, Windows Millennium Edition, and Windows XP operating systems. This option is not supported by the command route on Windows 95 and Windows 98 systems.
  • This command is only available if the network adapter properties in the Network Connections object have the option set as a component. Internet protocol (TCP/IP).

Examples

To display the entire contents of the IP routing table, enter the command:

route print

To display routes from the IP routing table that start with 10. , enter the command:

route print 10.*

To add a default route with default gateway address 192.168.12.1, enter the command:

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1, issue the command:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a permanent route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1, issue the command:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1 and cost metric 7, issue the command:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

To add a route to endpoint 10.41.0.0 with subnet mask 255.255.0.0 and next hop address 10.27.0.1 and interface index 0x3, issue the command: