Classful and Classless Routing
 


Cisco routers have two configurable options for how a router uses an existing default route: classless routing and classful routing.  Classless routing causes a router to use its default routes for any packet that does not match some other route.  Classful routing places one restriction on when a router can use its default route, resulting in cases in which a router has a default route but the router chooses to discard a packet rather than forwarding the packet based on the default route.

The terms classless and classful also characterize both IP addressing and IP routing protocols, so a fair amount of confusion exists as to the meaning of the terms.

Classless addressing and classful addressing refer to two different ways to think about IP addresses.  Both terms refer to a perspective on the structure of a subnetted IP address.  Classless addressing uses a two-part view of IP addresses, and classful addressing has a three-part view.  With classful addressing, the address always has an 8-, 16-, or 24-bit network field, based on the Class A, B, and C addressing rules.  The end of the address has a host part that uniquely identifies each host inside a subnet.  The bits in between the network and host part comprise the third part, namely the subnet part of the address.  With classless addressing, the network and subnet parts from the classful view are combined into a single part, often called the subnet or prefix, with the address ending in the host part.

The terms classless routing protocol and classful routing protocol refer to features of different IP routing protocols.  These features cannot be enabled or disabled; a routing protocol is, by its very nature, either classless or classful.  In particular, classless routing protocols advertise mask information for each subnet, giving classless protocols the ability to support both VLSM and route summarization.  Classful routing protocols do not advertise mask information, so they do not support VLSM or route summarization.

The third use of the terms classless and classful – routing – have to do with how the IP routing process makes use of the default route.  This is the only one of the three uses of the terms that can be changed based on router configuration.

As Applied To Classful Classless
Addresses Addresses have three parts: network, subnet, and host. Addresses have two parts: subnet or prefix, and host.
Routing protocols Routing protocol does not advertise masks nor support VLSM; RIP-1 and IGRP Routing protocol does advertise masks and support VLSM; RIP-2, EIGRP, OSPF.
Routing (forwarding) IP forwarding process is restricted in how it uses the default route IP forwarding process has no restrictions on using the default route

- Classless routing: When a packet’s destination only matches a router’s default route, and does not match any other routes, forward the packet using that default route.

- Classful routing: When a packet’s destination only matches a router’s default route, and does not match any other routes, only use the default route if this router does not know any routes in the classful network in which the destination IP address resides.

The use of the term classful refers to the fact that the logic includes some consideration of classful IP addressing rules – namely, the classful (Class A, B, or C) network of the packet’s destination address.  With classful routing, the only time the default route is used is when the router does not know about any subnets of the packet’s destination Class A, B, or C network.

You can toggle between classless and classful routing with the ip classless/no ip classless global configuration commands.  With classless routing, Cisco IOS Sotware looks for the best match, ignoring class rules.  If a default route exists, with classless routing, the packet always at least matches the default route.  If a more specific route matches the packet’s destination, that route is used.