Understanding IPv4 Addressing, Subnetting, and Binary Calculations
This article explains IPv4 address structure, network and host bits, classful address ranges, broadcast addresses, subnet mask functions, and step‑by‑step binary calculations for subnetting and determining usable host counts across various examples.
An IP address identifies a node on a network and consists of a network portion and a host portion, where the network bits are represented by continuous 1 s and the host bits by continuous 0 s.
The broadcast address has all host bits set to 1 , e.g., 255.255.255.255 , and cannot be assigned to a single interface.
Classful address ranges are illustrated:
Class A: network 10.0.0.0 , mask 255.0.0.0 , binary 11111111.00000000.00000000.00000000
Class B: network 172.16.0.0 , mask 255.255.0.0 , binary 11111111.11111111.00000000.00000000
Class C: network 192.168.1.0 , mask 255.255.255.0 , binary 11111111.11111111.11111111.00000000
Usable host counts are calculated as 2^n - 2 , where n is the number of host bits; examples include:
10.0.0.0/8 provides 2^24 - 2 = 16,777,214 usable addresses.
128.0.0.0/16 provides 2^16 - 2 = 65,534 usable addresses.
192.168.1.0/24 provides 2^8 - 2 = 254 usable addresses.
Subnetting divides a larger network into smaller ones by extending the subnet mask, which simplifies management and enables policies such as ACLs. The mask distinguishes network bits from host bits; for example, IP 192.168.1.1 with mask 255.255.0.0 has network 192.168.0.0 , while mask 255.255.255.0 yields network 192.168.1.0 .
To design subnets, determine the number of required subnets ( N ) and find the smallest 2^n ≥ N ; the value n indicates how many host bits must be borrowed. Examples:
For 4 subnets, borrow 2 bits ( 2^2 = 4 ).
For 6 subnets, borrow 3 bits ( 2^3 = 8 ≥ 6 ).
Each subnet’s details include network address, first usable IP (network address + 1), last usable IP (broadcast address – 1), broadcast address, and the next network (increment the smallest network bit by 1).
Example calculations:
IP 172.16.36.42/24 converts to binary 10101100.00010000.00100100.00101010 with mask 11111111.11111111.11111111.00000000 (255.255.255.0). The network address is 172.16.36.0 , first host 172.16.36.1 , last host 172.16.36.254 , and next network 172.16.37.0 .
Another example, 192.168.221.37/29 yields binary IP 11000000.10101000.11011101.00100101 and mask 11111111.11111111.11111111.11111000 (255.255.255.248). The network address is 192.168.221.32 , first host 192.168.221.33 , last host 192.168.221.38 , broadcast 192.168.221.39 , and next network 192.168.221.40 .
Binary power tables (2⁰ to 2⁷) are provided to aid manual calculations, and a detailed example for 158.72.68.139/28 shows step‑by‑step conversion to binary, mask derivation ( 255.255.255.240 ), network address 168.72.68.128/28 , first address 168.72.68.129 , last address 168.72.68.142 , and broadcast 168.72.68.143 .
Finally, the article demonstrates splitting 172.16.32.0/20 into four sub‑nets of 50 IPs each, showing the binary representation of each resulting subnet.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.