IP address Routing
Routing is one of the most important functions of IP addresses. Figure 1 shows a simple process of IP address layer processing.
Figure 1 IP layer Workflow
The information contained in the routing table determines all the decisions made at the IP layer. Steps for listing the IP address search route table:
- Search for matched host addresses;
- Search for matched network addresses;
- Search for default table items (the default table item is generally specified as a network Table item in the routing table, and its network number is 0 ).
Routing on the IP layer is actually a routing mechanism. It searches the route table and determines the network interface to which the group is sent. Routing policies are just a group of rules that decide which routes are put into the route table.IP address routing mechanism, and routing daemonProgramThe routing policy is provided.
What happens if no default item exists in the routing table and no matching item is found?
If the datagram is generated by the host, an error is returned to the application that sends the datagram, the host is not reachable, or the network is not reachable ". If the packet is forwarded, an error message that is inaccessible to the ICMP Host is sent to the original sender.
Only when the host can select a vro sending group can the ICMP redirection error message be seen (2):
- Assume that the host sends an IP datagram to R1 (R1 is the default route of the host );
- R1 receives the datagram and checks its route table. Sending R2 is the next stop to send the datagram. When it sends a datagram to R2, R1 detects that the interface it is sending is the same as the datagram arrival port (that is, the LAN of the host and the two routers );
- R1 sends an ICMP redirection packet to the host, telling it to send the datagram to R2 instead of R1.
Figure 2 ICMP redirection example
The recipient of the ICMP Redirect message must view three IP addresses:
- The IP address that causes redirection (that is, the data of the ICMP redirection packet is in the header of the IP datagram );
- The IP address of the router that sends the redirection packet (the source address in the IP datagram that contains the redirection information );
- The IP address of the router.
ICMP redirection packets can only be generated by routers, but not by hosts. In addition, redirect packets are used for the host rather than for the router.
In the 4.4 BSD system, the following conditions must be met before ICMP redirection packets are generated.:
- The outbound interface must be equal to the inbound interface;
- The route used for outbound data transmission cannot be created or modified by ICMP redirection packets, and cannot be the default route of the router;
- The datagram cannot be forwarded by the origin site;
- The kernel must be configured to send redirection packets.
Check the route table before the 4.4 BSD host receives the ICMP redirection packet.:
- The new router must be directly connected to the network;
- The redirection message must come from the router selected from the current destination;
- The host cannot be used as the router for redirect packets;
- The modified route must be an indirect route.
Note that the router should send only redirection to the host (Code1 or 3) instead of redirecting to the network.
How to initialize a route table:
- Specify a static route in the configuration file, which is generally used to set the default router;
- Use ICMP Router notifications and request packets.