The best route is the longest match route to the destination IP address. The route lookup process matches the destination IP address with the route available in the routing table and chooses the longest match route as forwarding route.
To match the destination IPv4 address of a packet with the routes in the routing table; the minimum number of far-left bits must match between the IPv4 address of the packet and the route in the routing table.
The router fined the best route in the routing table for the packet using the subnet mask. The data packet never contains the subnet mask in the packet header.
The best route is the longest match or greatest number equivalent far left bits. The figure below illustrates the maximum bits match, which is the best route for the packet.
If the router receives a packet destined for 172.16.2.100. The router has three possible routes for the packet: 172.16.0.0/16, 172.16.1.0/24 and 172.16.2.0/24. Look it the table above in the figure to understand the longest matches routing process.
172.16.2.0/24 has the longest match; so the router has selected this route as the best route and forwards the packet to Ethernet 1/1. For any of these routes to be considered a match there must be at least the number of matching bits indicated by the subnet mask of the route.
Routing Table Terms
The Cisco IP routing table is a hierarchical structure that is used to speed up the lookup process when locating routes and forwarding packets. Within this structure, the hierarchy includes:
- Ultimate route
- Level1 route
- Level1 parent route
- Level2 child routes
This route contains either a next-hop IPv4 address or an exit interface. Directly connected routes dynamically learned routes, and local routes are also ultimate routes. The figure below illustrates the ultimate routes.
Level 1 Route
The route that is equal to a subnet mask or less than the classful mask of the network address. The source of the level 1 route can be a directly connected network, static route, and also a dynamic routing protocol. Therefore, a level 1 route is also the ultimate routes. The type of level 1 route included:
- Network route– A route that has subnet mask equal to the classful network is called network route.
- Default route– This is a static route for the packet whose destination is not known to the router. The address of the default static route is 0.0.0.0/0.
- Supernet route– This route with network address with a maskless than the classful mask.
Level 1 Parent Route
Level 1 parent route is a level 1 network route that is subnetted. A parent route can never be an ultimate route. The figure below illustrates the level 1 parent route highlighted.
The level 1 parent route is the heading for the specific subnets. Each entry of the level 1 parent route displays the classful network address, the number of subnets and the number of different subnet masks.
Level 2 Child Route
This is a subnet of a classful network address. As illustrated in Figure 1, a level 1 parent route is a level 1 network route that is subnetted. A level 1 parent routes contain level 2 child routes, as shown in the Figure below.
There are two levels 2 child route for level 1 parent route 10.0.0.0 and three levels 2 child route for level 1 parent route 172.16.0.0. The source of a level 2 route can be a directly connected network, a static route, or a dynamically learned route. Level 2 child routes are also ultimate routes.
Route Lookup Process
When a router receives a packet on an interface, the router examines the header of the packet and identifies the destination IPv4 address, and proceeds through the router lookup process.
- The router examines level 1 route, as well as network routes and supernet routes; for the best match with the destination address of the IP packet.
- If the best match is a level 1 route, ultimate route, or supernet route then the packet is forward to the destination using the best match route.
- If the best match is a level 1 parent route, continue to the next step.
- The router examines level 2 child routes of the level 1 parent route for the best match.
- If there match with a level 2 child routes found, the router forwards the packet to the destination using this route.
- If no match is found with any of the level 2 child routes, continue to the next step.
- the router starts lookup best match in level 1 supernet routes in the routing table, including the default route.
- If there is now a smaller match with a level 1 supernet or default routes; the router uses that route to forward the packet.
- If a match to the destination not found with any route in the routing table, the router drops the packet.