All About IPv6
What is an IPv4 address?
By 2019, we officially ran out of IPv4 addresses. With only 4.29 billion unique addresses available, the internet simply outgrew the supply. That’s where IPv6 comes in — and it doesn’t just offer a few more addresses. It provides an almost incomprehensible number: 340,282,366,920,938,463,463,374,607,431,768,211,456
. Yes, that’s over 340 undecillion IP addresses — more than enough to connect every device imaginable for generations to come.
But what exactly is IPv6, and how is it different from IPv4?
To understand IPv6, it helps to first understand IPv4. An IPv4 address is a 32-bit number that uniquely identifies a device on the internet. It looks something like this: 10101100.00010000.00000001.00000011
(the dots are not part of it). While this binary format is how computers process IP addresses, it’s not very user-friendly for humans. That’s why we usually write IPv4 addresses in a simpler, decimal format, like 102.53.75.212
. The IP is split into 4 octets, each ranging from 0 to 255. This is the format most of us are familiar with. But what is 2001:0db8:85a3:0000:0000:8a2e:0370:7334
? or fe80::1
? or 2001:4860:4860::8888
? They look strange. Those are IPv6 addresses.
Demystifying IPv6
Actually, IPv6 is not that scary at all. They work very similarly to IPv4 addresses, but there are some key differences.
Address length
The most obvious difference is the length of the address. IPv6 addresses are 128 bits long, so instead of this:
10101100.00010000.00000001.00000011
you get this:
1010011010100101:0001001001001110:1000001010100011:0000001101110000:
0111001100110100:1010010010011101:0101101100110101:0000010100101110
(again, the colons are not there). And instead of 102.53.75.212
, it is now 2001:0db8:85a3:0000:0000:8a2e:0370:7334
.
Hex instead of decimal
As you already noticed, IPv6 addresses are written in hexadecimal instead of decimal. This is because it’s easier to work with 128-bit numbers in hexadecimal, which uses 16 characters (0-9 and A-F) instead of 10. This makes it easier to read and write, and it’s also more compact. There are also ways to shorten IPv6 addresses, like removing leading zeros and using double colons to represent consecutive zeros. You don't need to memorize an IPv6 address or even write it out. Instead, you can use a DNS server to resolve a hostname to an IP address.
Prefixes over a single public IP
Another major difference between IPv4 and IPv6 is that ISPs no longer hand out a single public IP address to each customer. Instead, they assign a prefix, which is a range of IP addresses (or a network). This allows you to have multiple public IP addresses for your devices. For example, you could have a prefix of 2001:0db8:85a3::/48
, which gives you 2^80
or 1,208,925,819,614,629,174,706,176
unique IP addresses to use. All of these addresses will be routed to your network, and you can assign them to your devices as you see fit.
You might be wondering, what do I need a gazillion IP addresses for? Isn't that wasteful? The answer is that we have so many IPv6 addresses that we can afford to be wasteful. It is better to have too many IP addresses than not enough. It really is just a very small fraction of the total number of addresses available.
An important note here is that IPv6 works on /64 boundary, splitting the address into two equal parts. The first half is the network prefix, and the second half is the interface identifier. It means that you will need to receive a prefix longer than /64 if you want to do subnetting, for example /60, /56, or /48. Since the first 64 bits are the network prefix, a larger prefix like /56 will use only the first 56 bits for the network prefix, leaving 8 bits for subnetting (64 - 56 = 8).
No more NAT
Another key difference is that IPv6 generally doesn’t use or discourage the use of NAT since there are enough IP addresses for everyone. This means that every device can have a unique public IP address, which makes it easier to communicate with other devices on the internet. Instead you use Firewall to block incoming traffic and create Firewall rules to allow traffic to specific devices.
No more DHCP server (SLAAC)
While the ISPs still use DHCP server on their end for IPv6, you don’t need to and are generally discouraged from using it on your network. Many devices and systems do not even support DHCP server with IPv6 (e.g. Android). Instead, you use SLAAC (Stateless Address Autoconfiguration) to automatically assign IP addresses to your devices. This is done by the router, which sends out Router Advertisement messages to the network, telling devices how to configure their IP addresses. The devices then generate their own IP addresses based on the network prefix and their MAC address.
Routing and subnetting
Routing and subnetting works pretty much the same way in IPv6 as in IPv4. You can use static routes, dynamic routing protocols, and subnetting to organize your network. The main difference is that you have a lot more addresses to work with, so you can create more complex network topologies and have more devices on your network.
Configuration
Configuring an IPv6 router is straightforward. You either create a DHCP client and request a prefix from your ISP, or if you are on mobile network, it happens automatically via APN. Since there is no more DHCP server but you still would like to assign static IP addresses to your devices, you can manually configure the IP address on the device itself. You can also use SLAAC to generate IP addresses automatically based on the network prefix and MAC address (EUI-64).
New types of IP addresses
IPv6 introduces new types of IP addresses:
- Link-local addresses are used for communication on the local network. They are automatically generated by the device and are not routable on the internet. They are used for neighbor discovery, router discovery, and other local network communication. They start with
fe80::/10
. - Loopback addresses are used for testing and troubleshooting. They start with
::1
and are used to test the network stack on the device. - Unique local addresses are similar to private IP addresses in IPv4. They are used for communication within a private network and are not routable on the internet. They start with
fc00::/7
and are analogous to IPv4 private addresses. - Global unicast addresses are public IP addresses that are routable on the internet. They start with
2000::/3
and are used for communication between devices on the internet. - Multicast addresses are used for one-to-many communication. They start with
ff00::/8
and are used for things like network discovery, routing updates, and other multicast traffic. - Anycast addresses are used for one-to-nearest communication. They are assigned to multiple devices, and the traffic is routed to the nearest device. They start with
2000::/3
and are used for things like DNS servers, load balancers, and other services that need to be highly available.
Having fun with IPv6
You can create some unique addresses using the a-f hex alphabet. The ISP issues a prefix, which is the first part of the address, and you can use the second part to create unique addresses.
2001:0db8:85a3::cafe
2001:0db8:85a3::dead-beef
2001:0db8:85a3::face-b00c
Fun-fact: the public AAAA records of facebook.com all end in face:b00c
Challenges of IPv6
The main challenge of IPv6 seems to be its adoption. While the technology has been around for over two decades and is supported by all modern operating systems, apps, and devices, many organizations have been slow to make the switch. You will find that all major websites and services are already IPv6-enabled, most ISPs and large organizations have already deployed IPv6, and many mobile networks are IPv6-only. But when it comes to the average user and the work office, you will never find an IPv6 network. I have talked to a network engineer who said he has never had to deal with IPv6 and he does networking for living. This is a major barrier to the adoption of IPv6. We do not get any real world exposure or experience with IPv6 which makes it difficult to understand best practices, troubleshoot issues, and deploy it in our own networks.
Another challenge that I came across was that many ISPs, especially mobile operators hand out only /64 prefixes to their customers. This is a problem because a /64 prefix cannot be used to subnet your network at all and you need to rely on other mechanisms like VLANs to segment your network.
Another challenge I encountered is that many devices and applications still tend to default to using IPv4.
Another challenge is that many mobile operators do not support dual-stack (IPv4 and IPv6) with static IP addresses. You can either have a static IPv4 address or a static IPv6 address, but not both. This is just another roadblock to the adoption of IPv6.