Howto set geoip_country for IPv4 and IPv6 databases?

Hi,

Next to their IPv4 country and city database, Maxmind now also has an
IPv6 country and city database at GeoIP2 Release Notes - 2022 Archive

Is there a way I can make geo use the IPv6 databases too?

This does not work:

geoip_country /etc/nginx/GeoIP.dat;
geoip_country /etc/nginx/GeoIPv6.dat;
geoip_city /etc/nginx/GeoLiteCity.dat;
geoip_city /etc/nginx/GeoLiteCityv6.dat;

Because I see this error when checking the config:

nginx: [emerg] “geoip_country” directive is duplicate in
/etc/nginx/nginx.conf:116

Thanks for any advice.

Regards,
Patrick

Hi,

It should be sufficient to just list the IPv6 database (which includes
the IPv4 database as mapped addresses) tough 1.2.x branch needs
attached patch.

I don’t know if Maxim has already applied it or a variant of it to
1.3.x branch.

Also search the archives for GeoIP and IPv6 support, there were a few
posts about it.

Attached patch was initially posted in
http://mailman.nginx.org/pipermail/nginx-devel/2011-June/000971.html
(though I’ve updated it for 1.2.2).

Regards,
Bruno

On Tue, Jan 15, 2013 at 09:08:30AM +0100, Bruno Prmont wrote:

It should be sufficient to just list the IPv6 database (which includes
the IPv4 database as mapped addresses) tough 1.2.x branch needs
attached patch.

I don’t know if Maxim has already applied it or a variant of it to
1.3.x branch.

It’s in the works, should be done real soon now.

Hi Ruslan,

On 01/15/2013 02:36 PM, Ruslan E. wrote:

On Tue, Jan 15, 2013 at 09:08:30AM +0100, Bruno Prmont wrote:

It should be sufficient to just list the IPv6 database (which includes
the IPv4 database as mapped addresses) tough 1.2.x branch needs
attached patch.

I don’t know if Maxim has already applied it or a variant of it to
1.3.x branch.

It’s in the works, should be done real soon now.

Thanks, that’s good to know. I’ll wait for the new 1.3 release with this
functionality and report back.

Regards,
Patrick

On Tue, Apr 30, 2013 at 06:14:54AM -0400, Rancor wrote:

geoip_country /etc/nginx/GeoIP.dat;
Any hints what’s wrong here? Thanks in advance for a reply.
This happens if nginx is built without IPv6 support:

$ nginx -p . -c x.conf -t
nginx: [emerg] invalid GeoIP database “GeoIPv6.dat” type:12 in
./x.conf:9
nginx: configuration file ./x.conf test failed
$ sed -ne9p x.conf
geoip_country GeoIPv6.dat;

If OTOH nginx is built with proper IPv6 support:
$ nginx -p . -c x.conf -t
nginx: the configuration file ./x.conf syntax is ok
nginx: configuration file ./x.conf test is successful

Make sure your nginx is built with IPv6 support.

Hey,

thanks for your reply. The packages of dotdeb.org are build with IPv6
support. When i’m using:

nginx -V

the output contains:

–with-ipv6

Additional netstat -npl shows this output:

tcp6 0 0 :::80 :::*
LISTEN
4942/nginx
tcp6 0 0 :::443 :::*
LISTEN
4942/nginx

so this NginX should run with IPv6?

Posted at Nginx Forum:

On Tue, Apr 30, 2013 at 09:03:20AM -0400, Rancor wrote:

Additional netstat -npl shows this output:

tcp6 0 0 :::80 :::* LISTEN
4942/nginx
tcp6 0 0 :::443 :::* LISTEN
4942/nginx

so this NginX should run with IPv6?

nginx detects the IPv6 support in libgeoip by trying to compile
the following code snippet:

#include <stdio.h>
#include <GeoIP.h>

int
main(void)
{
printf("%d\n", GEOIP_CITY_EDITION_REV0_V6);
return (0);
}

Does it compile OK on your system?

Hi,

i’m trying to get this to work with the current NginX package 1.4.0 from
dotdeb.org (using --with-ipv6) on a debian squeeze system. When
downloading
the GeoIP ipv6 binary from:

http://dev.maxmind.com/geoip/geolite

and changing:

geoip_country /etc/nginx/GeoIP.dat;

to:

geoip_country /etc/nginx/GeoIPv6.dat;

in my nginx.conf i’m getting this message after reload:

nginx: [emerg] invalid GeoIP database “/etc/nginx/GeoIPv6.dat” type:12
in
/etc/nginx/nginx.conf:47

Any hints what’s wrong here? Thanks in advance for a reply.

Posted at Nginx Forum:

Hi,

Seems that the libgeoip1 in debian squeeze in version
1.4.7~beta6+dfsg-1 doesn’t support this. Will test this again when
wheezy is released at the next weekend.

just want to let you know that this is now working on debian wheezy
with libgeoip1 version 1.4.8+dfsg-3

Posted at Nginx Forum:

Ruslan E. Wrote:

{
printf(“%d\n”, GEOIP_CITY_EDITION_REV0_V6);
return (0);
}

Does it compile OK on your system?

Hi,

thanks again for your reply. The code above doesn’t compile on my
system:

test.c: In function ‘main’:
test.c:7: error: ‘GEOIP_CITY_EDITION_REV0_V6’ undeclared (first use in
this
function)
test.c:7: error: (Each undeclared identifier is reported only once
test.c:7: error: for each function it appears in.)

Seems that the libgeoip1 in debian squeeze in version 1.4.7~beta6+dfsg-1
doesn’t support this. Will test this again when wheezy is released at
the
next weekend.

Posted at Nginx Forum: