Subnetting in IPv4

#tech - 2 Minute Read

a server rack

Subnet Mask Last octet (in bits) CIDR Networks Hosts per network
255.255.255.0 00000000 /24 1 254
255.255.255.128 10000000 /25 2 126
255.255.255.192 11000000 /26 4 62
255.255.255.224 11100000 /27 8 30
255.255.255.240 11110000 /28 16 14
255.255.255.248 11111000 /29 32 6
255.255.255.252 11111100 /30 64 2
255.255.255.254 11111110 /31 128 1

Question: How many nodes can be allocated on 10.10.3.3/29?

10.10.3.3 is an IP (v4) address. Let's expand the address into binary octets:

00001010.00001010.00001010.00000011

The /29 of CIDR notation tells us a lot about this address. It says that 29 bits belong to the network (subnet) portion of the address. From this, we can derive both the subnet mask and the network address.

Subnet mask

Let's separate the binary address after the 29th bit.

00001010.00001010.00001010.00000 | 011

The subnet mask is given by replacing all bits to the left with 1, and all to the right with 0:

11111111.11111111.11111111.11111000 = 255.255.255.248

Network address

Looking at our binary IP address, the network address is given by replacing all bits to the right of the 29th bit with 0. This is essentially a bitwise AND operation of the IP address and the subnet mask.

00001010.00001010.00001010.00000000 = 10.10.3.0

Broadcast address

The broadcast address is given by replacing all bits to the right with 1.

00001010.00001010.00001010.00000111 = 10.10.3.7

Host range

So, we see that IP addresses between 10.10.3.0 and 10.10.3.7 are available for hosts. In this case, we have .1 to .6, total of 6 possible hosts.

A quick way to calculate the number of available hosts using the CIDR notation:

2^(32 - <CIDR SUBNET MASK>) - 2 = Number of hosts

So, we have:

2^(32 - 29) - 2 = 2^3 - 2 = 6 hosts


Updated May 22, 2020.