Sub topic 9
Special-purpose address ranges
Not every IPv4 address can be assigned to a host on the public internet. Several ranges are set aside for specific jobs. This chapter assumes you can read dotted-decimal addresses, know that a prefix such as /8 gives the number of network bits, and know the class boundaries from earlier chapters.
The ranges to know
The table lists the special-purpose ranges you will meet most often.
| Range | Name | Purpose |
|---|---|---|
| 0.0.0.0/8 | "This network" | Source address used before a host has an address. 0.0.0.0 also means "any address" in server configuration. |
| 127.0.0.0/8 | Loopback | Traffic that never leaves the host. |
| 169.254.0.0/16 | Link-local | Self-assigned address when no DHCP server answers. |
| 224.0.0.0/4 | Multicast (class D) | One sender, many receivers. |
| 240.0.0.0/4 | Reserved (class E) | Held back for future use. |
| 255.255.255.255 | Limited broadcast | Every host on the local network segment. |
Loopback
Any address from 127.0.0.1 to 127.255.255.254 loops back to the same machine. The usual choice is 127.0.0.1, which the name localhost normally resolves to. The packet goes down the local network stack and straight back up. It never reaches a network card or a cable.
This block is a whole /8, which is about 16.7 million addresses. That is a large waste, but it cannot be reclaimed now.
Link-local
When a host is set to use DHCP and no server replies, many operating systems pick an address in 169.254.0.0/16 for themselves. Hosts on the same segment can then talk to each other. Routers do not forward link-local traffic.
If you see a 169.254.x.x address on a machine, the usual cause is a failed DHCP request.
Multicast and reserved space
The class D range 224.0.0.0 to 239.255.255.255 is for multicast. A multicast address names a group, and only hosts that joined the group receive the packets. You never assign one to an interface as its own address. For example, 224.0.0.5 is used by the OSPF routing protocol.
The class E range 240.0.0.0 to 255.255.255.254 is reserved. Ordinary hosts and routers do not use it.
Limited broadcast
255.255.255.255 sends a packet to every host on the local segment. Routers do not forward it. A DHCP client uses it as a destination when it asks for an address, because the client does not yet know any network details. This differs from a subnet's directed broadcast address, such as 192.168.1.255 for 192.168.1.0/24.
Checking ranges in Python
The ipaddress module has a property for each kind of special range.
import ipaddress
for text in ["127.0.0.1", "169.254.10.20", "224.0.0.5", "240.0.0.1", "8.8.8.8"]:
a = ipaddress.ip_address(text)
print(
text,
"loopback" if a.is_loopback else "",
"link-local" if a.is_link_local else "",
"multicast" if a.is_multicast else "",
"reserved" if a.is_reserved else "",
)Running this labels 127.0.0.1 as loopback, 169.254.10.20 as link-local, 224.0.0.5 as multicast, and 240.0.0.1 as reserved. 8.8.8.8 gets no label.
Diagram: where an address falls
The first octet is enough to place most addresses.
Common mistakes
- Treating
0.0.0.0as a normal host address. As a listening address it means all interfaces. As a source address it means "no address yet". - Assigning a 169.254.x.x address by hand and expecting it to route. Routers drop it.
- Assuming
is_privatein Python means only RFC 1918. It also returns true for loopback, link-local, and other special ranges.
Exercise
A laptop shows the address 169.254.33.7 and cannot reach the internet. Which range is this, and what most likely went wrong?
Show answer
It is link-local (169.254.0.0/16). The laptop probably asked for an address by DHCP, got no reply, and assigned itself one. Check the DHCP server and the network connection.
Exercise
Why can a packet sent to 255.255.255.255 never cross a router, while a packet sent to 192.168.1.255 might be handled differently?
Show answer
255.255.255.255 is the limited broadcast and is confined to the local segment. 192.168.1.255 is the directed broadcast of one subnet, so it names a specific network. Routers still block directed broadcasts by default in modern configurations, but the address itself identifies that subnet rather than the local one.