Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

"ip classless": how does it work?

Hi, there. This is the description I found for this command at Cisco's site:

"At times the router might receive packets destined for a subnet of a network that has no network default route. To have the Cisco IOS software forward such packets to the best supernet route possible, use the ip classless global configuration command. To disable this feature, use the no form of this command."

I think I get it, but could anybody give me a practical example of it?

What would be a typical net topology for this command?

I've had some IGRP routing problems when this command was active. I just want to know if I should disable it.


New Member

Re: "ip classless": how does it work?

This is a very good question and I hope someone else will follow up with additional information. This question thoroughly stumped me and I researched CCO and several of my Cisco Press books trying to find a scenario which described the logic. The only example I could find was in chapter six of the CCNA 640-607 exam certification guide.

According to that guide, a packet destined for a remote host is handled differently depending on whether a router is configured for classful or classless bevavior. Two tasks are considered here. The first is route lookup and the second is determining what role the default route will play.


A router configured with the "no ip classless" command tries to match the appropriate class (A, B or C) of network and then the specific subnet in the routing table to make a routing decision. If both are matched the packet will route. If a match is made only on the class of network, the packet is dropped. The default route is only used when a match is not made on either the class network or the specific subnet.


A router configured with the "ip classless" command tries to match the the specific subnet and ignores the class (A, B or C) of network and only uses the default route when no match is made.

In researching this I began to see some of the problems which could be caused by the absence of a default route or an incorrect default route and I would certainly like to hear the specific problems Carlos experienced.




Re: "ip classless": how does it work?

If you look at the routes in your routing table you'll see that they're grouped by major network. For example: is variably subnetted, 16 subnets, 7 masks

S [1/0] via

S [1/0] via

C is directly connected, Vlan9

The above router is in classless mode, but the routes are grouped by major network ( in this case; /8 because is in the Class A range) regardless.

Let's say the above entries are the only ones in the routing table in addition to a default route, and the router needs to route a packet to destination In classful mode, the router first looks to see if the major network ( in this case) is in the routing table. If so, it goes through the subnets of that major network that are in the routing table (there are 3 of them here) trying to find a match for It doesn't find one in this case, so the packet is dropped. The default route is *not* taken because a match for the major network was found in the routing table (the only routing table entries searched in this case are subnets of the major network). If a match for the major network is not found (e.g., a packet destined to arrives) the default route will be chosen. The logic here is that in classful routing it is assumed that major networks are contiguous; i.e., you can't have a major network divided and separated by another major network (, for example) because classful routing protocols such as RIP/IGRP don't work properly in such an environment. So a classful route lookup assumes that if a router knows about any part of a major network (the 3 subnet routes above mean that the router knows about the major network) it must know about all existing/up parts of that network; hence, any subnet of that network not found in the routing table must not exist or be down, so the default route shouldn't be followed (you can end up with routing loops this way).

Classless routing is what most people are used to -- the default route is taken regardless of any major network entries in the routing table because discontiguous major networks are indeed possible (and common) due to VLSM. So in the example above, the default route is taken for if "ip classess" is enabled.

In the original posters case, it's not surprising that "ip classless" can cause problems when a classful routing protocol like IGRP is in use. It should probably be disabled in this case, though migrating to a classless routing protocol like EIGRP/OSPF is generally what's recommended these days.


Re: "ip classless": how does it work?

This is a good response, but I'll try to put it in simpler terms: Classful routing assumes that if you know about any part of a given major network, you know about every possible destination within that major network. For instance, in the example above, since you know about three subnets within the 10/8 major network, you must know about all possible subnets of 10/8, and therefore a packet destined to, for instance, can be safely dropped, since that destination simply does not exist within this network.

On the other hand, a packet destined to is in a major network which isn't known at all, so it's safe to assume those destinations are outside this network, and packets destined to them should be forwarded along the defualt route.

It really doesn't have anything to do with the contiguous nature of the routes, or anything like that, it's a very simple rule for dropping packets to destintations which do not exist withint your network at the very edge of the network, rather than waiting until they reach the router generating the default route to be dropped.

And note--classless routing has nothing do with classless routing protocols. For instance, you can run classless routing with ripv1, and classful routing with EIGRP, or OSPF. In fact, running classful routing is a possible way to keep people from sending packets into non-existant destinations within your network, if you've numbered your entire network from a small number of private major networks.

Another way of thinking this is: The routing table is a database that sits between the routing protocols and the packet forwarding process(es). So, think of it this way:

forwarding<--RIB<--Routing Protocols

So, the Routing Protocols install routes in the routing table in the same way no matter whether or not "classless routing" is configured. The RIB is built the same way, as well--none of these elements are changed by the command ip classless. What changes is this:

-- A packet is received which is destined to

-- The destination is looked up in the RIB, and the RIB returns the default route as the best match,

-- If ip classless is configured, this match is used, and the packet is forwarded.

-- If ip classless is not configured, then the forwarding process now takes the destination address, and pulls the major network from this. In this instance, we would find the major network to be, by AND'ing with the major network mask.

-- We then look up the major network in the routing table, looking for any component of this major network.

-- If some other route is returned other than the default route, the packet is discarded.

-- If the default route is returned, the packet is forwarded along the default route.

I hope this rather long'ish explination makes sense.... I know this is hard to understand.


CreatePlease login to create content