An IP address identifies a device on a network. IPv4 uses 32 bits written as four octets (e.g. 192.168.1.10); IPv6 uses 128 bits to solve address exhaustion. An address splits into a network part and a host part, and a subnet mask says where that split is.
Network vs host & the subnet mask
The subnet mask (e.g. 255.255.255.0, or /24) marks which bits are the network and which are the host. Devices on the same network share the same network part. Subnetting borrows host bits to create more, smaller networks.
Key facts to memorise
- IPv4 = 32 bits (4 octets); IPv6 = 128 bits.
- Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 — not routable on the public internet.
- A /24 network has 256 addresses, but only 254 usable hosts (network and broadcast are reserved).
- Loopback is 127.0.0.1; 0.0.0.0 means 'any/unspecified'.
⚡ The edge
- For a /n network, usable hosts = 2^(32−n) − 2 (subtracting the network and broadcast addresses). A /24 gives 2^8 − 2 = 254.
- Private IPs need NAT to reach the internet — NAT translates many private addresses to one public address, which is also why IPv4 has survived address exhaustion.
Worked example
'How many usable host addresses are in a /26 network?'
- A /26 leaves 32 − 26 = 6 host bits.
- Total addresses = 2^6 = 64.
- Subtract the network and broadcast addresses: 64 − 2 = 62 usable hosts.
Answer: 62 usable hosts (2^6 − 2)
Worked example
'Why do we have private IP addresses and NAT?'
- IPv4 has only ~4.3 billion addresses, far fewer than the world's devices.
- Private ranges let countless internal networks reuse the same addresses behind a router.
- NAT maps those private addresses to a shared public address, conserving public IPs and adding a layer of isolation.
Answer: Private ranges + NAT let many devices share few public IPs, conserving the limited IPv4 space.
⚠ Watch out
- Usable hosts is 2^(host bits) minus 2 (network + broadcast), not the full count.
- Private addresses are not routable on the public internet — they require NAT.
- Don't confuse the subnet mask (network/host split) with the gateway (the router's address).