Classful addressing: IP address classes A, B, C, D and E
Introduction
Until 1993 every IPv4 address belonged to one of five classes, and the class said how many of its 32 bits named the network and how many named the host. This scheme is called classful addressing. The classes were defined in RFC 791 in 1981. They are obsolete now, but the names "class A", "class B" and "class C" are still used for the networks 10.0.0.0, 172.16.0.0 and 192.168.0.0, and they explain why many old tools guess a mask from an address.
The five classes
The class is set by the first bits of the first octet.
| Class | First bits | First octet | Default mask | Use |
|---|---|---|---|---|
| A | 0 | 0 - 127 | 255.0.0.0 (/8) | Very large networks |
| B | 10 | 128 - 191 | 255.255.0.0 (/16) | Medium networks |
| C | 110 | 192 - 223 | 255.255.255.0 (/24) | Small networks |
| D | 1110 | 224 - 239 | none | Multicast |
| E | 1111 | 240 - 255 | none | Reserved for experiments |
Classes A, B and C are unicast: an address names one device. In class A the first octet is the network and the other three are the host. In class B two octets are the network, in class C three. Class D is multicast: one sender and a group of receivers. Class E was never put to general use.
How to find the class of an address
Look at the first octet, or at its first bits in binary.
| Address | First octet in binary | Class |
|---|---|---|
| 10.1.2.3 | 00001010 | A |
| 172.16.5.4 | 10101100 | B |
| 192.168.1.10 | 11000000 | C |
| 224.0.0.5 | 11100000 | D |
| 250.1.1.1 | 11111010 | E |
127.0.0.1 is formally in class A, but the whole 127.0.0.0/8 block is reserved for the loopback, so a real class A network starts at 1 and ends at 126.
How many networks and hosts
The host part of an address cannot be all zeros (that is the network address) or all ones (that is the broadcast address), so every network loses two addresses.
| Class | Networks | Hosts in one network |
|---|---|---|
| A | 126 | 16,777,214 |
| B | 16,384 | 65,534 |
| C | 2,097,152 | 254 |
Why it was dropped
The step between the classes is too big. A company with 300 computers did not fit in a class C network of 254 hosts, so it got a class B network of 65,534 addresses and used less than one percent of them. Multiplied by thousands of organizations, this emptied the pool of IPv4 addresses much faster than the number of real devices required. At the same time the routing tables of the internet grew with every new class C network.
The fix was classless addressing. In 1993 RFC 1519 introduced CIDR (Classless Inter-Domain Routing): the network part can be any number of bits, written as a prefix length such as /22, and addresses can be given out in blocks that fit the need and combined in routing tables. The current text is RFC 4632.
What is left of it today
- The private ranges still have class names: 10.0.0.0/8 is one class A network, 172.16.0.0/12 is sixteen class B networks, 192.168.0.0/16 is 256 class C networks.
- Class D is alive: 224.0.0.0/4 is the multicast range, for example 224.0.0.5 is used by the OSPF routing protocol.
- Class E, 240.0.0.0/4, is still reserved.
- Old routing protocols such as RIP version 1 do not send a mask, so they assume the classful one. Modern equipment uses CIDR everywhere.
The rest of the subject, the mask, the prefix length and how to cut a network into subnets, is in the CIDR section of the IPv4 article and in the IP address and mask examples.
Article author: Andrei Olegovich