Blog

Networking articles

Subnetting Explained with Simple Examples

Subnetting explained step by step: network and host bits, subnet masks, and worked examples splitting an office network into smaller subnets.

4 min read Networking

Subnetting is the practice of dividing one IP network into smaller, separate networks called subnets. It sounds like an exam topic, and it is, but it also solves everyday problems: keeping guest Wi-Fi away from your accounts PC, putting security cameras on their own segment, or carving a cloud network into public and private zones. Once you see the pattern, the arithmetic is straightforward.

Why businesses subnet

  • Security. Devices on different subnets cannot talk to each other unless a router or firewall allows it. A compromised smart TV on the guest network should not be able to reach your file server.
  • Less broadcast noise. Some traffic goes to every device on a network segment. Smaller subnets keep that chatter contained.
  • Organization. Knowing that 10.0.20.x is always printers and 10.0.30.x is always cameras makes troubleshooting and firewall rules much easier.
  • Cloud design. Cloud providers require you to split a virtual network into subnets, typically separating internet-facing servers from databases.

The building blocks: addresses and masks

An IPv4 address is 32 bits, written as four numbers from 0 to 255 (each one an octet of 8 bits), such as 192.168.1.25. Every address has two parts:

  • The network part, which identifies the subnet.
  • The host part, which identifies the individual device in that subnet.

The subnet mask says where one part ends and the other begins. In binary, the mask is a run of 1s (network bits) followed by 0s (host bits). The mask 255.255.255.0 is 24 ones followed by 8 zeros, written in CIDR notation as /24.

Address: 192.168.1.25   = 11000000.10101000.00000001.00011001
Mask:    255.255.255.0  = 11111111.11111111.11111111.00000000
                          |------ network (24 bits) ------|host|

So 192.168.1.25/24 lives on the network 192.168.1.0, and the device is host 25 on it.

Three numbers every subnet has

For any subnet, you can work out:

  1. Network address: all host bits set to 0. It names the subnet and cannot be given to a device.
  2. Broadcast address: all host bits set to 1. Traffic sent here reaches every device on the subnet, so it also cannot be assigned.
  3. Usable hosts: everything in between. With h host bits, a subnet holds 2 to the power of h addresses, so the usable count is that number minus 2.

For 192.168.1.0/24: 8 host bits gives 256 addresses, the network address is 192.168.1.0, the broadcast address is 192.168.1.255, and .1 to .254 are usable (254 hosts).

Subnetting example 1: splitting a /24 into four

A small office has 192.168.10.0/24 and wants four separate segments: staff, servers, guest Wi-Fi and cameras.

To make four subnets, borrow 2 bits from the host part, because 2 bits give 2 × 2 = 4 combinations. The prefix grows from /24 to /26, leaving 6 host bits: 64 addresses per subnet, 62 usable.

SubnetNetworkUsable rangeBroadcast
Staff192.168.10.0/26.1 – .62.63
Servers192.168.10.64/26.65 – .126.127
Guest Wi-Fi192.168.10.128/26.129 – .190.191
Cameras192.168.10.192/26.193 – .254.255

The quick trick: the subnet size is 256 minus the last non-255 octet of the mask. A /26 mask is 255.255.255.192, and 256 − 192 = 64, so subnets start at 0, 64, 128 and 192.

Subnetting example 2: sizing by host count

Often you start from "how many devices?" rather than "how many subnets?". Pick the smallest block whose usable count (2 to the power of the host bits, minus 2) covers your devices plus room to grow:

  • 40 staff laptops and phones: 6 host bits (62 usable) → /26.
  • 12 servers: 4 host bits (14 usable) → /28.
  • A link between two routers: 2 host bits (2 usable) → /30.

Allocating different sizes from one larger block is called variable-length subnet masking (VLSM). Allocate the largest subnets first, and each block must start on a multiple of its own size. A /28 (16 addresses) can begin at .0, .16, .32 and so on, but not at .20.

Subnetting example 3: which subnet is this address in?

Given 172.16.5.140/27, find its network:

  1. A /27 mask is 255.255.255.224; block size is 256 − 224 = 32.
  2. Multiples of 32 in the last octet: 0, 32, 64, 96, 128, 160…
  3. 140 falls between 128 and 159.
  4. Network: 172.16.5.128; broadcast: 172.16.5.159; usable: .129 to .158.

This is the calculation you do when two devices "should" talk but cannot: often they are in different subnets because one has the wrong mask.

Subnets and VLANs

On a physical office network, subnets are usually paired with VLANs (virtual LANs). A VLAN separates traffic at the switch level, so devices plugged into the same switch can still be on different logical networks. Each VLAN gets its own subnet, and the router or firewall connecting them decides which traffic may cross. Guest Wi-Fi is a common example: the access point puts guests on a separate VLAN and subnet that can reach the internet but nothing internal.

Practical tips

  • Leave room. Readdressing a network later is painful. Size subnets for growth, especially in cloud networks where changing ranges can mean rebuilding.
  • Avoid overlaps with networks you may connect to: a branch office, a VPN partner or a cloud provider. Two sites both using 192.168.1.0/24 cannot be joined cleanly by VPN.
  • Use private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) for internal networks.
  • Document everything in a simple table: subnet, purpose, VLAN, gateway.
  • Use a calculator to double-check. Our subnet calculator shows the network, broadcast, mask and usable range for any address and prefix.

Subnets are only half the job: the firewall rules between them decide what can actually communicate. If you are designing a network for a new office or a cloud environment, plan both together, or talk to a cloud and network specialist before addresses are in use.

Key takeaways

  • Subnetting splits one network into smaller ones by moving the boundary between network and host bits.
  • Each subnet loses two addresses: the network address and the broadcast address.
  • Block size = 256 minus the mask's interesting octet; subnets start on multiples of that size.
  • Plan for growth, avoid overlapping ranges, and verify with a calculator.

Need help with this?

Netifi helps businesses around the world with Networking. Tell us what you are working on.