IPv4 Classful and Classless Addressing
Classful and Classless addressing are both terms that refer to a viewpoint on the structure of a subnetted IP address. Classless addressing has a two-part view, and classful addressing has a three-part view. With classful addressing, the address always has an /8, /16, or /24 bit network prefix, based on the Class A, B, and C addressing rules. The end of both address types has a host part that uniquely identifies each host inside a network or sub-network. The classful address has a third part between the network and the host part, namely the subnet part of the address containing borrowed bits.
Classful Addressing
Each router interface connected to a network requires an IP address and subnet mask. The IP address uniquely identifies the router or device in the network, and the subnet mask identifies the network broadcast. The prefix length and the subnet mask are different ways of determining the network portion of the IP address. For IPv4 subnetting, we borrow host bits and use them as network bits to create supplementary networks called sub-networks. We can subnet a network, either a classful or a classless subnet.
Borrowing more host bits can define more sub-networks. We already learned that an IPv4 address has 4 octets, and the octet boundaries are predefined:/8, /16, and /24. Network subnetting at octet boundaries is too easy. The table below identifies the prefix lengths and subnet masks equivalent to prefixes. The table also identifies the network and host bits, including the number of hosts each subnet can connect. The longer prefix lengths mean fewer hosts per network.
Classful Subnetting
Subnetting on the octet boundary is easy and is also known as classful subnetting. To understand the subnetting on the octet boundaries, examine the following example. Suppose you have an IP network 120.0.0.0/8 in a single broadcast domain. The number of hosts in the network is 16,777,214. This is a large network with an extensive broadcast, causing slow network performance. So, this is not perfect.
You can subnet the network 120.0.0.0/8 address at the octet boundary of /16, as shown in the Figure below. Subnetting with /16 can provide 256 sub-networks (i.e., 120.0.0.0/16 – 120.255.0.0/16). Each subnet contains 65,534 hosts. The first two octets with the/16 prefix length identify the network portion of the address, and the last two octets are for the host portion of IP addresses. The figure below illustrates the subnetting of /8 network into /16 network.
As shown in the Figure below, you can also subnet the /8 prefix network into the /24 octet boundary. A/24 subnetting can provide 65536 sub-networks (i.e., 120.0.0.0/24 – 120.255.255.0/24), with each subnet containing 256 hosts. The first three octets identify the network portion of the address, while the last octets are for the host portion of IP addresses while using the/24 prefix.
Classless Subnetting
Classful subnetting uses the default Class A, B or C networks, including the default mask for its classes (A, B, C). The default subnet mask for Classes are:
Class-A: 0 – 127 with a mask of 255.0.0.0 or /8
Class-B: 128 – 191 with a mask of 255.255.0.0 or /16
Class-C: 192 – 223 with a mask of 255.255.255.0 or /24
Routers configured with classful ip addresses do not include subnet mask information with routing updates. The router assumes its subnet mask or defaults to the classful subnet mask.
However, classless subnetting allows the use of Variable-Length Subnet Masks (VLSM). The classless IP address uses a CUSTOM subnet mask. Routers running a classless IP address, for example, include subnet mask information with their routing updates.
120.210.0.0/17
20.6.150.0/28
172.31.16.0/21
172.16.16.0/20
Subnetting Formulas
To calculate the number of subnets produced by the bits borrowed from the host portion, use formula (1), and for the number of hosts per network, use formula (2).
The “n” is the number of borrowed bits from the host portion. The first formula will produce the number of possible networks. The “h” is the number of bits remaining in the host portion. The second formula will produce the number of usable host addresses for each sub-network. Two addresses cannot be assigned to any host: the network address(the first address of the subnet) and the broadcast address(the last address of the subnet), so we must subtract 2 for usable host addresses.