Understanding Subnets and CIDR Notation

CIDR notation appears throughout firewall rules, network configuration, and cloud provider documentation. This guide explains what it means and how to work with it practically.

What Is an IP Address, Really?

An IPv4 address like 203.0.113.10 is actually a 32-bit number, conventionally written as four decimal numbers (0-255) separated by dots.

What Is a Subnet?

A subnet is a logical subdivision of a network — a defined range of IP addresses treated as a single group for routing purposes.

Understanding CIDR Notation

203.0.113.0/24

The /24 indicates how many bits of the address represent the network portion — the remaining bits identify individual hosts within that network.

Common CIDR Blocks Reference

CIDRSubnet MaskUsable Addresses
/32255.255.255.2551 (a single specific host)
/30255.255.255.2522
/29255.255.255.2486
/28255.255.255.24014
/24255.255.255.0254
/16255.255.0.065,534

Practical Example: Firewall Rules

sudo ufw allow from 203.0.113.10/32 to any port 22

/32 here means "exactly this one IP address" — the most common CIDR notation you'll use when restricting access to a single trusted IP.

sudo ufw allow from 203.0.113.0/24 to any port 22

This allows the entire range from 203.0.113.0 to 203.0.113.255 — useful for allowing an entire office or team's network range.

Private IP Address Ranges (RFC 1918)

RangeCIDR
10.0.0.0 – 10.255.255.25510.0.0.0/8
172.16.0.0 – 172.31.255.255172.16.0.0/12
192.168.0.0 – 192.168.255.255192.168.0.0/16

These ranges are reserved for private networks (like VPS provider internal/private networking) and are never routed on the public internet directly.

Calculating Available Hosts

The formula for usable host addresses in a subnet is 2^(32 - CIDR) - 2 (subtracting the network and broadcast addresses). For a /24: 2^8 - 2 = 254 usable addresses.

Using a CIDR Calculator

For quick reference without manual calculation, search for an online "CIDR calculator" — useful when planning firewall rules or private network ranges for multiple VPS instances.

Practical Use in VPS Networking

  • Restricting SSH access to a specific office IP: /32
  • Allowing an entire team's IP range: a larger block like /28 or /24, depending on team size
  • Private networking between your own VPS instances: typically a /24 or /16 private range

Common Errors

Firewall rule allows more/fewer IPs than intended — double-check the CIDR suffix; a common mistake is using /24 when only a single IP (/32) was actually intended, unintentionally allowing an entire range.

Related Articles

  • How to Configure UFW Firewall on a Linux VPS
  • How to Configure Multiple IP Addresses on One VPS
  • How to Set Up a Private Network Between Multiple VPS Instances
  • cidr notation, subnet, ip addressing, network basics
  • 0 Kasutajad peavad seda kasulikuks
Kas see vastus oli kasulik?

Seotud artiklid

DNS Fundamentals: A, AAAA, CNAME, MX, TXT & NS Records Explained

DNS translates human-readable domain names into the information servers actually need — IP...

How to Point a Domain to Your VPS (A/AAAA Records)

Before your website is reachable at yourdomain.com instead of a raw IP address, you need to...

How to Configure MX Records for Email Delivery

MX (Mail Exchange) records tell the internet which servers handle incoming email for your domain....

How to Use CNAME Records Correctly

CNAME records let you alias one domain name to another, but they come with important restrictions...

How to Enable and Configure IPv6 on Your VPS

IPv6 adoption continues to grow, and many VPS plans include a free IPv6 address alongside IPv4....