Lesson 1 of 18 · 20m
IP Addresses and Subnets: An Address Is a Position, Not a Name
CIDR math you'll actually use, the RFC 1918 and special-use ranges that decide reachability, and why 169.254.169.254 is a security boundary.
An EC2 instance gets 10.0.4.23, a pod gets 10.244.3.17, your laptop gets 192.168.1.50, and ip addr on all three insists the machine is somehow also 127.0.0.1. Who assigns these, and who decided 172.20.0.5 is private but 172.32.0.5 is routable? Once you stop reading an IP as "the machine's name" and start reading it as a lease inside a range, subnet math stops being trivia and becomes the thing that tells you who can reach what.
An address is a position, not a name
The wrong mental model: "the server's IP is 10.0.4.23." The right one: "that interface currently holds 10.0.4.23." A host has one address per interface per family — ip addr lists them all — plus addresses that move: VIPs fail over between machines, containers share the host's address through NAT, and your laptop's "IP" is really the NAT's public address to everyone outside. When a connection breaks after a failover, the first question is which interface and which range the traffic was actually using, and ip route get <dst> answers it in one line.
CIDR: the only math that matters
An IPv4 address is 32 bits. The /n suffix says how many leading bits name the network; the rest name the host inside it. /24 leaves 8 host bits: 256 addresses, of which the first (network) and last (broadcast) are reserved on Ethernet — 254 usable. The table you actually use:
| CIDR | Total | Usable hosts | Typical use |
|---|---|---|---|
| /32 | 1 | 1 | single host route |
| /30 | 4 | 2 | old point-to-point links |
| /31 | 2 | 2 | point-to-point, RFC 3021 — no broadcast |
| /26 | 64 | 62 | a small service tier |
| /24 | 256 | 254 | the "default" LAN |
| /22 | 1024 | 1022 | a mid-size VPC subnet |
| /16 | 65536 | 65534 | enterprise block |
10.0.4.23/22 doesn't just mean "10.0.4.23" — it means the network 10.0.4.0, broadcast 10.0.7.255, usable 10.0.4.1–10.0.7.254. Get the boundary wrong and your "same subnet" assumption is wrong too: 10.0.4.23/22 and 10.0.8.10/22 are in different networks and need a router between them. The stdlib does the math honestly:
import ipaddress
n = ipaddress.ip_network("10.0.4.0/22")
print(n.network_address, n.broadcast_address, n.num_addresses)
# 10.0.4.0 10.0.7.255 1024The ranges that aren't yours
RFC 1918 carved out three blocks that no public router will forward — this is the entire reason "private" addresses exist:
10.0.0.0/8— the big one, the default VPC choice172.16.0.0/12— only172.16.0.0–172.31.255.255.172.32.x.xand172.15.x.xare public. Hand-written ACLs that pattern-match "172." get owned by exactly this misread.192.168.0.0/16— home gear
And the special-use blocks that bite you if you only know RFC 1918:
127.0.0.0/8— loopback. The whole /8 loops;127.0.0.53is how systemd-resolved parks a local resolver,127.53.0.1is a valid trick for per-service stub DNS.169.254.0.0/16— link-local/APIPA. Also where169.254.169.254lives: the cloud metadata endpoint on AWS, GCP, and Azure. It is reachable from inside the instance only — which is precisely why your "fetch this URL for me" feature must denylist it, or SSRF turns into IAM credential theft.100.64.0.0/10— carrier-grade NAT (RFC 6598). Tailscale assigns node addresses here. It's private-ish, not RFC 1918 — allowlist it explicitly or break your own VPN.192.0.2.0/24,198.51.100.0/24,203.0.113.0/24— documentation ranges (RFC 5737). Use them in examples so your docs never point at someone's real host.224.0.0.0/4— multicast.240.0.0.0/4— reserved, unroutable in practice.
IPv6 in one paragraph
128 bits, hex, :: compresses one run of zeros once. The ranges that matter: fe80::/10 link-local (needs a zone id — ping6 fe80::1%eth0), fc00::/7 ULA (the RFC-1918-ish private space), ::1 loopback, 2001:db8::/32 documentation. There is no broadcast — multicast groups like ff02::1 took its job. The standard subnet is a /64; routers assign addresses via SLAAC (prefix + EUI-64 or randomized), and 2001:4860:4860::8888 is still Google's DNS. getaddrinfo() prefers IPv6 answers per RFC 6724, which is why adding an AAAA record can reroute your traffic without anyone touching code.
Try this
ip -4 addr show scope global # what this host advertises
python3 - <<'EOF'
import ipaddress
for a in ("172.20.1.5","172.32.1.5","100.64.1.1","169.254.169.254","127.53.0.1"):
ip = ipaddress.ip_address(a)
print(f"{a:18} private={ip.is_private} global={ip.is_global} loopback={ip.is_loopback} link_local={ip.is_link_local}")
EOFClassify every address you meet before reasoning about reachability — public, private, link-local, loopback, CGNAT. Half of "why can't they reach me" is a misclassification, and now it takes you ten seconds to check.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
What is a Web Server? Apache, Nginx, and How the Internet Delivers Web Pages
A web server accepts HTTP requests and returns responses. Apache has been doing this since 1995. Nginx rebuilt the model in 2004 and took over the cloud. Here's how they work, how they differ, and how to pick between them.
How to Install NGINX on Debian & Ubuntu: Server Blocks, HTTPS and Reverse Proxy
When it comes to running a web server for all of my online projects, NGINX is the first that comes to mind for me. By default, it follows my guidelines of running a piece of software – meaning that the software is security-minded, performance-driven, and honestly, really easy to manage all the aspects of it. NGINX is most likely the most popular web server software in the world, and it's well known for being the backbone of some of the biggest sites on the internet to date. It is a lightweight
Minecraft 26.4 Replaced Its Decade-Old Login Crypto. Here's What key-rotation-period-seconds Actually Does.
26.4 Snapshot 9 rewrote how a Java Edition client and server agree on an encryption key. RSA-1024 is out, X25519 is in, and a new key-rotation-period-seconds setting decides how often the server's key changes. I opened the snapshot server jar, timed the login crypto, and checked what changes for...
The Same Researcher Broke apt the Same Way Twice, Seven Years Apart
In 2019 Max Justicz showed apt would install a package an attacker swapped in over a redirect. In November 2026 he did it again, CVE-2026-109518, through a different door that ends in the same place: code as root from a man in the middle. The fix shows how apt reuses files on disk.