Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.09k stars 372 forks source link

How to get ip4 instead of ip6 #110

Closed jagehring closed 5 years ago

jagehring commented 6 years ago

I'm using ipapi and if I go to there site it shows my IP with the right city. On my site, it is showing the ip6 version so my city is somewhere else. is there a way to get the same results as the ipapi site?

nielspeen commented 6 years ago

The client browser/app decides whether IPv4 or IPv6 is used and most apps will prefer IPv6 when available.

Some work-arounds:

  1. You can disable IPv6 on your web server to force clients to use IPv4. (Quick and dirty.)

  2. You can add IPv4-only and IPv6-only hostnames to your web server (e.g. ipv4.mysite.com and ipv6.mysite.com) and use AJAX calls to those hostnames to register the user's IPv4 and IPv6 address in your database.

  3. You can wait for the IPv6 databases to become more accurate.

I typically use #2 on our websites.

Keep in mind though: IPv4 may be more accurate in your own situation, but this may be different for your website's visitors.