unicornAll work
All theoryNetworking

IP addressing & subnetting

What an IP and a subnet mask mean, how to read CIDR, and what to tell nmap to scan.

In a nutshell An IP address is a device's number on a network, and a subnet mask splits that number into "which network" and "which host on it." Understanding this lets you read a target's address range, know how big a network is, and tell nmap exactly what to scan.

The IP address

An IPv4 address is four numbers 0–255 joined by dots — 192.168.1.10 — really 32 bits (four bytes). Every device needs a unique one to be reached. Some ranges are private, reserved for internal networks and never routed on the public internet:

10.0.0.0    – 10.255.255.255     (one huge block)
172.16.0.0  – 172.31.255.255     (16 blocks)
192.168.0.0 – 192.168.255.255    (home routers live here)

Seeing 192.168.x.x or 10.x.x.x in a scan means you're on an internal network.

The subnet mask — where the network ends

An address has two parts: the network part (which network) and the host part (which device on it). The mask is the line between them.

192 168 1 10 network part — /24 host 192.168.1.10 / 255.255.255.0
A /24 mask: the first three octets are the network, the last octet is the host.

Analogy — a postal address. "City + street" is the network part (gets a letter to the right neighbourhood); "house number" is the host part (which door). The mask says how much of the address is neighbourhood vs house.

Reading CIDR quickly

The number after the slash is how many bits belong to the network; the rest are hosts.

CIDR Mask Usable hosts Meaning
/24 255.255.255.0 254 one typical LAN
/16 255.255.0.0 65,534 a big environment
/30 255.255.255.252 2 a point-to-point link
/32 255.255.255.255 1 a single host

For 192.168.1.0/24: network is .0, usable hosts .1.254, and .255 is the broadcast address (talks to everyone at once).

Why it matters in practice

nmap 192.168.1.0/24     # scan all 254 hosts of this LAN in one command
nmap 10.10.10.5/32      # exactly one host
The quick mental math Hosts in a subnet = 2^(32 − prefix) − 2 (drop network + broadcast). /24 → 2^8 − 2 = 254. /25 → 126. /26 → 62. Halving the host space each time you add a bit to the prefix.

IPv6 exists too, with vastly more addresses and a different notation, but the same idea of a network part and a host part holds.

All theory