How to Calculate Subnets: A Complete Beginner's Guide

5 min read
Beginner Networking Subnetting CIDR IP Addressing

If you have ever looked at something like 192.168.1.0/24 and wondered what the /24 means, or why someone chose 255.255.255.0 as a subnet mask, this guide is for you. Subnetting is one of those networking fundamentals that looks intimidating at first but clicks once you understand how binary math maps to IP addresses.

By the end of this article, you will be able to take any IP/CIDR combination and quickly determine the network address, broadcast address, usable host range, and how many devices can live on that subnet. Whether you are studying for the CCNA, building a homelab, or just trying to understand why your office network is segmented, this is the guide that gets you there.

What Is a Subnet?

A subnet (short for subnetwork) is a logical division of an IP network. Instead of putting every device on one giant flat network, you divide it into smaller chunks. Each chunk is a subnet with its own range of IP addresses.

Think of it like a building with floors. The building has one street address, but each floor has its own suite numbers. Subnetting does the same thing for IP networks — it takes a large block of addresses and splits it into smaller, manageable pieces.

Why subnet?

  • Security: Devices on different subnets cannot talk to each other without a router, so you can isolate sensitive systems
  • Performance: Smaller broadcast domains mean less noise on the wire
  • Organization: Separate departments, VLANs, or services into logical groups
  • Efficiency: Use only the addresses you need instead of wasting a large block

IP Addresses in Binary

Every IPv4 address is a 32-bit number. We write it in dotted decimal (like 192.168.1.100) for human readability, but underneath it is just 32 ones and zeros.

192.168.1.100 in binary:
11000000.10101000.00000001.01100100

Each of the four octets is 8 bits, so:

  • 192 = 11000000
  • 168 = 10101000
  • 1 = 00000001
  • 100 = 01100100

Understanding this binary representation is the key to understanding subnetting, because the subnet mask is what divides those 32 bits into two parts: the network portion (which subnet this address belongs to) and the host portion (which specific device on that subnet).

What Is a Subnet Mask?

A subnet mask is a 32-bit number where all the network bits are set to 1 and all the host bits are set to 0. It tells you where the network address ends and the host address begins.

Subnet mask: 255.255.255.0
In binary:   11111111.11111111.11111111.00000000
             |---- network (24 bits) -----|host|

The first 24 bits are 1s (network part), and the last 8 bits are 0s (host part). This means:

  • The first three octets identify the network
  • The last octet identifies individual hosts on that network

CIDR Notation

Instead of writing out 255.255.255.0, we can use CIDR (Classless Inter-Domain Routing) notation: just append a slash and the number of network bits.

192.168.1.0/24 means "the first 24 bits are the network portion."

Here are the most common CIDR prefixes:

CIDR Subnet Mask Usable Hosts
/8 255.0.0.0 16,777,214
/16 255.255.0.0 65,534
/24 255.255.255.0 254
/25 255.255.255.128 126
/26 255.255.255.192 62
/27 255.255.255.224 30
/28 255.255.255.240 14
/30 255.255.255.252 2
/32 255.255.255.255 1 (single host)

How to Calculate a Subnet: Step by Step

Let's work through a real example: 10.0.50.47/20

Step 1: Find the subnet mask

/20 means 20 network bits. In binary:

11111111.11111111.11110000.00000000
255     .255     .240     .0

Subnet mask: 255.255.240.0

Step 2: Find the network address

AND the IP address with the subnet mask (bitwise AND):

IP:   10.0.50.47     = 00001010.00000000.00110010.00101111
Mask: 255.255.240.0  = 11111111.11111111.11110000.00000000
AND:  10.0.48.0      = 00001010.00000000.00110000.00000000

Network address: 10.0.48.0

Step 3: Find the broadcast address

Flip all the host bits (the zeros in the mask) to 1:

Network: 00001010.00000000.00110000.00000000
Flip:    00001010.00000000.00111111.11111111
Result:  10.0.63.255

Broadcast address: 10.0.63.255

Step 4: Find the usable range

  • First usable host: network + 1 = 10.0.48.1
  • Last usable host: broadcast - 1 = 10.0.63.254

Step 5: Count the hosts

Total addresses: 2^(32-20) = 2^12 = 4,096 Usable hosts: 4,096 - 2 = 4,094 (subtract network and broadcast)

The Quick Method

Once you get comfortable, you do not need to do binary math every time. Here is the shortcut for any prefix length:

  1. Block size: 256 minus the interesting octet of the mask
  2. Network address: Round down the IP's interesting octet to the nearest multiple of the block size
  3. Broadcast: Network + block size - 1
  4. Usable range: Network + 1 to Broadcast - 1

For our example 10.0.50.47/20:

  • Mask third octet: 240. Block size: 256 - 240 = 16
  • IP third octet: 50. Nearest multiple of 16 below 50 is 48 → network is 10.0.48.0
  • Broadcast third octet: 48 + 16 - 1 = 63 → broadcast is 10.0.63.255
  • Usable: 10.0.48.1 to 10.0.63.254

Common Subnetting Scenarios

Home Network (/24)

Most home routers use 192.168.1.0/24:

  • 254 usable hosts (more than enough for a house)
  • Network: 192.168.1.0, Broadcast: 192.168.1.255
  • Range: 192.168.1.1 to 192.168.1.254

Point-to-Point Link (/30)

Connects two routers with the minimum number of addresses:

  • 2 usable hosts (one for each router interface)
  • Example: 10.0.0.0/30 gives you 10.0.0.1 and 10.0.0.2

Small Office (/26)

A /26 gives 62 usable addresses — enough for a small department:

  • Example: 172.16.10.0/26
  • Range: 172.16.10.1 to 172.16.10.62
  • Broadcast: 172.16.10.63

Server VLAN (/28)

When you need to isolate a handful of servers:

  • 14 usable hosts
  • Example: 10.10.5.0/28
  • Range: 10.10.5.1 to 10.10.5.14

Private IP Ranges

Not all IP addresses are routable on the public internet. These ranges are reserved for private use:

Range CIDR Typical Use
10.0.0.0 – 10.255.255.255 10.0.0.0/8 Large enterprise networks
172.16.0.0 – 172.31.255.255 172.16.0.0/12 Medium networks
192.168.0.0 – 192.168.255.255 192.168.0.0/16 Home and small office

Practice Problems

Try these yourself, then check your answers with our Subnet Calculator:

  1. 172.16.45.200/21 — What is the network address? How many usable hosts?
  2. 192.168.100.130/26 — What is the broadcast address? What is the usable range?
  3. 10.1.1.1/28 — What is the network? What is the last usable host?

Try It Yourself

Use our free Subnet & CIDR Calculator to instantly calculate any subnet. It shows the network address, broadcast, usable range, wildcard mask, binary representation, and includes a complete cheat sheet from /8 to /32.

See Also