IPv4 subnetting guide

Convert CIDR manually with binary

An Internet Protocol address identifies an interface on a network. IPv4 uses 32 bits shown as four decimal octets, while IPv6 uses 128 bits commonly shown in hexadecimal groups. This guide works only with IPv4.

Private IPv4 space can be reused inside separate networks; public addresses must be globally coordinated. The complete private ranges are:

Traditional labelPrivate rangeCIDRTotal addresses
A10.0.0.0 – 10.255.255.25510.0.0.0/816,777,216
B172.16.0.0 – 172.31.255.255172.16.0.0/121,048,576
C192.168.0.0 – 192.168.255.255192.168.0.0/1665,536

The class labels are historical; modern routing and subnetting use CIDR prefixes.

What CIDR means

Classless Inter-Domain Routing writes an address with a prefix length, such as 110.40.240.16/22. The number after the slash tells you how many leading bits belong to the network. The remaining bits belong to the host portion.

Convert each IPv4 octet to binary

IPv4 address32-bit binary form
110.40.240.1601101110.00101000.11110000.00010000
14.12.72.800001110.00001100.01001000.00001000
10.98.1.6400001010.01100010.00000001.01000000

Worked example: 110.40.240.16/22

A /22 uses 22 network bits and leaves 10 host bits.

Address:  01101110.00101000.111100|00.00010000
Mask:     11111111.11111111.111111|00.00000000
Netmask:  255.255.252.0

Set all host bits to 0 for the network address and to 1 for the broadcast address:

Network:   110.40.240.0
Broadcast: 110.40.243.255
Total:     2^10 = 1,024 addresses
Usable:    1,022 addresses
Range:     110.40.240.1 – 110.40.243.254

Worked example: 14.12.72.8/17

A /17 uses 17 network bits and leaves 15 host bits.

Address:   00001110.00001100.0|1001000.00001000
Mask:      11111111.11111111.1|0000000.00000000
Netmask:   255.255.128.0
Network:   14.12.0.0
Broadcast: 14.12.127.255
Total:     2^15 = 32,768 addresses
Usable:    32,766 addresses
Range:     14.12.0.1 – 14.12.127.254

Worked example: 10.98.1.64/28

A /28 uses 28 network bits and leaves four host bits.

Address:   00001010.01100010.00000001.0100|0000
Mask:      11111111.11111111.11111111.1111|0000
Netmask:   255.255.255.240
Network:   10.98.1.64
Broadcast: 10.98.1.79
Total:     2^4 = 16 addresses
Usable:    14 addresses
Range:     10.98.1.65 – 10.98.1.78

The traditional “total minus two” usable count applies to ordinary multi-access IPv4 subnets such as these examples. /31 point-to-point links and /32 host routes have special interpretations.

Allocate subnets from 139.145.56.0/22

The original exercise divides a /22 for four networks needing 65, 100, 33 and 13 usable addresses. For each requirement, choose the smallest power-of-two block that also accommodates network and broadcast addresses, then begin on a correctly aligned boundary.

NetworkNeedAllocated CIDRNetmaskBroadcastUsable range
A65139.145.56.0/25255.255.255.128139.145.56.127139.145.56.1 – 139.145.56.126
B100139.145.56.128/25255.255.255.128139.145.56.255139.145.56.129 – 139.145.56.254
C33139.145.57.0/26255.255.255.192139.145.57.63139.145.57.1 – 139.145.57.62
D13139.145.57.64/28255.255.255.240139.145.57.79139.145.57.65 – 139.145.57.78

These allocations consume the beginning of the /22; the rest remains available. In operational VLSM planning, sorting requirements largest-first usually reduces alignment waste.

Check a CIDR with the calculator