IPv4 Addressing Basics
What an IPv4 address is, how the subnet mask splits it into a network part and a host part, which ranges are private, and why 169.254.x.x on your laptop means something went wrong.
An address for a packet
MAC addresses identify a device on one local link. To reach a device on another network, packets need an address that says which network the device belongs to, and that can be organised so routers do not need to know every device in the world. That is the job of the IP address.
An IPv4 address is 32 bits long. For people it is written as four numbers (octets) from 0 to 255 separated by dots: 192.168.1.25. Each octet is 8 bits, so the same address in binary is:
192 .168 .1 .25
11000000 .10101000 .00000001 .00011001
32 bits allow about 4.3 billion addresses. That sounded like plenty in the 1980s; it is the reason IPv6 exists (covered later in this course).
Network part and host part
Every IPv4 address is really two things glued together:
- a network part, shared by every device on the same network, and
- a host part, which identifies one device within that network.
The subnet mask says where the split is. It is another 32-bit value: ones for the network part, zeros for the host part.
Address 192.168.1.25 11000000.10101000.00000001.00011001
Subnet mask 255.255.255.0 11111111.11111111.11111111.00000000
----------------------------------------
Network part: 192.168.1 | Host part: .25
The mask 255.255.255.0 has 24 ones, so it is also written /24 (“slash 24”, or prefix length): 192.168.1.25/24. Two hosts are on the same network exactly when the network parts of their addresses are identical, which is how a host decides whether to deliver locally or send to its gateway (next lessons).
Two addresses in every network are reserved:
- the network address, with all host bits 0 (
192.168.1.0), which names the network itself, and - the broadcast address, with all host bits 1 (
192.168.1.255), which means “every host on this network”.
So a /24 has 256 addresses but 254 usable host addresses. Working out these numbers for any mask is the subject of the next lesson.
Public and private addresses
Public addresses are unique across the internet and are allocated through regional registries and ISPs. Because IPv4 addresses are scarce, RFC 1918 reserves three blocks for private use. They are not routed on the public internet, so any organisation can reuse them internally:
| Block | Range | Typical use |
|---|---|---|
10.0.0.0/8 |
10.0.0.0 to 10.255.255.255 | Large organisations, cloud networks |
172.16.0.0/12 |
172.16.0.0 to 172.31.255.255 | Medium networks |
192.168.0.0/16 |
192.168.0.0 to 192.168.255.255 | Homes and small offices |
Your home router uses one of these on the inside and translates to a single public address when your traffic goes out (NAT, covered in a later lesson).
Other special addresses worth recognising
| Address | Meaning |
|---|---|
127.0.0.0/8 (usually 127.0.0.1) |
Loopback: the device itself. ping 127.0.0.1 tests the local network software, not the cable. |
169.254.0.0/16 |
Link-local (RFC 3927). A host gives itself one of these when it cannot get an address from DHCP. Seeing it means “DHCP failed”. |
0.0.0.0 |
“This host” or “unspecified”, used before a host has an address. As a route, 0.0.0.0/0 means “everywhere”, the default route. |
255.255.255.255 |
Limited broadcast: all hosts on the local network. |
224.0.0.0/4 |
Multicast: one sender, a group of receivers. |
100.64.0.0/10 |
Shared address space (RFC 6598) used by ISPs for carrier-grade NAT. |
Static and dynamic addressing
A host can receive its address in two ways:
- Static: someone types the address, mask, gateway and DNS servers into the device. Good for servers, routers and printers that must always be found at the same address.
- Dynamic (DHCP): the host asks a server for a lease. Good for laptops and phones. This is covered in the DHCP lesson.
A host needs four settings to work properly: IP address, subnet mask, default gateway and DNS server.
See your own settings
# Windows
ipconfig /all
# Linux
ip -4 addr show
ip route
Identify your address, your mask (shown as a prefix such as /24), and your default gateway. Then decide: is your address private? It almost certainly is. To see your public address, ask an external service, for example curl https://api.ipify.org; it will differ from your local one.
What are the network address, broadcast address and usable host range for 192.168.50.77/24?
Network address 192.168.50.0, broadcast address 192.168.50.255, usable hosts 192.168.50.1 to 192.168.50.254 (254 hosts). The mask /24 leaves the last octet for hosts: all zeros is the network, all ones is the broadcast.
Can You Explain It?
Close the lesson and answer these without looking back. The goal isn't the wording — it's whether you've formed a usable mental model.
- What does the subnet mask tell a host, and how is /24 related to 255.255.255.0?
- Why are two addresses in every subnet unusable for hosts?
- A colleague's laptop has 169.254.12.4. What is your diagnosis and where do you look first?
🧪 Want to practise this on your own computer? See how to set up your lab →