Introduction

The history of the Internet is marked by stacked innovations. Ideas that seemed good and necessary in their day are often superseded by better ideas that come along later.

And yet, remnants often remain.

We had a customer running NetBSD who was having trouble exchanging emails with us. They could contact other people just fine, but not us.

Investigation and debugging eventually determined that their service was attempting to communicate directly with our mail server rather than through a gateway. The service was using a manually added IP address. We determined that when they added the address via ifconfig, they did not supply a netmask. NetBSD then assigned it a default network prefix of /8. A /8 would include 16 million other hosts, which is nonsensical.

We initially thought that it was a default behavior of ifconfig, but some legwork showed that the default was built into the BSD kernel, and also the Linux kernel. It all traced back to a system called “Classful Networking,” which was developed in 1981 and was superseded in 1993 by Classless Interdomain Routing, or CIDR. CIDR, in turn, uses variable length subnet masks (VLSM), whereas in Classful Networking subnet masks were fixed.

NetBSD was assigning the network prefixes associated with the default subnet masks for the old classful system. Our network was set up with a variable netmask, and hence a different network prefix. This put our customer in a different subnet than we were in, and FUBARed our communications.

So what is Classful Networking? Why did it ever exist in the first place? And why are modern kernels still defaulting to a system that was made obsolete almost 30 years ago?

History of Classful Networks

The internet ran into scaling problems early on. The way an internet address is written, the first iteration was able to identify only 256 unique networks. The network was defined by the first 8 bits of the 32-bit IPv4 address, and individual machines were defined by the other 24 bits, or the remaining three octets in quad-decimal notation.

It was fine to have only 256 huge networks in the early days, when the only networks around were giants like ARPANET (Network Number 10) and SATNET (Network Number 3). But it soon became clear that there would eventually be much more than 256 networks, and the vast majority of them would not need the 16,777,216 individual nodes allowed by those three trailing octets.

The solution to that was to divide the IPv4 address domain into “classes,” and give them different scaling capacities. There were five classes, assigned letters A through E.

Class 1st IP Last IP Netmask CIDR Prefix
A 0.0.0.0 127.255.255.255 255.0.0.0 /8
B 128.0.0.0 191.255.255.255 255.255.0.0 /16
C 192.0.0.0 223.255.255.255 255.255.255.0 /24
D 224.0.0.0 239.255.255.255 NA NA
E 240.0.0.0 255.255.255.255 NA NA

Classes A-C were regular networks. Class D was assigned multicast addresses, while Class E was reserved for special uses.

This system was introduced by RFC 791 in 1981. It was replaced in 1993 by CIDR, under specifications RFC 1518 and RFC 1519. Classful Networking lasted for 12 years, but it was only a stopgap. The problem was the huge leap in size from Class C networks (256 nodes) to Class B networks (65,536 nodes). Many emerging networks needed much more than 256 individual machines, so they were assigned to Class B. Yet very few really needed more than 65,000 machines, so the pool of Class B addresses was being wasted.

CIDR solved this by making the netmask length variable, and assigning a network prefix that was derived from (and so defined) the netmask in a format that was easier to write and remember. The network prefix is simply the number of leading 1 bits in the netmask address, with all other bits set to 0. The old classful netmasks were fixed, and so received the network prefixes defined in the table above.

CIDR, with its variable netmasks, has served since 1993, and it still the addressing system used today.

Carryover to BSD and Linux

The kernels for BSD and Linux were in active development right about the time that the internet was making the transition from Classful Networking to CIDR. Accordingly they incorporated the Classful Networking IP assignments as part of their default behavior.

This means that when you assign an IP address using ifconfig, if you don’t specify the netmask and/or the network prefix, the kernel assigns the IP address to one of the five classes and gives it the default netmask and prefix for that class.

Changing these defaults in modern kernels would break backwards compatibility. And so they remain to this day.

However, warning the user if there is no netmask supplied to a network configuration tool should not break backwards compatibility. If you would be interested in a year of complimentary service in exchange for adding this warning to any of the distributions we officially support, please contact us.

Special thanks to sigjuice, cpach and others at Hacker News, for invaluable information on the history of ifconfig and the Linux kernel.