disclaimer at first : this question is from a noob on IPv6 topic.
Our web server initially had IPv6 active and Nginx not configure properly so the users with IPv6 got an error and website did not load.
After configuration of Nginx to listen on IPv6, website loads properly but for the users with IPv6, the geolocation fails (we use Maxmind free database), they are then all Geolocated in USA.
I then disabled the IPv6 support, and now it appears to work well, even with client who is with IPv6, my website see an IPv4 and then geolocalize it in the right country.
Question is then :
- What really happens when an IPv6 client queries my website? If he has an IPv4 too, then it defeats the purpose of having IPv6 (which was because we were running out of IPv4)?
- Is the geolocation based on that IPv4 reliable?
- Is there any drawback of not being IPv6 ready?
Make sure you are using the correct database. Some geoip offerings have seperate databases for IPv4 and IPv6 (AIUI with maxmind the legacy products are split into seperate v4 and v6 while the geoip2 products cover both in one database).
There are different types of client to consider.
Cases 1 and 2 are pretty obvious.
With cases 3 and 4 the client will likely try both IPv4 and IPv6. In general if it finds both it will try IPv6 first.
With case 5 the client will use your IPv6 address if a record exists. If you do not offer an IPv6 address it will use an IPv6 address synthesized by the NAT64/DNS64 gateway. The NAT64 will then translate the IPv6 traffic from the client to IPv4 traffic to send to you.
The original idea was that we would move from v4 only to dual-stack. Then once everyone was on dual-stack we could start turning off IPv4. The hope was that this would happen before IPv4 addresses ran out.
That didn't happen for many reasons including ivory tower standards that ignored the reality of the Internet and the simple fact that it was hard to build a buisness case for IPv6 when noone else was doing it.
So now we are in the sad position that IPv4 addresses have essentially run out but large parts of the internet are still IPv4 only.
ISPs are therefore forced to do something to enable continued growth in a post-depletion world with many IPv4-only services. They basically have three options.
All of these options ultimately come down to implementing mechanisms to allow IPv4 addresses to be shared among multiple customers.
Geolocation is always dependent on the accuracy of the geolocation data. As IPv4 addresses get more scarce they are likely to be moved around more reducing the accuracy of geolocation.
Furthermore with IP sharing mechanisms users in different locations may be behind the same IP. There is nothing a geolocation database can do about that.
Beyond geolocation questions there are three main considerations here.
If country-level granularity is sufficient for you, then you can simply rely on whois. Don't query whois for every single client IP address you see. When you do see a new IP and query whois, then cache the range such that future requests for IP addresses in that range do not touch whois. If you get no response from whois, then don't try to use whois for the same /32 for the next 24 hours.
If you need more fine-grained granularity, or if caching of data from whois is more complicated than what you want to implement, then you need to find a provider who can give you access to such data for IPv6. You do not have to use the same provider for IPv4 and IPv6.
For clients with both IPv4 and IPv6, you can build your own data about correspondence between addresses. How this can be done has been answered before.
If both client and server has dual stack support, then it is the client which decides whether IPv4 or IPv6 is used. Since 2010 it has been considered best practice that clients attempt to use the fastest or most reliable of the two.
There are clients with more reliable IPv6 connectivity than IPv4 connectivity. If your site only supports IPv4 those clients will experience your site as being unreliable. The fraction of users for which this is the case will keep growing.