Skip to main content
RunBook Academy

LinuxXIX · Networking FoundationsIPv4

IPv4 addressing, subnetting, and CIDR

Foundation⏱ ~14 minipcalcip

What you'll learn

  • Read an IPv4 address and its prefix length
  • Calculate the network, broadcast, and usable host ranges
  • Choose a subnet size for a production use case
  • Recognise the private address ranges defined by RFC 1918

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

IPv4 is still the dominant layer-3 protocol in production. Its address space is small (about 4.3 billion) and nearly exhausted, but every sysadmin must understand its structure to configure hosts, design subnets, and read firewall rules.

Address format

An IPv4 address is 32 bits, written as four decimal octets:

10.0.0.5
192.168.1.100
203.0.113.42

The leading bits determine the network portion; the trailing bits identify the host. A prefix length (CIDR notation) tells you where the split is.

PrefixMeaningHosts
/32Single host1
/30Point-to-point link2 usable
/29Tiny subnet6 usable
/28Small subnet14 usable
/24Classic class C254 usable
/16Class B65,534 usable
/8Class A16,777,214 usable

Two addresses per subnet are always reserved: the network address (all host bits zero) and the broadcast address (all host bits one).

Calculate a subnet

ipcalc 10.10.0.0/24
ipcalc 10.10.0.0/26
ipcalc 10.10.0.50/26 -n

ipcalc is part of the ipcalc package on Debian-derived distros and is in initscripts on RHEL. The -n flag shows the network range.

Worked example: 10.10.0.0/26

The /26 means 26 bits of network and 6 bits of host. 2^6 = 64 addresses total, 62 usable.

ItemValue
Network10.10.0.0
First usable10.10.0.1
Last usable10.10.0.62
Broadcast10.10.0.63
Total addresses64
Usable hosts62

Always leave room for the gateway, monitoring agents, and future growth. A /30 is correct for a point-to-point link but not for a server subnet.

Private address ranges (RFC 1918)

Three ranges are reserved for private use and not routable on the public internet:

RangePrefixUse
10.0.0.0 - 10.255.255.25510.0.0.0/8Large private networks
172.16.0.0 - 172.31.255.255172.16.0.0/12Medium private networks
192.168.0.0 - 192.168.255.255192.168.0.0/16Home and small office

There are also the CGNAT range (100.64.0.0/10) and the link-local range (169.254.0.0/16) used by IPv4 zeroconf.

Subnet design discipline

When you design a subnet:

  1. Estimate the host count including monitoring agents, load balancers, and gateway IPs.
  2. Round up to the nearest CIDR that fits with room to spare. A 50-host subnet should be a /25 (126 usable), not a /26.
  3. Document the allocation in an IPAM tool or spreadsheet. Undocumented networks become unmanageable within a year.
  4. Reserve the first 10 and last 10 addresses for network infrastructure (gateway, monitoring, future expansion).
ip -4 addr show
ip -4 route
ip -4 neigh show

The -4 flag forces IPv4 output. Without it, dual-stack hosts show both IPv4 and IPv6, which is usually what you want but sometimes gets in the way of a quick check.

Knowledge check

Knowledge check · 3 questions

  1. Q1. How many usable host addresses does a /27 subnet have?

  2. Q2. Which of these is a private (RFC 1918) address?

  3. Q3. Which of the following statements about IPv4 subnetting are correct? Select all that apply.

Passing score: 75%. Answers are checked in this browser.