The First Octet Rule

Without putting too fine a point on it, it can be said that there are three sizes of internetworks as measured
by the number of hosts: big, medium, and small.
Big internetworks, by definition, have a huge number of hosts. Relatively few big internetworks
exist.
Small internetworks are just the opposite. Each one is small because it has a small number of
hosts; a huge number of small internetworks exist.
Medium internetworks are just that: a medium number of them (in relation to big and small ones)
and a medium number of hosts in each one.
This high level of addressing focus requires three types—classes—of network address for the three sizes
of internetworks. Addresses for big internetworks need to be capable of addressing many hosts, but
because so few big internetworks exist, only a few big-network addresses are required.
The situation is reversed for small internetworks. Because there are many small internetworks, a large
number of small-network addresses are needed. But because a small internetwork has a small number of
hosts, each of the many network addresses only requires a few host addresses.
For medium-sized internetworks, a medium number of network addresses and a medium number of host
addresses will be available for each network address.
Figure 2.10 shows how the network and host portions of IP addresses are divvied up for these three
classes.
Figure 2.10. Class A, B, and C IP address formats.
The big, medium, and small networks described thus far map to address classes as follows:
Class A IP addresses are for big internetworks. The first octet is the network portion, and the last
three octets are the host portion. Only 256 numbers are available in the eight-bit network part, but
224 or 16,777,216 numbers are available in the host part of each of those network addresses.

Class B addresses are for medium-size internetworks. The first two octets are the network portion
, and the last two octets are the host portion. There are 216 or 65,536 available numbers in the
network part and an equal number in the host part.
Class C addresses are just the opposite of class A. The first three octets are the network portion,
and the last octet is the host portion.
Because all IP addresses are 32-bit binary strings, a way of distinguishing the class to which a particular
address belongs is necessary. The first octet rule, illustrated in Figure 2.11, provides the means to make
such a distinction and can be described as follows:
Figure 2.11. The first octet rule.
For class A addresses, the first bit of the first octet— that is, the left-most bit of the entire 32-bit
string— is always set to zero. Therefore, we can find the minimum and maximum numbers in the
class A range by setting all the remaining bits in the first octet to zero (for the minimum) and one
(for the maximum). This action results in the decimal numbers 0 and 127 with a few exceptions: 0
is reserved as part of the default address (Chapter 12, "Default Routes and On-Demand Routing"
), and 127 is reserved for internal loopback addresses.[4] That leaves 1 through 126; any IP address
whose first octet is between 1 and 126 inclusive is a class A address.
[4] UNIX machines use an internal loopback address (typically 127.0.0.1) to send traffic to themselves. Data may be sent to this
address and returned to the transmitting process without ever leaving the device.
Class B addresses always have their left-most bit set to one and the second bit set to zero. Again
finding the minimum and maximum number of the first octet by setting all remaining bits to zero
and then to one, we see in Figure 2.9 that any address whose first octet is in the decimal range 128
through 191 is a class B address.
In class C addresses, the first two bits are set to one, and the third bit is set to zero. The result is a
first octet range of 192 through 223.[5]
[5] Notice that 223 does not exhaust all available numbers in the first octet. See Configuration Excerise 1 at the end of this chapter.
So far IP addressing doesn't seem so difficult. A router or host could easily determine the network part of
an IP address by using the first octet rule. If the first bit is 0, then read the first eight bits to find the
network address. If the first two bits are 10, then read the first 16 bits; and if the first three bits are 110,
then read 24 bits in to get the network address. Unfortunately, things are not that easy.