1. Library
  2. IP Addresses
  3. Network Addressing

Updated 2 hours ago

When you see 192.168.1.0/24, you're looking at a question: which addresses belong together? Subnet calculation isn't abstract math—it's the gate every packet passes through. Same subnet? Talk directly. Different subnet? Find a router.

What You're Solving For

Given an IP address with CIDR notation like 192.168.5.0/24, you want:

  • Network address — Where this range starts (can't assign to hosts)
  • Broadcast address — Where it ends (can't assign to hosts)
  • Usable host range — Every address between them
  • Total capacity — How many devices fit

The Binary Foundation

IP addresses are 32-bit binary numbers. Dotted decimal is for humans; networks think in binary. Understanding this makes everything else obvious.

What CIDR Notation Means

The /24 in 192.168.5.0/24 means "the first 24 bits identify the network." The remaining 8 bits identify hosts.

192.168.5.0/24 in binary:
11000000.10101000.00000101.00000000
                            ^^^^^^^^
                            8 host bits = 2⁸ = 256 addresses

The subnet mask marks this division:

255.255.255.0 in binary:
11111111.11111111.11111111.00000000
^^^^^^^^^^^^^^^^^^^^^^^^   ^^^^^^^^
24 network bits (1s)       8 host bits (0s)

The subnet mask is a stencil. Lay it over any address, and it reveals which neighborhood that address belongs to.

Finding the Network Address

The network address has all host bits set to 0. Find it with a binary AND—wherever the mask has 1, keep the IP bit; wherever 0, the result is 0.

What network does 192.168.5.85/24 belong to?

IP:      11000000.10101000.00000101.01010101  (192.168.5.85)
Mask:    11111111.11111111.11111111.00000000  (255.255.255.0)
         ----------------------------------------
AND:     11000000.10101000.00000101.00000000  (192.168.5.0)

The host bits became 0. This is the network address—the start of the range.

Finding the Broadcast Address

The broadcast address has all host bits set to 1. Take the network address and flip every host bit.

Network:   11000000.10101000.00000101.00000000  (192.168.5.0)
                                      ^^^^^^^^
                                      Set to 1
Broadcast: 11000000.10101000.00000101.11111111  (192.168.5.255)

Usable Hosts

Everything between network and broadcast can be assigned:

Network:     192.168.5.0    (reserved)
First host:  192.168.5.1
Last host:   192.168.5.254
Broadcast:   192.168.5.255  (reserved)

Total: 256 addresses
Usable: 254 hosts (256 - 2)

When the Boundary Splits an Octet

Here's where it gets interesting: 10.50.100.75/22

The /22 means 22 network bits—which cuts through the middle of the third octet.

Step 1: Convert to binary
10.50.100.75 → 00001010.00110010.01100100.01001011

Step 2: Apply /22 mask
Mask: 11111111.11111111.11111100.00000000 (255.255.252.0)
                            ^^
                            These 2 bits are network, not host

Step 3: AND to find network
00001010.00110010.01100100.01001011  (10.50.100.75)
11111111.11111111.11111100.00000000  (mask)
----------------------------------------
00001010.00110010.01100100.00000000  (10.50.100.0)

Step 4: Set 10 host bits to 1 for broadcast
00001010.00110010.01100111.11111111  (10.50.103.255)

Result:
Network:     10.50.100.0/22
First host:  10.50.100.1
Last host:   10.50.103.254
Broadcast:   10.50.103.255
Usable:      1,022 hosts (2¹⁰ - 2)

The range spans 100, 101, 102, 103 in the third octet. Those last 2 bits of the third octet are host bits—they count through four values (00, 01, 10, 11) whether you expected it or not. Subnet boundaries don't respect octet boundaries.

The Quick Math Method

Once the binary clicks, you can calculate most subnets mentally.

Block Size

Subnets divide address space into equal blocks. The block size comes from host bits:

/24: 8 host bits  → 2⁸ = 256 per block
/27: 5 host bits  → 2⁵ = 32 per block
/22: 10 host bits → 2¹⁰ = 1,024 per block

Block size tells you where boundaries fall:

/24 (256):  .0, .1, .2... (4th octet increments by 1)
/27 (32):   .0, .32, .64, .96, .128...
/22 (1024): Every 4 in 3rd octet (.0, .4, .8, .12...)

Which Subnet Contains This IP?

Divide the relevant octet by block size.

192.168.5.85/27:

Host bits: 5 → Block size: 32
85 ÷ 32 = 2 remainder 21

Block 0: 0-31
Block 1: 32-63
Block 2: 64-95 ← 85 is here
Block 3: 96-127

Network:    192.168.5.64
First host: 192.168.5.65
Last host:  192.168.5.94
Broadcast:  192.168.5.95
Usable:     30 hosts

Common Subnet Sizes

/30 — 4 addresses, 2 usable (point-to-point links)
/29 — 8 addresses, 6 usable
/28 — 16 addresses, 14 usable
/27 — 32 addresses, 30 usable
/26 — 64 addresses, 62 usable
/25 — 128 addresses, 126 usable
/24 — 256 addresses, 254 usable
/23 — 512 addresses, 510 usable
/22 — 1,024 addresses, 1,022 usable
/16 — 65,536 addresses, 65,534 usable

Note: /31 networks are a special case for point-to-point links (RFC 3021). Both addresses are usable—no network or broadcast reserved.

Practical Example: Dividing an Office Network

You have 10.20.30.0/24 and need 4 departmental subnets.

4 subnets → need 2 bits (2² = 4)
Original /24 + 2 bits = /26
Each /26: 64 addresses, 62 usable

HR:          10.20.30.0/26   (hosts .1-.62)
Engineering: 10.20.30.64/26  (hosts .65-.126)
Sales:       10.20.30.128/26 (hosts .129-.190)
Guest WiFi:  10.20.30.192/26 (hosts .193-.254)

Each department becomes its own broadcast domain. They communicate through a router, but broadcasts stay local.

Reference Tables

Which Octet Changes?

  • /24 to /32 — 4th octet only
  • /16 to /23 — 3rd octet changes
  • /8 to /15 — 2nd octet changes
  • Less than /8 — 1st octet changes

Partial Octet Mask Values

10000000 = 128  (1 bit)
11000000 = 192  (2 bits)
11100000 = 224  (3 bits)
11110000 = 240  (4 bits)
11111000 = 248  (5 bits)
11111100 = 252  (6 bits)
11111110 = 254  (7 bits)
11111111 = 255  (8 bits)

Powers of 2

2¹ = 2        2⁶ = 64       2¹¹ = 2,048
2² = 4        2⁷ = 128      2¹² = 4,096
2³ = 8        2⁸ = 256      2¹³ = 8,192
2⁴ = 16       2⁹ = 512      2¹⁴ = 16,384
2⁵ = 32       2¹⁰ = 1,024   2¹⁵ = 32,768

Verify Your Work

After calculating, check:

  1. Network address: all host bits = 0
  2. Broadcast address: all host bits = 1
  3. First usable = network + 1
  4. Last usable = broadcast - 1
  5. Total addresses = 2^(host bits)

Frequently Asked Questions About Subnet Calculation

Sources

Was this page helpful?

😔
🤨
😃