#1088880 libapache2-mod-geoip: Database lookup not working for IPv6 clients

Package:
libapache2-mod-geoip
Source:
libapache2-mod-geoip
Description:
GeoIP support for apache2
Submitter:
Tomaz Solc
Date:
2024-12-02 14:15:02 UTC
Severity:
normal
#1088880#5
Date:
2024-12-02 13:50:02 UTC
From:
To:
Dear Maintainer,

mod_geoip does not seem to be working for IPv6 clients.

With the following in my server config:

GeoIPEnable On
LogFormat "%h %l %u %t \"%r\" %{GEOIP_COUNTRY_CODE}e %{GEOIP_COUNTRY_CODE_V6}e %{GEOIP_ADDR}e" geoip
CustomLog ${APACHE_LOG_DIR}/geoip.log geoip

and in geoip.conf:

GeoIPOutput Env
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
GeoIPDBFile /usr/share/GeoIP/GeoIPv6.dat

performing a request from IPv6 and IPv4 writes the following to geoip.log:

x:x:x:x:x:x:x:x - - [02/Dec/2024:14:25:39 +0100] "GET / HTTP/1.1" - - x:x:x:x:x:x:x:x
x.x.x.x - - [02/Dec/2024:14:25:51 +0100] "GET / HTTP/1.1" SI - x.x.x.x

GEOIP_COUNTRY_CODE is correctly set for the IPv4 client, but
neither GEOIP_COUNTRY_CODE nor GEOIP_COUNTRY_CODE_V6 is set for the
IPv6 client.

According to documentation I would expect GEOIP_COUNTRY_CODE_V6 to be
set for the IPv6 client.

GEOIP_ADDR is correctly set, so mod_geoip seems to correctly pick the
IPv6 address from Apache.

If I perform the lookup of the same IPv6 address manually using
geoiplookup6 I do get the correct result, so the issue is not the
database content:

$ geoiplookup6 x:x:x:x:x:x:x:x
GeoIP Country V6 Edition: SI, Slovenia

The GeoIP.dat and GeoIPv6.dat are readable by the Apache process, there
are no relevant error messages in error.log.

$ ls -l /usr/share/GeoIP/*.dat
-rw-r--r-- 1 root root 2437415 jan 31  2023 /usr/share/GeoIP/GeoIP.dat
-rw-r--r-- 1 root root 5644409 jan 31  2023 /usr/share/GeoIP/GeoIPv6.dat

Best regards
Tomaž