Why Are There Public and Private IP Addresses?
A public IP address is the IP you use via your router that allows you to communicate to other devices on the internet, much like a physical real-world address and building number. They are assigned by your internet service provider (ISP) as a way to allow worldwide device identification and communication.
Private IP addresses are used within local area networks (LAN) and allow the devices on private networks to communicate with each other. To use the address analogy, a private IP address would be the apartment number within a building.
It wasn't always this way. Public and private IP addresses as we know them today largely came into existence with the introduction of network address translation (NAT). In the early days of the internet, when there were only (relatively) few devices able to connect to the internet, every IP was unique as there were enough addresses for each to be publicly routable. Consisting of a 32-bit number, there are roughly 4.3 billion possible IPv4 addresses.
By 1993 it was becoming increasingly apparent that there would come a time when there were not enough unique IPs, a phenomenon called IPv4 address exhaustion (which did eventually happen in January 2011). NAT was introduced as a way to allow a local network to share a single public IP address, a process that requires one's private IP address to be translated into the public one when communicating with the internet. This effectively "bundled" all devices on a local network together, significantly reducing the demand for public IP addresses.
To address IPv4 exhaustion, IPv6 was introduced, providing a vastly larger address space with 128-bit addresses, allowing for an almost limitless number of unique IP addresses. While IPv6 adoption is growing, IPv4 remains widely used, and NAT continues to be an important technology for managing IPv4 address space.
Security implications of NAT
NAT had some interesting security implications too. By only having a single public-facing IP, the architecture of internal networks became hidden from the outside world, making it more difficult for external attackers to access any one specific device on the network. It also works as a very basic firewall because it only allows incoming traffic that arrives in response to outgoing requests.
Port forwarding took on a new dimension as a way for external devices to communicate with specific devices on the local network. For example, if you have a security camera installed outside your home, you would need to configure the port forwarding on your router to be able to connect to the camera from your phone while away.
Understanding public and private IP addresses is the foundation for understanding proxies, NAT, and routing. For related networking basics, read our guide on what an IP address is and Network Address Translation. If you are learning proxy architecture, continue with forward proxies and reverse proxies.
How Are Public and Private IP Addresses Assigned?
Private IP ranges
Private IPv4 addresses are reserved across three class ranges, sized to the network they're intended to serve.
- Public IP addresses are assigned by ISPs and can be dynamic or static. Dynamic IP addresses are assigned from a pool and may change over time, while static IP addresses remain constant and are often used for servers or important networked devices.
- ISPs obtain these addresses from regional internet registries (RIRs), which manage IP address allocation. Public IPv4 addresses fall within the range of 1.0.0.0 to 223.255.255.255, excluding addresses reserved for special purposes such as private networks, multicast, and experimental use.
- With the introduction of IPv6, the pool of available public IP addresses has significantly expanded. IPv6 addresses are typically assigned dynamically but can also be statically allocated for specific needs. IPv6 adoption helps alleviate the limitations of IPv4 by providing a larger address space.
Public and private IP addresses play important roles in ensuring effective and secure network communication. The difference between a public and private IP address is that a public address, assigned by ISPs, facilitates global connectivity, allowing devices to communicate across the internet. On the other hand, a private IP address, managed within local networks by routers or DHCP servers, is important for internal network organization and communication. It allows devices within the same network to interact without exposing internal infrastructure to the broader internet.
The introduction of NAT in the early 1990s has allowed multiple devices within a local network to share a single public IP address, significantly reducing the demand for public IP addresses and adding a layer of security by masking the internal network structure. Despite the introduction of IPv6, which provides a vastly larger address space, IPv4 and NAT remain integral to the way the internet works.
Key takeaways
What to remember about public and private IP addresses
- Public IPs identify devices on the open internet
- Private IPs identify devices within a local network
- NAT lets many devices share a single public IP
- ISPs assign public IPs, routers and DHCP assign private ones
- IPv6 expands the address space, but IPv4 and NAT remain dominant