Cisco IP Classless Command

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:

R1#show ip route static
<strong>172.16.0.0/24 is subnetted, 2 subnets</strong>
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

For reference purposes, keep in mind that the bold line above is called a parent route, and the two lines below it are child routes.

It seems like what it is saying is that the 172.16.0.0/24 network is being subnetted into 2 subnets. That should mean that the prefix of the parent route should be smaller than that of the child routes. But here, both the parent and child prefixes are the same size (/24). Let’s experiment a bit. I tried creating different routing tables and found the following:

  1. When the child subnets are the same size, the prefix of the child subnets is indicated in the parent route:
Router#show ip route
Gateway of last resort is not set
     172.16.0.0/24 is subnetted, 3 subnets
C       172.16.1.0 is directly connected, Loopback1
C       172.16.2.0 is directly connected, Loopback2
C       172.16.32.0 is directly connected, Loopback3
Router#

Similarly in this example:

Router#show ip route
Gateway of last resort is not set
     10.0.0.0/25 is subnetted, 3 subnets
C       10.10.10.0 is directly connected, Loopback10
C       10.10.11.0 is directly connected, Loopback11
C       10.10.12.0 is directly connected, Loopback12
Router#
  1. When the child subnets are not the same size, that is they are variably subnetted, then the prefix of the parent route reverts to the classful prefix:
Router#show ip route
Gateway of last resort is not set
     172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
C       172.16.1.0/24 is directly connected, Loopback1
C       172.16.2.0/24 is directly connected, Loopback2
C       172.16.5.0/25 is directly connected, Loopback4
C       172.16.32.0/24 is directly connected, Loopback3
Router#
  1. Finally, if the subnet mask is smaller than the classful mask of the network, no parent route is created but each route is displayed individually:
Router#show ip route
Gateway of last resort is not set
C    192.168.0.0/23 is directly connected, Loopback20
C    192.168.2.0/23 is directly connected, Loopback21
Router#

Keep in mind that all of the above is true only for 12.X versions of Cisco IOS. In version 15.X, the routing table includes a local route with a prefix of /32. This results in all routes always being variably subnetted, thus all parent routes will always display their classful prefixes. Here is an example of such a routing table:

Router#show ip route
Gateway of last resort is not set
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       10.10.10.0/24 is directly connected, Loopback5
L       10.10.10.1/32 is directly connected, Loopback5
     172.16.0.0/16 is variably subnetted, 8 subnets, 2 masks
C       172.16.1.0/24 is directly connected, Loopback1
L       172.16.1.1/32 is directly connected, Loopback1
C       172.16.2.0/24 is directly connected, Loopback2
L       172.16.2.1/32 is directly connected, Loopback2
C       172.16.3.0/24 is directly connected, Loopback3
L       172.16.3.1/32 is directly connected, Loopback3
C       172.16.4.0/24 is directly connected, Loopback4
L       172.16.4.1/32 is directly connected, Loopback4
Router#

So to summarize, in version 12.X, if all child routes have the same prefix, parent routes always display that prefix. If they are variably subnetted, the classful prefix is displayed. If you are using IOS version 15.X, parent routes are always variably subnetted thus they display the classful prefix.

I hope this has been helpful!

1 Like