Lesson Contents
When Cisco routers have to forward packets, they will check their routing table and they use longest prefix matching to find the best match. If you don’t have a best match then the router will use a default route (if you have one). Otherwise, the packet will be dropped.
The forwarding behavior that I described above is called classless routing and it has been the default since IOS 11.3. This is an ancient version, it went end-of-sale around 1998 so classless routing is the only thing that most people know about nowadays.
The other method is called classful routing and it works slightly different. Instead of trying to explain this with text it’s better to see it in action with some examples.
To demonstrate the difference between classless and classful routing I will use the following topology:
R2 has four loopback interfaces that we will try to reach from R1. To do this, we’ll use some static routes on R1. Let’s take a look at the configuration…
Configuration
Classless Routing
Let’s start with the default mode, classless routing. Here’s what the routing table of R1 looks like:
R1#show ip route static
172.16.0.0/24 is subnetted, 2 subnets
S 172.16.0.0 [1/0] via 192.168.12.2
S 172.16.1.0 [1/0] via 192.168.12.2
S* 0.0.0.0/0 [1/0] via 192.168.12.2
We have three static routes. Let’s try to ping each loopback interface on R2:
R1#ping 172.16.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/28/68 ms
This ping works because we have a specific 172.16.0.0 /24 route in the routing table. Let’s try 172.16.1.2:
R1#ping 172.16.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/30/80 ms
This ping also works because we have a specific 172.16.1.0 /24 route in the routing table. Let’s try 172.16.2.2:
R1#ping 172.16.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/30/72 ms
This ping works, there is no specific entry for it in the routing table but we can use the default route for it. Last but not least, let’s try 10.10.10.2:
R1#ping 10.10.10.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/33/72 ms
This ping also works because of the default route. So far everything is working as expected. Now let’s take a look at classful routing.
Classful Routing
First we have to disable classless routing on R1:
R1(config)#no ip classless
Also to make this work, you have to disable CEF (Cisco Express Forwarding):
R1(config)#no ip cef
Now we are ready for some tests. First of all, let me show you the routing table again:
R1#show ip route static
172.16.0.0/24 is subnetted, 2 subnets
S 172.16.0.0 [1/0] via 192.168.12.2
S 172.16.1.0 [1/0] via 192.168.12.2
S* 0.0.0.0/0 [1/0] via 192.168.12.2
Nothing has changed in the routing table, it’s exactly the same. Only the forwarding decisions of the router have changed. Let’s try those pings again:
R1#ping 172.16.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/24/60 ms
R1#ping 172.16.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/32/56 ms
The first two pings are successful because we have two matching entries in the routing table: 172.16.0.0 /24 and 172.16.1.0 /24. Before I try a ping to 172.16.2.2, let’s enable a debug:
R1#debug ip packet
IP packet debugging is on
Now let’s try that ping:
R1#ping 172.16.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.2.2, timeout is 2 seconds:
Success rate is 0 percent (0/5)
This ping doesn’t work anymore and this is what the debug tells us:
Rene,
Hello, thanks for the explanation of this, it is nice to finally have an understanding of this command.
Chris
Hi Rene,
Great explanation but I think it should be 172.16.0.0/16 is subnetted, 2 subnets rather than /24.
correct me if i am wrong.
Hello Kapil
It is true that the 172.16.0.0 subnet is a class B address, and thus in clasful IP addressing it would have a prefix of /16 rather than /24. However, classless and classful routing should not be confused with classless and classful addressing or routing protocols.
Having said that, it can be confusing when the routing table states that:
F
... Continue reading in our forumThanks for the explanation … I think now I get it I have never worked on 12.X version of the IOS as it was already out of date by the time i started learning networking. So I thought it is weird.
Extremely detailed answer. Thanks again
Nice explanation Rene’. Makes perfect sense.
One comment about the configs for R1. I don’t see the static default route in the config.