Are Public IPs Unique?

Understanding IP Addresses: A Beginner's Guide
The initial stages of learning about IP addresses and their functionality can often seem complex. A common approach to overcome this is to actively seek information and pose relevant questions.
This SuperUser Q&A post directly addresses the inquiries of a reader who is new to the subject.
The Source of the Information
The following question and answer exchange originates from SuperUser, a segment of Stack Exchange.
Stack Exchange is a network of question-and-answer websites maintained by its user community.
Image Attribution
The accompanying screenshot was kindly provided by Linux Screenshots, and is available on Flickr.
It visually illustrates concepts related to the discussion of IP addresses.
Learning about networking fundamentals, like IP addresses, requires a step-by-step approach.
Starting with basic inquiries and gradually building understanding is a highly effective method.
Understanding Public IP Address Uniqueness
A SuperUser user, amin gholami, recently inquired about the uniqueness of public IP addresses. The core of the question revolves around the distinction between private IPs and public IPs, and how multiple devices sharing a router relate to a single public IP.
The Role of Private vs. Public IPs
It's important to first clarify the difference between these two types of IP addresses. Private IP addresses are used within a local network, such as your home or office network.
These addresses are not globally unique and are typically in ranges like 192.168.x.x or 10.x.x.x. Public IP addresses, conversely, are globally unique and identify your network to the internet.
How Routers Manage IP Addresses
When multiple devices connect to a router, they are assigned private IP addresses by the router itself. This process is known as Network Address Translation (NAT).
The router then uses its single public IP address to communicate with the internet on behalf of all connected devices. Essentially, the router acts as an intermediary.
Are Public IPs Truly Unique?
The answer to amin gholami’s question is generally yes, public IP addresses are unique. However, the situation is nuanced.
While each network connected directly to the internet *should* have a unique public IP, technologies like Carrier-Grade NAT (CGNAT) are becoming more common.
Carrier-Grade NAT (CGNAT) and IP Sharing
CGNAT is used by Internet Service Providers (ISPs) to share a smaller pool of public IP addresses among a larger number of customers.
In this scenario, multiple customers might share the same public IP address, making it no longer strictly unique. This is more prevalent in areas with limited IPv4 address availability.
In Summary
Typically, a router presents a single, unique public IP address to the internet. All devices behind that router share this single public IP through NAT.
However, with the increasing adoption of CGNAT, the absolute uniqueness of public IPs is becoming less guaranteed, as ISPs may assign the same public IP to multiple customers.
Global Uniqueness of Public IP Addresses
A SuperUser community member, fedesismo, provides a comprehensive explanation regarding the uniqueness of public IP addresses.
Generally Unique Public IPs
In most cases, public IP addresses are indeed globally unique. However, there are exceptions, primarily relating to private IP addresses. These private IPs, which are not globally unique, fall within specific ranges:
- The range from 10.0.0.0 to 10.255.255.255 is designated for private use.
- IP addresses spanning 172.16.0.0 to 172.31.255.255 are also considered private.
- Finally, the 192.168.0.0 to 192.168.255.255 range is reserved for private addressing.
Further details can be found in RFC1918.
The IP address assigned to your home router's internet-facing interface is a public IP, provided by your Internet Service Provider (ISP). Conversely, the IPs utilized for your home network's Wi-Fi or Ethernet connections are private and therefore not unique.
Exceptions to One-to-One Communication
It's important to note that certain techniques deviate from the traditional one-to-one communication model of the Internet protocol. These methods are employed in services demanding high availability, redundancy, or minimal latency, such as DNS or Content Delivery Networks (CDNs).
In these scenarios, multiple servers globally may be configured to respond to a single IP address (IPv4 or IPv6), although only one will actively respond to any given request. This is detailed in RFC4786.
IPv6 and Anycast Addressing
IPv6 introduces a new addressing system designed to address these evolving needs, specifically through the implementation of Anycast Addresses.
An Anycast Address, defined within IPv6, allows a packet to be routed to one of several nodes all sharing the same address. The network then delivers the packet to the "nearest" interface, as determined by the routing protocols in use.
Refer to RFC2526 for more information.
Understanding IPv6 Anycast Addresses
An Anycast Address is assigned to a group of interfaces, typically belonging to different nodes. When a packet is sent to an Anycast Address, it's delivered to the closest interface identified by that address, based on routing protocol calculations.
Anycast Addresses are indistinguishable from Unicast Addresses syntactically, as they are allocated from the Unicast Address space. Assigning a Unicast Address to multiple interfaces effectively transforms it into an Anycast Address. Nodes utilizing an Anycast Address must be explicitly configured to recognize it as such.
Additional information on IPv6 Anycast Addresses can be found at Cisco.
Do you have further insights to contribute to this explanation? Share your thoughts in the comments section. For a more extensive discussion and additional perspectives from other technical experts, please visit the original Stack Exchange thread.