|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59124 IPv6
Submitted: 2010-03-17 09:10 UTC Modified: 2016-08-19 00:32 UTC
Avg. Score:4.6 ± 0.6
Reproduced:22 of 22 (100.0%)
Same Version:6 (27.3%)
Same OS:7 (31.8%)
From: Assigned: ohill (profile)
Status: Closed Package: geoip (PECL)
PHP Version: 5.2.12 OS:
Private report: No CVE-ID: None
 [2010-03-17 09:10 UTC]
The current PHP extension does not seem to support the IPv6 country database (at, and I had need of it, so I wrote a quick function as shown here:

It would probably be better to incorporate this into most functions, and also add checks to only include these functions if the version of libGeoIP supported IPv6 stuff, but this is a good start!


geoip-1.1.0-ipv6-php7.patch (last revision 2015-09-23 17:31 UTC by
geoip-1.1.0-ipv6.patch (last revision 2014-05-27 02:27 UTC by yiftachswr at gmail dot com)
geoip-1.0.8-further-ipv6-fix.patch (last revision 2012-11-13 11:27 UTC by php at gnodde dot org)
geoip-include-ipv6.patch (last revision 2012-06-15 11:37 UTC by dominic dot benson at thirdlight dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-24 16:54 UTC]
I will take a look shortly.

For now it seems Maxmind is only doing IPv6 with Country database, even if the C API has more functions.

Need to wrap your code in C API version detection not to break things. I'm pretty sure it needs >=1.4.5
 [2011-06-08 00:56 UTC] hessu at hes dot iki dot fi
Even country level support would be really good to have.

I just put the AAAA records up on my service (in support of 
the World IPv6 Day,, which 
Google, Akamai and Facebook and some other small players are 
taking part in) and noticed that the default measurement units 
according to origin country do not seem to work for IPv6 
 [2012-06-15 11:44 UTC] dominic dot benson at thirdlight dot com
Added a patch to enable the IPv6 versions by default when a sufficient geoip library is available.
Extend so that explicit IPv4 only methods are available as _v4 (per _v6), and so that the non-suffixed methods will try both databases if possible and necessary.
This has the effect that the standard functions (e.g. geoip_country_name_by_name) will be IP version transparent, which is overwhelmingly the more likely use case.
The _v4 allows usage in the edge cases that explicit restriction is required.

This does mean that these functions are not just wrappers for the underlying C API methods with the same name, but it represents an, IMHO, significant improvement in functionality without requiring user code to handle a wider variety of possible interfaces - like checking if _v6 functions exist.
 [2012-11-13 11:29 UTC] php at gnodde dot org
I've added IPv6 capabilities to the geoip_record_by_name() method, since Maxmind offers IPv6 city databases. The patch is based on and includes the previous patch attached to this ticket.
 [2012-11-13 14:02 UTC] arnaud dot abelard at univ-nantes dot fr
This last patch won't compile with geoip 1.0.8 and libgeoip 1.4.7 on debian Squeeze:

/bin/sh /root/geoip/geoip-1.0.8/libtool --mode=compile cc  -I. -I/root/geoip/geoip-1.0.8 -DPHP_ATOM_INC -I/root/geoip/geoip-1.0.8/include -I/root/geoip/geoip-1.0.8/main -I/root/geoip/geoip-1.0.8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/geoip/geoip-1.0.8/geoip.c -o geoip.lo 
libtool: compile:  cc -I. -I/root/geoip/geoip-1.0.8 -DPHP_ATOM_INC -I/root/geoip/geoip-1.0.8/include -I/root/geoip/geoip-1.0.8/main -I/root/geoip/geoip-1.0.8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/geoip/geoip-1.0.8/geoip.c  -fPIC -DPIC -o .libs/geoip.o
/root/geoip/geoip-1.0.8/geoip.c: In function 'zm_startup_geoip':
/root/geoip/geoip-1.0.8/geoip.c:133: error: 'GEOIP_CITY_EDITION_REV0_V6' undeclared (first use in this function)
/root/geoip/geoip-1.0.8/geoip.c:133: error: (Each undeclared identifier is reported only once
/root/geoip/geoip-1.0.8/geoip.c:133: error: for each function it appears in.)
/root/geoip/geoip-1.0.8/geoip.c:140: error: 'GEOIP_CITY_EDITION_REV1_V6' undeclared (first use in this function)
/root/geoip/geoip-1.0.8/geoip.c: In function 'zif_geoip_record_by_name':
/root/geoip/geoip-1.0.8/geoip.c:479: error: 'GEOIP_CITY_EDITION_REV1_V6' undeclared (first use in this function)
/root/geoip/geoip-1.0.8/geoip.c:481: error: 'GEOIP_CITY_EDITION_REV0_V6' undeclared (first use in this function)
 [2012-11-13 14:42 UTC] arnaud dot abelard at univ-nantes dot fr
Required libgeoip version is >= 1.4.8
 [2012-12-06 20:49 UTC] phpdev at ehrhardt dot nl
To compile it with MS VC9 the declaration of ipv4_db_available and ipv6_db_available have to be moved to the top of the block, likt this:

	GeoIP * gi;
	char * hostname = NULL;
	int arglen;
	int ipv4_db_available;
	int ipv6_db_available;
	GeoIPRecord * gir = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) {

	ipv4_db_available = 1;
#if LIBGEOIP_VERSION >= 1004005
	ipv6_db_available = 1;
 [2014-01-16 01:34 UTC] mzvarik at gmail dot com
Adding the IPv6 support would be really great =)
 [2014-01-27 23:34 UTC]
Would be great if you could please consider the patch. For example Piwik uses the pecl-library. And a (small but) increasing number of visitors come via IPv6 these days here.
 [2014-05-10 10:51 UTC] yiftachswr at gmail dot com
Please please, I see that this is now once agai an active project with a new 1.10 beta released, can we please have IPv6 support.
 [2014-11-03 00:37 UTC] matt at piwik dot org
Thanks for the very useful work on GeoIP PECL! :)

I guess thousands of Piwik users geo locate their visitors using the extension since it's part of the core feature, refs user guide:

it would be so nice to have IPv6 support in the PECL extension like in the PHP library and the apache server module. We will then add support to Piwik in
 [2015-09-23 17:31 UTC]
The following patch has been added/updated:

Patch Name: geoip-1.1.0-ipv6-php7.patch
Revision:   1443029505
 [2015-09-23 17:37 UTC]
Added geoip-1.1.0-ipv6-php7.patch.

This patch adds full IPv6 support, reduces code duplication, and replaces some macros in favor of functions. It also makes the extension fully PHP7 compatible.

There is a corresponding PR for the HHVM extension here:
 [2016-07-17 13:52 UTC] burrellramone at gmail dot com

I am very new to the idea of applying patches. Could someone please explain how I would go about applying this patch? I have downloaded the latest tarball as of May 1st 2016.
 [2016-07-17 14:08 UTC] burrellramone at gmail dot com
I figured it out after doing some reading. The patch file has everything needed to do the patch. Just have to run the patch command in the right directory and all is well.
 [2016-08-19 00:32 UTC]
-Status: Assigned +Status: Closed
 [2016-08-19 00:32 UTC]
Available in 1.1.1
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 09:03:43 2022 UTC