Sub topic 13
Pitfalls: range boundaries and overlapping networks
This chapter assumes you can read CIDR prefixes and know the three RFC 1918 ranges. It covers two mistakes that cause real outages: misjudging where a private range ends, and giving two networks addresses that overlap.
Range boundaries
The ranges 10.0.0.0/8 and 192.168.0.0/16 are easy to remember because they match whole octets. The 172.16.0.0/12 range does not. A /12 fixes 12 bits, so the second octet is only partly fixed. The first 4 bits of that octet are 0001, which allows 16 through 31.
| Address | Private? | Reason |
|---|---|---|
| 172.15.255.255 | No | One below the range start |
| 172.16.0.0 | Yes | First address of the range |
| 172.31.255.255 | Yes | Last address of the range |
| 172.32.0.1 | No | Outside the range, so it is public |
A common mistake is to treat everything that starts with 172 as private. A firewall rule or an "is this internal?" check written that way will treat public addresses as trusted.
import ipaddress
net = ipaddress.ip_network("172.16.0.0/12")
print(net.network_address) # 172.16.0.0
print(net.broadcast_address) # 172.31.255.255
print(ipaddress.ip_address("172.32.0.1") in net) # FalseHost bits cause a related error. The prefix must describe a network, so the bits after it must be zero. ip_network("172.16.5.4/12") raises ValueError because it has host bits set. Pass strict=False if you want it normalized to 172.16.0.0/12.
The is_private property of the ipaddress module is broader than RFC 1918. It also returns True for loopback, link-local, and other special ranges. When you need only the three RFC 1918 networks, test membership against an explicit list.
Overlapping networks
Private addresses are not globally unique. Every home router can use 192.168.1.0/24, and so can every office. This is fine until two networks must be connected, for example by a VPN, a cloud peering link, or a company merger. A router cannot tell which 192.168.1.10 you mean, so it cannot forward traffic correctly.
Overlap does not require identical prefixes. Two networks overlap when one contains any address of the other. A smaller prefix contains the larger-prefix network that lies inside it.
import ipaddress
office = ipaddress.ip_network("10.0.0.0/16")
branch = ipaddress.ip_network("10.0.128.0/17")
cloud = ipaddress.ip_network("10.1.0.0/16")
print(office.overlaps(branch)) # True: the /17 is the upper half of the /16
print(office.overlaps(cloud)) # FalseHow to avoid it
- Do not use 192.168.0.0/24 or 192.168.1.0/24 for anything you may connect later. These are the most common home and office defaults, so they conflict most often.
- Keep a central list of allocated prefixes and check each new one against it before you use it.
- Choose prefixes from the large 10.0.0.0/8 range, and give each site or environment its own block.
- Leave room to grow. Renumbering a live network is far harder than reserving space at the start.
If overlap already exists, you have two options. You can renumber one side, which is permanent but disruptive. Or you can translate addresses at the boundary with NAT, which is quicker but makes troubleshooting and logging harder.
Exercise
A team uses 10.0.0.0/24 for servers. Another team proposes 10.0.0.128/25 for a new lab. Do the two networks overlap? Is 172.32.10.5 a private address?
Show answer
Yes, they overlap. 10.0.0.128/25 covers 10.0.0.128 to 10.0.0.255, which is the upper half of 10.0.0.0/24 (10.0.0.0 to 10.0.0.255). No, 172.32.10.5 is not private. The 172.16.0.0/12 range ends at 172.31.255.255, so 172.32.x.x is public.