All guides
Home Glossary Subnet
Term

Subnet

A logical subdivision of an IP network designed to improve routing efficiency, manage traffic, and enhance security.

A subnet (subnetwork) is a logical subdivision of an IP network designed to improve routing efficiency, manage traffic, and enhance security. By dividing a large block of IP addresses into smaller, isolated segments, administrators can organize complex cloud and on-premises infrastructures without purchasing separate physical networks. Subnetting is fundamental to managing address spaces across both IPv4 and IPv6 environments.

How it works

Subnetting works by applying a subnet mask (or CIDR prefix) to an IP address to split its bits into two parts: the network identifier and the host identifier. Routers and operating systems use this mask to determine whether a destination IP address sits on the local network or requires external routing.

When a server sends a data packet, its network stack performs a bitwise AND operation using its own IP address, its subnet mask, and the destination IP. If the resulting network identifiers match, the packet is delivered directly over Layer 2 (using ARP in IPv4 or Neighbor Discovery in IPv6). If they do not match, the host forwards the packet to its default gateway for Layer 3 routing across networks.

  • Traffic isolation: Restricts the size of broadcast domains so unnecessary broadcast traffic does not degrade performance across the entire infrastructure.
  • Security segmentation: Allows administrators to place public-facing load balancers in a public subnet while isolating databases and internal APIs in private subnets governed by strict firewall rules and Access Control Lists (ACLs).
  • Address conservation: Uses Classless Inter-Domain Routing (CIDR) to allocate right-sized IP blocks rather than wasting large legacy address classes.

Example

Suppose you are provisioning a Virtual Private Cloud (VPC) using the 192.168.1.0/24 address block, which provides 256 total IP addresses. To separate your web tier from your database tier, you split this block into two smaller subnets using a /25 CIDR prefix (subnet mask 255.255.255.128):

  • Public subnet (192.168.1.0/25): Usable host range from 192.168.1.1 to 192.168.1.126. Here, .0 is the reserved network address and .127 is the broadcast address.
  • Private subnet (192.168.1.128/25): Usable host range from 192.168.1.129 to 192.168.1.254. Here, .128 is the reserved network address and .255 is the broadcast address.

On a Linux host, you can inspect the active IP address and CIDR subnet prefix assigned to an interface using the ip utility:

ip -brief address show eth0
# Output: eth0  UP  192.168.1.10/25

What matters when choosing a server or hosting

When selecting a cloud provider, dedicated server, or virtual private server, check how the platform handles network segmentation and IP allocation:

  • Private networking support: Ensure the provider allows you to create custom VPCs with isolated private subnets so backend nodes can communicate without traversing the public internet.
  • CIDR flexibility and IPv6 readiness: Look for providers that let you define custom RFC 1918 private ranges and natively assign /64 IPv6 subnets to avoid future IPv4 exhaustion.
  • Reserved provider IPs: Cloud platforms often reserve additional addresses in every subnet for internal gateways, DNS resolvers, and management interfaces, reducing your usable host count.

Common mistakes

  • Sizing subnets too small: Choosing a /29 or /28 subnet leaves very few usable IPs after accounting for network, broadcast, and cloud-reserved addresses, making horizontal autoscaling impossible without rebuilding the network.
  • Overlapping CIDR blocks: Assigning the same private subnet range (such as 10.0.1.0/24) across multiple environments prevents you from connecting them later via VPN or VPC peering.
  • Exposing private subnets to an Internet Gateway: Attaching a direct route to an Internet Gateway on a subnet meant for internal workloads bypasses NAT isolation and exposes services to public scans.

FAQ

Why are the first and last IP addresses in an IPv4 subnet unusable?

In standard IPv4 networking, the very first address identifies the subnet itself (the network address), and the very last address is used to send traffic to all hosts simultaneously (the broadcast address). Assigning either to a server causes routing conflicts.

What is the difference between a public subnet and a private subnet?

A public subnet has a route table entry pointing outbound traffic directly to an Internet Gateway, allowing resources with public IPs to receive inbound internet traffic. A private subnet lacks a direct internet route and typically uses a NAT gateway for outbound updates only.

How does IPv6 subnetting differ from IPv4?

IPv6 eliminates broadcast addresses in favor of multicast and uses 128-bit addressing. Standard practice assigns a massive /64 prefix to every individual subnet, removing the need to conserve host addresses through tight subnet calculations.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.