Router routes traffic based on the longest prefix, and cannot find any match traffic will be dropped.
Classless routing
The routing that we normally understand is classless routing.
Let’s explore the routing tables of R1 and R2.
R1 pings to 10.10.10.2 because a specific static route 10.10.10.2 is in the routing table
R1 can ping to the above two addresses because the default route is matched. So classless routing is this:
- Find the route with the longest prefix.
- If there is no match in the longest prefix it will match the default route
Classful routing
ip classless is turned on by default. To demonstrate classful routing we need to turn off ip classless and ip cef.
Let’s revisit R1’s routing table. With classful routing, routing decision changes.
No problem with 10.10.10.2 because there is a specific match in the routing table.
No problem with 172.30.1.1 because there is no big networks 172.30.x.x in the routing table and it matches the default route.
Problem with 192.168.1.33, because there is a big network which says:
192.168.1.0/24 is variably subnetted, 4 subnets, 3 masks.
Now 192.168.1.33 is under 192.168.1.0/24 and because there is no specific route and it matches the big network the traffic is dropped due to no match is found. Router will not look into the default route when there is no match for 192.168.1.0/24.
From the debug it says 192.168.1.33 is unroutable. In this scenario specific route to 192.168.1.33 has to be added to the routing table.
So classful routing:
- matches route with the longest prefix same as the classless routing.
- if there is a big network, and there is no specific route to this big network the traffic is drop.
- If there is no longest prefix route, and the address is not under any big network then router consults the default route.