Public vs. private IP addresses
The exhaustion of IPv4 addresses
IP addresses fall into two main categories:
- Public IP addresses are globally unique and are required to communicate on the public Internet.
- Private IP addresses are only meaningful inside a local network (like a home network or an organization’s internal network).
This split exists because of how IPv4 addressing developed.
In the 1980s and 1990s, there was no practical distinction between “public” and “private” IP addresses. Government organizations, universities, and enterprises used IP addresses internally and also used those same addresses to access the Internet.
IP address allocation is overseen by the Internet Assigned Numbers Authority (IANA). When an organization needed a block of IP addresses, it requested that block through IANA.
As the Internet (and TCP/IP) became more popular - especially in homes - it became clear that IPv4 addresses would eventually run out, particularly given how quickly large blocks were being allocated.
To slow down the shortage, a proposal introduced the idea of reserving specific IP ranges for internal use. Organizations and home users could use these addresses inside their networks, and then purchase only one (or a small number) of public IP addresses for Internet access.
The key rule was this:
- You can use addresses from the private ranges inside your network.
- Those private addresses must not be routed on the public Internet.
Because private addresses aren’t routed globally, many different organizations can reuse the same private IP addresses internally without conflict.
This proposal was documented in Request for Comments (RFC) 1918. For that reason, private IP addresses are often called RFC 1918 addresses.
To let private-addressed devices access the Internet, the Internet-facing router performs a translation between private and public addresses:
- Outbound traffic: the router translates a private IP address to a public IP address.
- Inbound return traffic: the router translates the public IP address back to the correct private IP address.
This process is called Network Address Translation (NAT). We’ll discuss NAT in more detail in a later chapter.
(Image 135)
Image Title - Diagram of Private IP Addresses used within organizations and the Public IP Address space across the internet
RFC 1918 addressing plus NAT extended the usable life of IPv4 for many years. Even so, the public IPv4 address space was fully exhausted in 2019.
Because IPv4 exhaustion was expected, IPv6 was developed in the mid-1990s as the long-term replacement for IPv4 and the real solution to the address shortage. At the time of this writing, IPv6 still isn’t widely deployed. One reason is that RFC 1918 and NAT have worked efficiently for many networks, and many organizations have been hesitant to adapt. Even so, IPv6 support has been increasing steadily over the years.
Classes of IPv4 addresses
IPv4 addresses were originally divided into ranges called classes. The most common classes are Class A, Class B, and Class C. Each class has a default subnet mask.
A network administrator can change (extend) the default subnet mask. This is typically done to divide a larger network into smaller networks.
As discussed earlier, Class A, B and C also have a range of IP Addresses that are reserved for “Private” use, (the RFC 1918 addresses):
| Class | Public Range | Private Range | Default Subnet Mask |
|---|---|---|---|
| A | 1.0.0.0 - 126.255.255.255 | 10.0.0.0 - 10.255.255.255 | 255.0.0.0 |
| B | 128.0.0.0 - 191.255.255.255 | 172.16.0.0 - 172.31.255.255 | 255.255.0.0 |
| C | 192.0.0.0 - 223.255.255.255 | 192.168.0.0 - 192.168.255.255 | 255.255.255.0 |
Classless inter-domain routing (CIDR) notation
A subnet mask can be written in dotted decimal form, but it’s commonly written using Classless Inter-Domain Routing (CIDR) notation.
CIDR notation uses:
- a forward slash
{`/`} - followed by the number of “on” bits (1s) in the subnet mask
For example, the default subnet mask for a Class A network is 255.0.0.0. That mask has 8 bits set to 1, so in CIDR notation it’s written as: /8.
Placed next to a network address like 10.0.0.0, it looks like this: 10.0.0.0/8
That means the same thing as: 10.0.0.0 255.0.0.0
Similarly:
- Class B’s default subnet mask is 255.255.0.0, which has 16 on bits, so it’s written as: /16
For example: 172.16.0.0/16
- Class C’s default subnet mask is 255.255.255.0, which has 24 on bits, so it’s written as: /24
For example: 192.168.1.0/24
CIDR is simply another way to write a network address together with its subnet mask.
You’ll also see two common synonyms:
- A network address can be called a: Prefix
- A subnet mask can be called a: Prefix Length
These terms are synonymous and interchangeable.