IPv4 addresses
Every device on a network needs an address so messages can find it. Take one real-looking address, 192.168.1.20, apart: four numbers, each made of 8 bits, split into a network part (the street) and a host part (the house). Then meet the special ranges: private, loopback and public.
5 quick questions
Pick an answer to see why. Your score saves with your progress.
01Why can each of the four numbers in an IPv4 address only go up to 255?
One octet is 8 bits. 2 to the power 8 is 256, so the values run from 00000000 (0) to 11111111 (255).
02What is the 8-bit number 10101000 in decimal?
Add up the place values that hold a 1: 128 + 32 + 8 = 168. That is the second number of 192.168.1.20.
03In 192.168.1.20/24, which part is the network part?
/24 means the first 24 bits (the first three numbers) name the network. The last 8 bits, 20, name the device (the host).
04Which of these addresses is private (RFC 1918)?
172.16.0.0/12 runs from 172.16.0.0 to 172.31.255.255, so 172.20.4.1 is private. 172.40.0.1 is outside that range.
05You send a message to 127.0.0.1. Where does it go?
127.0.0.0/8 is loopback: it always means this device. Programmers use it to talk to programs on their own computer.
Glossary
- IP address
- A number that names a device's connection to a network, so messages can be sent to it.
- IPv4
- Version 4 of the Internet Protocol. Its addresses are 32 bits long.
- Bit
- The smallest piece of data: a single 0 or 1.
- Octet
- A group of 8 bits (a byte). An IPv4 address is four octets.
- Dotted decimal
- The usual way to write an IPv4 address: four numbers from 0 to 255 with dots between them.
- Prefix length
- The /n after an address. It says how many leading bits are the network part, e.g. /24.
- Private address
- An address from 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Reused in many homes and offices, never routed on the internet.
- Loopback
- 127.0.0.0/8, usually 127.0.0.1 (localhost): an address that always means this device.
Notes and sources
- IPv4 addresses are 32 bits long (RFC 791). The /n prefix notation comes from CIDR (RFC 4632).
- 192.168.1.20, 192.168.1.1 and 192.168.1.35 are private RFC 1918 addresses; 203.0.113.5 is an RFC 5737 documentation address standing in for a real public one.
- 127.0.0.0/8 is reserved for loopback by RFC 1122 §3.2.1.3; the special-purpose ranges are listed in RFC 6890.
- Prefix lengths do not have to fall between the dots (for example /20); the subnets lesson shows how that works.
- NAT (RFC 3022) and IPv6 (RFC 8200) each get their own lesson.
Quiz Unlocks after the last step.