Networking
2 min read
How to Distinguish Private, Public, and Loopback IPv4 Addresses
Learn how to classify IPv4 addresses safely when debugging networks, allowlists, containers, and local development environments.
An IPv4 address is not automatically reachable from the internet just because it has four numeric parts. Private networks, loopback addresses, link-local addresses, multicast ranges, and public addresses have different behavior. Correct classification helps when an application works on a laptop but fails in a container, a firewall rule is too broad, or a support ticket reports a host that cannot be reached.
## Validate all four octets first
A standard IPv4 address contains four decimal octets from 0 through 255. Reject values with five parts, negative values, text, or a number outside that range. Avoid accepting an ambiguous notation just because a library happens to parse it. A strict input rule makes logs and access policies easier to audit.
The CalcSnippets IPv4 Address Validator checks address shape and identifies common ranges. It is useful for copied inventories and incident notes. Classification is still only one fact about reachability: DNS, routing, NAT, VPNs, security groups, and local firewalls may all decide whether a connection succeeds.
## Know the common non-public ranges
`127.0.0.0/8` is loopback and refers back to the local machine. `10.0.0.0/8`, `172.16.0.0/12`, and `192.168.0.0/16` are private ranges used behind routers and cloud networks. `169.254.0.0/16` is link-local, often assigned when normal network configuration fails. Addresses at 224 and above have special multicast or reserved behavior and should not be treated as ordinary hosts.
When you make an allowlist, use CIDR ranges and document why each one exists. Do not allow every private address merely because it sounds safe; an internal request path can still be abused for server-side request forgery. Resolve hostnames carefully and validate the final connection target after redirects when the system fetches user-supplied URLs.
## Debug from the route outward
Start with the service binding. A process listening only on `127.0.0.1` will not accept a connection from another machine, even when the local browser works. Then check the container port mapping, host firewall, cloud security group, and route. Make each layer observable with a narrow test rather than changing all configuration at once. Network work becomes much faster when an address classification is paired with evidence about the actual path.