The Short Answer
Whether an address is public or private depends only on the range it comes from. These ranges are reserved and never routed on the public internet:
| Range | Purpose |
|---|---|
10.0.0.0/8 | Private (RFC 1918) |
172.16.0.0/12 | Private (RFC 1918) |
192.168.0.0/16 | Private (RFC 1918) |
100.64.0.0/10 | Shared, for carrier-grade NAT (RFC 6598) |
169.254.0.0/16 | Link-local (RFC 3927) |
127.0.0.0/8 | Loopback, this machine only |
Addresses that regional registries assign to networks are public. The address 203.0.113.10 in the examples here comes from a block reserved for documentation (RFC 5737) and stands in for a public address. If the /12 and /16 parts are unfamiliar, see subnet masks and CIDR notation.
The Reserved Ranges in Detail
- RFC 1918: the three classic private ranges, used in offices, homes, and private networks between servers. Note that
172.16.0.0/12runs from 172.16.0.0 to 172.31.255.255; 172.32.0.1 is a public address. - Shared address space:
100.64.0.0/10is used by internet providers for carrier-grade NAT, which places many customers behind shared public addresses. If your own connection has an address from it, you usually cannot accept inbound connections on it. - Link-local: some systems give an interface a
169.254.x.xaddress when no DHCP server answers. Many cloud platforms also run an instance metadata service at169.254.169.254. - IPv6: the equivalents are unique local addresses in
fc00::/7(in practicefd00::/8) and link-local addresses infe80::/10. See IPv4 vs IPv6.
How Private Addresses Reach the Internet
A device with only a private address goes online through a gateway that performs network address translation: it replaces the private source address with its own public one and keeps track of the connection so the reply finds its way back. That is how a whole office shares one public address. The mechanism and its limits are covered in what is NAT.
On Your Server: See Both Addresses
List the addresses configured on the interfaces:
ip -4 a
ip r
Each inet line is one address with its prefix length, for example inet 203.0.113.10/24. The default via line of ip r shows the gateway that traffic to the internet leaves through. Then ask an outside service which address it sees; ifconfig.me, for example, answers a plain curl request with the address alone:
curl -4 https://ifconfig.me
This is a third-party service, and it sees the request and your address. The authoritative list of your server's public addresses is in your provider's control panel.
- Same address in both: the public address sits on the server itself.
- Private address locally, another one outside: the server is behind NAT. Inbound connections only work if the gateway forwards them.
- Two interfaces: one public and one private, typical when servers share a private network.
Private Networks Between Servers
When several servers work together, a web server and a database server for example, a private network keeps their traffic off the public interface. Give each server a second interface with an address such as 10.10.0.11/24, and let the services talk over those addresses. The traffic never crosses the internet and cannot be reached from it.
A private network is not automatically a trusted one. Other machines in it can still reach your ports, and traffic in it is not encrypted unless you add encryption. Keep firewall rules on the private interface too, allowing only the servers that need each port.
Why a Database Belongs on a Private or Loopback Address
A database that listens on the public address is soon found by the scanners that probe every public address. Bind it to the address its clients use:
- Same server:
127.0.0.1, so only local programs connect. See what is localhost. - Other servers: the private address, with the firewall allowing only the application servers.
Check what a service listens on with sudo ss -tlnp. A line with 0.0.0.0:3306 means MySQL accepts connections on every address, including the public one. The safe setup is described in MySQL remote access.
Common Mistakes
- A DNS record with a private address: visitors outside your network cannot reach it.
- Overlapping ranges: a VPN or private network that uses the same range as your office, such as
192.168.1.0/24on both sides, sends traffic to the wrong place. Pick a less common range, such as part of10.0.0.0/8. - Treating private as secure: it only means unreachable from the internet, not protected from everything else.