What an address is for
Every device on a network needs an identifier so that data can be sent to it and replies can come back. On most home networks that identifier is an IPv4 address: four numbers between 0 and 255 separated by dots, such as 192.168.1.20. Each of the four numbers is one byte, so an address is 32 bits in total. A newer format, IPv6, uses much longer addresses and is increasingly common, but the ideas below, an address plus a way to tell which addresses are local, apply to both. This article uses IPv4 for its examples because it is what most home equipment shows you by default.
Public and private addresses
Your internet connection has a public address, which is how the rest of the internet sees your home. The devices inside normally use private addresses. Three ranges are set aside for private use and are not routed on the public internet:
- 10.0.0.0 to 10.255.255.255
- 172.16.0.0 to 172.31.255.255
- 192.168.0.0 to 192.168.255.255
Because these ranges are reused in millions of homes, the router performs network address translation, or NAT, so that many private devices can share one public address. Two consequences matter to builders. Devices behind NAT are not directly reachable from outside unless you configure it, which is part of why exposing services needs thought. And if you connect two networks that use the same private range, for example when a remote VPN tunnel joins your home to another location, the overlap causes confusion, so choosing a less common range from the private blocks at the start can save trouble later.
Network part and host part
An address has two conceptual halves: the part that identifies the network and the part that identifies the device on it. A subnet mask says where the split falls. You will see it written two ways:
- Dotted form, such as 255.255.255.0.
- Slash form, also called CIDR notation, such as /24, which means the first 24 bits are the network part.
These are the same thing. A /24 means the first three numbers identify the network and the last number identifies the device. So 192.168.1.20/24 is device 20 on the network 192.168.1.0.
Two devices can talk directly only if they are on the same subnet. To reach anything outside it, they send traffic to a default gateway, which is normally your router. This is why a device with the wrong mask or gateway can reach some machines but not others.
How many addresses fit
The number of addresses depends on how many bits remain for the device part. For a /24 there are 8 bits left, giving 2 to the power 8, or 256 addresses. Two are reserved: the first, 192.168.1.0 in our example, names the network itself, and the last, 192.168.1.255, is the broadcast address used to reach everyone at once. That leaves 254 usable device addresses.
A few more examples, calculated the same way:
| Size | Addresses | Usable devices |
|---|---|---|
| /24 | 256 | 254 |
| /25 | 128 | 126 |
| /26 | 64 | 62 |
| /27 | 32 | 30 |
| /28 | 16 | 14 |
A home rarely needs more than a /24 per zone. Smaller subnets are tidier when you want to separate groups of devices, and each separate subnet needs its own range, which is the basis of network segmentation. If you do not like arithmetic, an online subnet calculator will give the same answers; it is still worth understanding the logic so you can sanity-check the output.
DHCP: how devices get addresses
Typing an address into every device would be tedious, so most networks run a DHCP service, usually on the router. When a device joins, it asks for an address. The DHCP service offers one from a configured pool, along with the mask, the default gateway and the DNS resolver to use. The grant lasts for a lease time, after which the device asks to renew it.
Because addresses are leased, a device may get a different one after being offline for a while. That is fine for phones and laptops, but a problem for servers and project devices that other things need to find.
Fixed addresses for lab devices
There are two common ways to give a device a stable address:
- A DHCP reservation. You tell the router to always give a specific address to a device, identified by its hardware address. The device still asks via DHCP, and everything is managed in one place. This is generally the tidier approach.
- A static setting on the device. You configure the address, mask, gateway and resolver on the device itself. It works without a DHCP server but is easy to get wrong and easy to forget.
Whichever you pick, keep the fixed addresses outside the pool that DHCP hands out dynamically, to avoid two devices being given the same address. A conflict produces intermittent, confusing failures. A simple scheme, such as low numbers for infrastructure, a middle block for reserved lab machines and the upper block for the dynamic pool, is easy to remember. Write the scheme down.
Special addresses worth recognising
- 127.0.0.1 refers to the device itself, called loopback. It is useful for testing a service locally.
- 169.254.x.x often appears when a device expected an address from DHCP and did not receive one. If you see it, look for a DHCP or cabling problem.
- 0.0.0.0 in a service configuration usually means “listen on all addresses”, which can be convenient and also a little risky if the device is reachable from places you did not intend.
Putting it to use
When two devices cannot reach each other, ask three questions. Are they on the same subnet, according to their addresses and masks? If not, is a gateway configured and are there rules in the router permitting the traffic? Does the name resolve, or are you using the numeric address, a separation that DNS resolution explains? Many networking puzzles turn out to be one of those three.
Understanding addresses, masks and DHCP gives you the vocabulary to read your router’s settings with confidence, plan zones sensibly and describe problems accurately when you ask for help.