Preparing for IPv6

IPv6 is here and it’s causing havoc for legacy applications.

IPv6 is not just around the corner, it’s here!! 

I recently worked on a legacy website that had fallen afoul of something I’m seeing very commonly these days; they had not prepared for the move to IPv6. 

IPv6?

For those who don’t know, there are two formats for IP addresses. 

IPv4 – e.g.192.168.1.1

IPv6 – 0000:0000:0000:0000:0000:FFFF:C0A8:0101

IPv6 (Shortened) – 0:0:0:0:0:FFFF:C0A8:101

What’s the difference?

As you can see the IPv6 version is MUCH longer. The reason for this change is we are running out of IPv4 addresses at an alarming rate. When the IPv4 standard was created, no one foresaw the explosion in internet connected devices.

With IPv4, you have about 4.3 billion addresses. Sounds a lot, but when everyone (these days) has a smart phone and internet connection you run out of addresses pretty quickly. 

IPv6 has capacity for 340 billion billion billion billion (that’s not a type) address. I think it’s fair to say, we’re covered for the foreseeable future with IPv6. 

How does this affect me (as a developer)?

There are a few factors at play here. 

  1. Data Storage – How are you going to store the longer addresses?
  2. Coding – What code relies on IP addresses and does it need refactoring?
  3. Geo IP – Does your Geo IP database support IPv6?

Data Storage

You have the following options:

  • Extend your IP address row to accommodate the extended IPv6 addresses
  • Hash your addresses into a common format (not a great idea as you will lose GeoIP support)

Which approach you take will depend on how many tables, rows etc you would need to change. 

Coding

This is very much dependant on the choice you make for data storage. Realistically, there’s going to be some refactoring going on. Hopefully, you’ve got a class/module for dealing with IP addresses (if not why not). There’s going to be some refactoring needed either way. 

Things like blocked IP ranges, country codes etc are all things that need to be addressed. 

Geo IP

There’s some great Geo IP services out there these days, but this is all wrapped up in the first two decisions.  

Conclusion

There’s no silver bullet here I’m afraid. This article isn’t intended to solve your problems, it’s more to raise awareness that it needs to be considered for all future developments. IPv6 isn’t going anywhere, and you need to consider that if you’re developing news systems. 

It’s a lot easier to get it right in development than put it right once you’ve pushed it live.