Table of Contents
ipv6calc is a small utility written in programming language C to manipulate (not only) IPv6 addresses and is able to do other tricky things. Intentions were convering a given IPv6 address into compressed format, convering a given IPv6 address into the same format like shown in /proc/net/if_inet6 and (because it was not difficulty) migrating the Perl program ip6_int into. Now only one utility is needed to do a lot.
This utility was also used in the past to extend features on network-functions-ipv6 library, used by initscripts-ipv6.
Note: this tool got also its freecode.com (former freshmeat, now also EOL) / ipv6calc page (but this is not maintained by the author)
“ipv6calc”: the main utility
“ipv6calcweb”: CGI wrapper for ipv6calc's address information output
“ipv6logconv”: log converter (IPv4/IPv6)
“ipv6loganon”: log anonymizer (IPv4/IPv6)
“ipv6logstats”: log statistic generator (IPv4/IPv6)
“mod_ipv6calc”: Apache module
If not disabled during compiling of the tool, following databases are statically included, since version 0.95.0 internally mentioned as “BuiltIn”:
IEEE IAB, OUI, OUI-28, OUI-36 databases (for decoding vendor part of MAC/EUI-48/EUI-64)
IPv4 assignment databases from IANA, ARIN, RIPENCC, APNIC, LACNIC, AFRINIC (for selecting proper registry in ipv6calcweb.cgi and IPv4 anonymization)
IPv6 assignment databases from IANA, ARIN, RIPENCC, APNIC, LACNIC, AFRINIC (for selecting proper registry in ipv6calcweb.cgi and IPv6 anonymization)
ASN assignment databases from IANA, ARIN, RIPENCC, APNIC, LACNIC, AFRINIC (for IPv4/IPv6 anonymization)
LISP assignment database for supplying extra info
If enabled during compiling the tool, following external (but local stored) databases can be used
IPv4 “legacy” (since 0.61.0, released 2006 until 3.0.0 released 2020)
IPv6 “legacy” (since 0.90.0, released 2011, req. GeoIP >= 1.4.5 until 3.0.0 released 2020)
GeoIP2 (native MaxMindDB file support since 2.0.0, release 2019)
IPv4 (since 0.60.0, released 2006)
IPv6 (since 0.70.0, released 2007, IP2Location LITE IPv6 Databases since 0.99.0, released 2015)
release 0.99.0 is tested against IP2Location >= 4.0.2
release >= 2.0.0 && < 3.0.0 is only working with IP2Location >= 7.0.1
release >= 3.0.0 is only working with IP2Location >= 8.2.0
(since 0.98.0, released 2015 until 3.0.0 released 2020) based on local Berkeley DB files generated from downloaded CSV files
native MaxMindDB files (support since 2.0.0, released 2019)
“External” (since 0.98.0, released 2015), based on local Berkeley DB files, generated from downloaded TXT/XML files (registries assignment databases). Supporting IPv4/IPv6 to Registries and IPv4/IPv6 to CountryCode. If newer, overruling the related included databases.
Since version 0.95.0 the tool can be compiled to use dynamically loading of library, means the binaries can be also used on systems where IP2Location or GeoIP libraries are not existing. On such system, the support is simply disabled then and some capabilities/features which requires the databases are disabled.
Since version 0.97.4 also fallback code for GeoIP and IP2Location is included in the source package, means that support of dynamically loading of library can be included during compilation without having related development sources on the system.
Since version 2.0.0 MaxMindDB is supported (linked or dynamically loaded)
Since version 3.0.0 GeoIP(legacy) and db-ip.com(BerkeleyDB) is removed
Via GitHub (since 2016-09-05) at GitHub / ipv6calc
via HTTPS at GitHub / ipv6calc / releases
from DeepSpace6 via FTP DeepSpace6 / anonymous FTP or HTTP www.deepspace6.net mapped FTP
via ftp.bieringer.de / anonymous FTP or HTTP at www.bieringer.de mapped FTP
Since version 0.95.0 packages are signed with new GPG key, also available here: CODE-GPG-KEY-bieringer.de-2013 @ftp.bieringer.de or CODE-GPG-KEY-bieringer.de-2013 @ftp.deepspace6.net
Key fingerprint: AAB3 8CB7 97C7 50C7 78C6 08C6 DDEB 141D F738 0F61 uid: Peter Bieringer (Code Signing Key 2013) <code@bieringer.de>
A SPEC file is included, so you can build a RPM from tar.gz using
$ rpmbuild -ta path/to/ipv6calc-$version.tar.gz
In addition, conditional build options are available (see related configure options below):
--without ip2location --without mmdb (which disables GeoIP v2 and db-ip.com v2) --without external --without shared --without mod_ipv6calc
Can be searched via rpmfind / ipv6calc.
Fedora 29 is the current developing platform, so use given hints above to create a RPM. Since Fedora 7 this package is included by default.
See also FedoraProject / Packages / ipv6calc
It's tested by the developer that creation of the RPM is working fine starting with RHEL 4.
Major version 5 has the package included by default (but a rather old version)
RPMs of newer releases are available as test builds on koji, see related URL in announcements ipv6calc-announce / list archive
*** Untested since version 2.0.0 because OS is out of support ***
Major version 6: available since September 2014 on FedoraProject / EPEL, see also FedoraProject / Packages / ipv6calc
*** Untested since version 3.0.1 because OS is out of support ***
Major version 7: available since Decenber 2016 on FedoraProject / EPEL, see also FedoraProject / Packages / ipv6calc
Major version 8: available since September 2019 on FedoraProject / EPEL, see also FedoraProject / Packages / ipv6calc
Major version 9: available since December 2021 on FedoraProject / EPEL, see also FedoraProject / Packages / ipv6calc
CentOS 7 / AlmaLinux 8+9 are also platforms for regression tests.
Package is maintained, more information can be found at https://packages.ubuntu.com/ipv6calc
Package is maintained, more information can be found at http://packages.debian.org/ipv6calc
Package is maintained, more information can be found at http://download.opensuse.org/repositories/home:/uebelhacker/
See here for more: ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/net/ipv6calc/README.html
See here for more: http://www.freshports.org/net-mgmt/ipv6calc/ (http://www.freebsd.org/cgi/query-pr.cgi?pr=34441)
See here for more: http://www.openbsd.org/cgi-bin/cvsweb/ports/net/ipv6calc/
Following “ipc6calc” related configure options are currently supported (note: disabling the internal databases reduces the size of the resulting binaries/shared library a lot):
--disable-dynamic-load Disable dynamic load of libraries (default: enabled) --disable-db-ieee Disable build-in IEEE database (default: enabled) --disable-db-ipv4 Disable build-in IPv4 database (default: enabled) --disable-db-ipv6 Disable build-in IPv6 database (default: enabled) --disable-db-as-registry Disable built-in AS-to-Registry database (default: enabled) --disable-db-cc-registry Disable built-in CountryCode-to-Registry database (default: enabled) --disable-geoip2 Disable MaxMindDB support for GeoIP (default: enabled) --disable-dbip2 Disable MaxMindDB support for db-ip.com (default: enabled) --enable-mmdb Enable MaxMindDB support (GeoIP/db-ip.com) (default: disabled) --enable-external Enable external db support (default: disabled) --enable-ip2location Enable IP2Location support (default: disabled) --enable-mod_ipv6calc Enable build of mod_ipv6calc for Apache (default: disabled) --with-mmdb-dynamic Enable use of dynamic loading of MaxMindDB library (default=no) --with-mmdb-headers=DIR MaxMindDB include files location --with-mmdb-lib=DIR MaxMindDB library location --with-mmdb-dyn-lib=NAME Use specified MaxMindDB dynamic library, default: libmaxminddb.so.0 --with-ip2location-headers=DIR IP2Location include files location --with-ip2location-headers-fallback IP2Location include files from internal fallback location (only usable with dynamic load option) --with-ip2location-lib=FILE IP2Location library location --with-ip2location-static Explicitly link IP2Location statically (default=no) --with-ip2location-dynamic Enable use of dynamic loading of IP2Location library (default=no) --with-ip2location-db=DIR Use specified IP2Location database directory, default: /usr/share/IP2Location --with-ip2location-dyn-lib=NAME Use specified IP2Location dynamic library, default: libIP2Location.so --with-geoip-db=DIR Use specified GeoIP database directory, default: /usr/share/GeoIP --with-dbip-db=DIR Use specified db-ip.com database directory, default: /usr/share/DBIP --with-external-db=DIR Use specified external database directory, default: /usr/share/ipv6calc/db --with-apxs=NAME name of the apxs executable (apxs) --enable-shared Enable shared library build (default: disabled) --enable-bundled-getopt Enable bundled getopt library (default: autoselected) --enable-bundled-md5 Enable bundled MD5 library (default: autoselected) --enable-libmd-md5 Enforce use of libmd MD5 implementation (default: autoselected) --enable-openssl-evp-md5 Enforce use of OpenSSL EVP MD5 implementation (default: autoselected) --enable-openssl-md5 Enforce use of OpenSSL legacy MD5 implementation (default: autoselected)
As usual, use
$ make
and run tests afterwards using
$ make test
or at least (e.g. if external databases are not available)
$ make test-minimal
A shell script is included which can configure and compile with standard presets (also used during regression tests):
$ ./autogen.sh -h Supported options: -?|-h|--help : this help -n|--no-make : stop before running 'make' -a|--all : enable GeoIP/IP2Location/db-ip.com/External/mod_ipv6calc support -A|--ALL : enable GeoIP/IP2Location/db-ip.com/External/mod_ipv6calc support with dynamic library support -m|--mmdb : enable MaxMindDB support (GeoIP/db-ip.com) --mmdb-dyn|-M : switch to dynamic library loading of MaxMindDB --disable-geoip2 : disable MaxMindDB support for GeoIP --disable-dbip2 : disable MaxMindDB support for db-ip.com -i|--ip2location : enable IP2Location support --ip2location-dyn|-I: switch to dynamic library loading of IP2Location -e|--external : enable external database support --disable-db-ieee : disable built-in IEEE database --disable-db-ipv4 : disable built-in IPv4 database --disable-db-ipv6 : disable built-in IPv6 database --disable-builtin : disable all internal databases -S : enable shared library mode --no-static-build : skip static build --no-test : skip 'make test' --clang : use 'clang' instead of default (usually 'gcc') --gcc-Os : use 'gcc' option '-Os' --m32 : compile for 32-bit --enable-openssl-md5: use legacy OpenSSL MD5 implementation --enable-libmd-md5 : use libmd MD5 implementation --relax : don't stop on compiler warnings
sending announcements of new versions
very low
only moderators are allowed to post
discussions
low
subscribers
You can send bug reports to the author himself or subscribe to maillist “ipv6calc” and send it to the list.
The main program named “ipv6calc” is able to recognize many (not only) IPv6 address formats and depending on a selectable action (not required) a selectable output format can be specified. Also it has the capability to show detailed information of an IPv4/IPv6 address or anonymize it.
Option “-v” shows built-in features, depending on configuration before compiling:
$ ipv6calc -v ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC DB_IPV6_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID
Option “-v -v” (since 0.91.0) shows built-in features and capabilities in detail, depending on configuration before compiling:
$ ipv6calc -vv ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC DB_IPV6_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID Capabilities: GeoIP2(linked/MaxMindDB) IP2Location(linked) DBIP2(linked/MaxMindDB) ExternalDatabase DB_AS_REG(BuiltIn) DB_CC_REG(BuiltIn) DB_IPV4_REG(BuiltIn) DB_IPV6_REG(BuiltIn) DB_IEEE(BuiltIn) Internal main library version: 4.2.0 API: 4.1.0 (built-in) Internal database library version: 4.2.0 API: 4.1.0 (built-in) Linked MD5 implementation: OpenSSL EVP MD5 MaxMindDB for GeoIP2/DBIP2 support enabled MaxMindDB dynamic library version (on this system): 1.8.0 GeoIP2 (MaxMindDB) support enabled GeoIP2 database support: Country4=1 Country6=1 ASN4=1 ASN6=1 City4=1 City6=1 IP2Location support enabled, compiled with API version: 8.6.1, dynamically linked with version: API=8.6.1 Major=8 MajorMinor=806 IP2Location database support: Country4=1 Country6=1 ASN4=0 ASN6=0 City4=0 City6=0 DBIP2 (MaxMindDB) support enabled DBIP2 database support: Country4=1 Country6=1 ASN4=1 ASN6=1 City4=1 City6=1 External available databases: Country4=1 Country6=1 IPV4_REG=1 IPV6_REG=1 BuiltIn databases available: ASN_REG=1 IPV4_REG=1 IPV6_REG=1 IEEE=1 CC_REG=1 DB features: 0xff1fffff GeoIP(MaxMindDB): features available/implemented: 0x03063ff0/0x03063ff0 (100%) GeoIP2: info of available databases in directory: /usr/share/GeoIP GeoIP2: IPv4/v6 CountryCode (FREE) : [1] GeoLite2-Country.mmdb (GeoLite2-Country Copyright (c) 2019 MaxMind All Rights Reserved, created: 20191217-195954 UTC) GeoIP2: IPv4/v6 City (FREE) : [2] GeoLite2-City.mmdb (GeoLite2-City Copyright (c) 2019 MaxMind All Rights Reserved, created: 20191217-200126 UTC) GeoIP2: IPv4/v6 ASN (FREE) : [3] GeoLite2-ASN.mmdb (GeoLite2-ASN Copyright (c) 2023 MaxMind All Rights Reserved, created: 20230606-150556 UTC) GeoIP2: detected best databases FREE Country4=2 Country6=2 City4=2 City6=2 GeoIP2: detected best databases COMM Country4=0 Country6=0 City4=0 City6=0 GeoIP2: selected best databases normal Country4=2 Country6=2 City4=2 City6=2 GeoIP2: selected best databases method: COMM older than 12 months are deselected in case of FREE is available GeoIP2: selected best databases method: COMM/FREE with more features are only selected in case not older than 1 months of already found COMM/FREE IP2Location: features available/implemented: 0x0c0003c0/0x0c003ff0 (50%) IP2Location: info of available databases in directory: /usr/share/IP2Location IP2Location: Copyright (c) IP2Location All Rights Reserved IP2Location: IPv4 Country :[201] IP-COUNTRY-SAMPLE.BIN (IP2L-DB1 IPv4 IPv6 SAMPLE 20230605) IP2Location: IPv6 Country :[301] IPV6-COUNTRY.SAMPLE.BIN (IP2L-DB1 IPv4 IPv6 SAMPLE 20230605) IP2Location: detected best databases SAMPLE Country4=201 Country6=301 City4=0 City6=0 ASN4=0 ASN6=0 IP2Location: detected best databases LITE Country4=0 Country6=0 City4=0 City6=0 ASN4=0 ASN6=0 IP2Location: detected best databases COMM Country4=0 Country6=0 City4=0 City6=0 ASN4=0 ASN6=0 IP2Location: selected best databases LI->SA* Country4=0 Country6=0 City4=0 City6=0 ASN4=0 ASN6=0 IP2Location: selected best databases normal Country4=201 Country6=301 City4=0 City6=0 ASN4=0 ASN6=0 IP2Location: selected best databases method: * = autoswitch from LITE to SAMPLE enabled in case not older than 12 months and having more features IP2Location: selected best databases method: COMM older than 12 months are deselected in case of LITE is available IP2Location: selected best databases method: COMM/LITE/SAMPLE with more features are only selected in case not older than 1 months of already found COMM/LITE/SAMPLE IP2Location: selected best databases method: softlinks: skipped-by-default db-ip.com(MaxMindDB): features available/implemented: 0x30063ff0/0x30063ff0 (100%) DBIP2: info of available databases in directory: /usr/share/DBIP DBIP2: IPv4/v6 Location+ISP (COMM) : [6] dbip-location-isp.mmdb (DBIP-Location-ISP (compat=Enterprise) Copyright (c) 2023 db-ip.com All Rights Reserved, created: 20230601-021221 UTC) DBIP2: detected best databases FREE Country4=0 Country6=0 City4=0 City6=0 DBIP2: detected best databases COMM Country4=6 Country6=6 City4=6 City6=6 DBIP2: selected best databases normal Country4=6 Country6=6 City4=6 City6=6 DBIP2: selected best databases method: COMM older than 12 months are deselected in case of FREE is available DBIP2: selected best databases method: COMM/FREE with more features are only selected in case not older than 1 months of already found COMM/FREE External: features available/implemented: 0xc01980cc/0xc01980cc (100%) External: info of available databases in directory: /usr/share/ipv6calc/db External: IPv4 Registry : ipv6calc-external-ipv4-registry.db (EXTDB-1/AFRINIC/20231207 APNIC/20231207 ARIN/20231207 IANA/20230718 LACNIC/20231207 LISP/20200318 RIPENCC/20231207, created: 20231208-045838 UTC) External: IPv6 Registry : ipv6calc-external-ipv6-registry.db (EXTDB-2/AFRINIC/20231207 APNIC/20231207 ARIN/20231207 IANA/20191106 LACNIC/20231207 LISP/20200318 RIPENCC/20231207, created: 20231208-051528 UTC) External: IPv4 CountryCode : ipv6calc-external-ipv4-countrycode.db (EXTDB-3/AFRINIC/20231207 APNIC/20231207 ARIN/20231207 IANA/20230718 LACNIC/20231207 LISP/20200318 RIPENCC/20231207, created: 20231208-045838 UTC) External: IPv6 CountryCode : ipv6calc-external-ipv6-countrycode.db (EXTDB-4/AFRINIC/20231207 APNIC/20231207 ARIN/20231207 IANA/20191106 LACNIC/20231207 LISP/20200318 RIPENCC/20231207, created: 20231208-051528 UTC) BuiltIn: features available/implemented: 0x0001c00f/0x0001c00f (100%) BuiltIn: info of available databases BuiltIn: ASN : IANA/20230810 BuiltIn: CC : AFRINIC/20231207 APNIC/20231206 ARIN/20231206 LACNIC/20231206 RIPENCC/20231206 BuiltIn: IPv4 : AFRINIC/20231207 APNIC/20231206 ARIN/20231206 IANA/20230718 LACNIC/20231206 LISP/20200318 RIPENCC/20231206 (created: 20231207-053316 UTC) BuiltIn: IPv6 : AFRINIC/20231207 APNIC/20231206 ARIN/20231206 IANA/20191106 LACNIC/20231206 LISP/20200318 RIPENCC/20231206 (created: 20231207-055604 UTC) BuiltIn: IEEE : IAB/20231207 OUI/20231207 OUI28/20231207 OUI36/20231207 Database selection or priorization ('->': subsequential calls) Database priorization default: GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB)->GeoIP->db-ip.com->External->BuiltIn DB_AS_REG (AS-Number to Registry database): BuiltIn DB_CC_REG (CountryCode to Registry database): BuiltIn DB_IPV4_REG (IPv4 to Registry database): External DB_IPV6_REG (IPv6 to Registry database): External DB_IPV4_AS (IPv4 to AS database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV6_AS (IPv6 to AS database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV4_CC (IPv4 to CountryCode database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB)->External DB_IPV6_CC (IPv6 to CountryCode database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB)->External DB_IPV4_COUNTRY (IPv4 to Country database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) DB_IPV6_COUNTRY (IPv6 to Country database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) DB_IPV4_CITY (IPv4 to City database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV6_CITY (IPv6 to City database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV4_REGION (IPv4 to Region database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV6_REGION (IPv6 to Region database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IEEE (IEEE/OUI/OUI28/OUI36 Vendor database): BuiltIn DB_IPV4_INFO (IPv4 additional information): External->BuiltIn DB_IPV6_INFO (IPv6 additional information): External->BuiltIn DB_IPV4_GEONAMEID (IPv4 GeonameID): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV6_GEONAMEID (IPv6 GeonameID): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) DB_IPV4_DUMP_CC (IPv4 Database Dump by CountryCode): External DB_IPV6_DUMP_CC (IPv6 Database Dump by CountryCode): External
Option “-v -h” (since 0.97.4) shows explanation of feature tokens
$ ipv6calc -v -h ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC DB_IPV6_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID Explanation of available(x)/possible(o) feature tokens GeoIP x GeoIPv4 database (provided by GeoIP(MaxMindDB)) GeoIPv6 x GeoIPv6 database (provided by GeoIP(MaxMindDB)) IP2Location x IP2Location IPv4 database (provided by IP2Location) IP2Location6 x IP2Location IPv6 database (provided by IP2Location) DBIPv4 x db-ip.com IPv4 database (provided by db-ip.com(MaxMindDB)) DBIPv6 x db-ip.com IPv6 database (provided by db-ip.com(MaxMindDB)) DB_AS_REG x AS-Number to Registry database (provided by BuiltIn) DB_IPV4_REG x IPv4 to Registry database (provided by External,BuiltIn) DB_IPV6_REG x IPv6 to Registry database (provided by External,BuiltIn) DB_IPV4_AS x IPv4 to AS database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV6_AS x IPv6 to AS database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV4_CC x IPv4 to CountryCode database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB),External) DB_IPV6_CC x IPv6 to CountryCode database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB),External) DB_IPV4_COUNTRY x IPv4 to Country database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV6_COUNTRY x IPv6 to Country database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV4_CITY x IPv4 to City database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV6_CITY x IPv6 to City database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV4_REGION x IPv4 to Region database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_IPV6_REGION x IPv6 to Region database (provided by GeoIP(MaxMindDB),IP2Location,db-ip.com(MaxMindDB)) DB_CC_REG x CountryCode to Registry database (provided by BuiltIn) DB_IEEE x IEEE/OUI/OUI28/OUI36 Vendor database (provided by BuiltIn) DB_IPV4_INFO x IPv4 additional information (provided by External,BuiltIn) DB_IPV6_INFO x IPv6 additional information (provided by External,BuiltIn) DB_IPV4_GEONAMEID x IPv4 GeonameID (provided by GeoIP(MaxMindDB),db-ip.com(MaxMindDB)) DB_IPV6_GEONAMEID x IPv6 GeonameID (provided by GeoIP(MaxMindDB),db-ip.com(MaxMindDB)) DB_IPV4_DUMP_CC x IPv4 Database Dump by CountryCode (provided by External) DB_IPV6_DUMP_CC x IPv6 Database Dump by CountryCode (provided by External) ANON_ZEROISE x Anonymization method 'zeroize' ANON_ANONYMIZE x Anonymization method 'anonymize' ANON_KEEP-TYPE-ASN-CC x Anonymization method 'keep-type-asn-cc' ANON_KEEP-TYPE-GEONAMEID x Anonymization method 'keep-type-geonameid'
Note: since version 0.95.0 the internal layer for database usage was abstracted and each database “plugin” is initialized reporting then its supporting features in binary representation. This makes implementation of other external databases easier in the future. Partially internal (built-in) databases can be overlayed by generated external databases replacing the need of recompilation for updated built-in databases.
A simple example is the conversion of an IPv6 address to a DNS PTR query string:
$ ipv6calc --out revnibbles.arpa 2001:db8::1 No input type specified, try autodetection...found type: ipv6addr 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
Like you see, input format was autodetected. And the given example can be extended because ipv6calc also understands netmask / prefix length values:
$ ipv6calc -q --out revnibbles.arpa 2001:db8::1/64 0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
Also you've also learnt now that switch '-q' (quiet) suppresses informational messages. You can use this now to start a DNS PTR query using:
$ dig PTR `./ipv6calc -q --out revnibbles.arpa 2001:db8::1/64`
But ipv6calc can do many more for you! Next example shows you the extraction of the IPv4 address contained in a 6to4 IPv6 address:
$ ipv6calc -q --action conv6to4 --in ipv6 2002:c0a8:fb61::1 --out ipv4 192.168.251.97
This also works vice-versa:
$ ipv6calc -q --action conv6to4 --in ipv4 192.168.251.97 --out ipv6 2002:c0a8:fb61::
There are many more features already implemented, if you miss one, send a note.
Depending on available databases output can vary.
$ ipv6calc -q -i 3ffe:ffff::210:a4ff:fe01:2345 Address type: unicast, 6bone, global-unicast, productive Address type has SLA: 0000 Registry for address: reserved Interface identifier: 0210:a4ff:fe01:2345 EUI-48/MAC address: 00:10:a4:01:23:45 MAC is a global unique one MAC is an unicast one OUI is: XIRCOM
$ ipv6calc -q -i 3ffe:831f:ce49:7601:8000:efff:af4a:86BF Address type: unicast, 6bone, global-unicast, teredo Country Code: IT Registry for address: 6BONE IPv4 address: 80.181.121.64 (TEREDO-CLIENT) IPv4 address type: unicast, global Autonomous System Information for [80.181.121.64]: AS3269 ASN-IBSNAZ Country Code for [80.181.121.64]: IT ...
$ ipv6calc -q -i 153.16.26.80 IPv4 address: 153.16.26.80 IPv4 address type: unicast, global, lisp ... IPv4 registry: ARIN(LISP#cbc-xtr) ...
There exists also a machine readable output (e.g. used by 'ipv6calcweb.cgi') - in addition, database related information can be displayed, if databases are located on the system and supported.
$ ipv6calc -q -i -m 2a01:238:423d:8800:85b3:9e6b:3019:8909 IPV6=2a01:0238:423d:8800:85b3:9e6b:3019:8909 IPV6_ANON=a909:16fa:9091:a448:a909:4941:0000:0007 IPV6_TYPE=ipv6,unicast,global-unicast,productive,iid-random,iid,iid-local IPV6_COUNTRYCODE=DE IPV6_COUNTRYCODE_SOURCE=GeoIP(MaxMindDB) IPV6_AS_NUM=6724 IPV6_AS_SOURCE=GeoIP(MaxMindDB) IPV6_GEONAME_ID=2921044 IPV6_GEONAME_ID_SOURCE=GeoIP(MaxMindDB) IPV6_GEONAME_ID_TYPE=Country IPV6_REGISTRY=RIPENCC SLA=8800 IID=85b3:9e6b:3019:8909 EUI64_SCOPE=local-random IP2LOCATION_COUNTRY_SHORT=DE IP2LOCATION_COUNTRY_LONG=Germany IP2LOCATION_REGION=Berlin IP2LOCATION_CITY=Berlin IP2LOCATION_ZIPCODE=10178 IP2LOCATION_LATITUDE=52.524368 IP2LOCATION_LONGITUDE=13.410530 IP2LOCATION_TIMEZONE=+01:00 GEOIP2_CONTINENT_SHORT=EU GEOIP2_CONTINENT_LONG=Europe GEOIP2_COUNTRY_SHORT=DE GEOIP2_COUNTRY_LONG=Germany GEOIP2_LATITUDE=51.000000 GEOIP2_LONGITUDE=9.000000 GEOIP2_RADIUS=100 GEOIP2_TIMEZONE_NAME=Europe/Berlin GEOIP2_AS_NUM=6724 GEOIP2_AS_ORGNAME=Strato AG GEOIP2_GEONAME_ID_COUNTRY=2921044 GEOIP2_GEONAME_ID_CONTINENT=6255148 DBIP2_CONTINENT_SHORT=EU DBIP2_CONTINENT_LONG=Europe DBIP2_COUNTRY_SHORT=DE DBIP2_COUNTRY_LONG=Germany DBIP2_REGION=Berlin DBIP2_CITY=Berlin (Charlottenburg-Wilmersdorf) DBIP2_ZIPCODE=10587 DBIP2_LATITUDE=52.523900 DBIP2_LONGITUDE=13.321400 DBIP2_WEATHERSTATIONCODE=GMXX8538 DBIP2_TIMEZONE_NAME=Europe/Berlin DBIP2_AS_NUM=6724 DBIP2_AS_ORGNAME=Strato AG DBIP2_ISP=Strato Rechenzentrum DBIP2_NETSPEED=Corporate DBIP2_GEONAME_ID=3336294 DBIP2_GEONAME_ID_REGION=2950157 DBIP2_GEONAME_ID_COUNTRY=2921044 DBIP2_GEONAME_ID_CONTINENT=6255148 EXTERNAL_COUNTRY_SHORT=DE IP2LOCATION_DATABASE_INFO=IP2L-DB11 IPv4 IPv6 20181226 Copyright (c) 2018 IP2Location All Rights Reserved GEOIP2_DATABASE_INFO=GeoLite2-City Copyright (c) 2019 MaxMind All Rights Reserved, created: 20191217-200126 UTC / GeoLite2-ASN Copyright (c) 2019 MaxMind All Rights Reserved, created: 20190122-114228 UTC DBIP2_DATABASE_INFO=DBIP-Location-ISP (compat=Enterprise) Copyright (c) 2019 db-ip.com All Rights Reserved, created: 20190101-015418 UTC EXTERNAL_DATABASE_INFO=EXTDB-4/AFRINIC/20200904 APNIC/20200903 ARIN/20200903 IANA/20191106 LACNIC/20200903 LISP/20200318 RIPENCC/20200903, created: 20200904-063305 UTC BUILTIN_DATABASE_INFO=IPv6-REG:AFRINIC/20201012 APNIC/20201010 ARIN/20201011 IANA/20191106 LACNIC/20201009 LISP/20200318 RIPENCC/20201011 IPV6CALC_NAME=ipv6calc IPV6CALC_VERSION=3.0.0 IPV6CALC_COPYRIGHT="(P) & (C) 2001-2020 by Peter Bieringer <pb (at) bieringer.de>" IPV6CALC_OUTPUT_VERSION=21 IPV6CALC_SETTINGS_ANON="set=keep-type-asn-cc,mask-ipv6=56,mask-ipv4=24,mask-eui64=40,mask-mac=24,method=keep-type-asn-cc" IPV6CALC_FEATURES="GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID" IPV6CALC_CAPABILITIES="GeoIP2(linked/MaxMindDB) IP2Location(linked) DBIP2(linked/MaxMindDB) ExternalDatabase DB_AS_REG(BuiltIn) DB_CC_REG(BuiltIn) DB_IPV4_REG(BuiltIn) DB_IPV6_REG(BuiltIn) DB_IEEE(BuiltIn)"
Using option --mrst <TOKEN> (Machine Readable Select Token) can be used to display only a selected token
$ ipv6calc -q -i --mrst IPV6_TYPE 2a01:238:423d:8800:85b3:9e6b:3019:8909 IPV6_TYPE=unicast,global-unicast,productive,iid-random,iid,iid-local
Using option --mrmt <TOKEN> (Machine Readable Match Token) can be used to display only matching tokens
$ ipv6calc -q -i --mrmt IP2LOCATION 2a01:238:423d:8800:85b3:9e6b:3019:8909 IP2LOCATION_COUNTRY_SHORT=DE IP2LOCATION_COUNTRY_LONG=Germany IP2LOCATION_REGION=Berlin IP2LOCATION_CITY=Berlin IP2LOCATION_ZIPCODE=10178 IP2LOCATION_LATITUDE=52.524368 IP2LOCATION_LONGITUDE=13.410530 IP2LOCATION_TIMEZONE_NAME=+01:00 IP2LOCATION_DATABASE_INFO=IP2L-DB11 IPv6 20181226 Copyright (c) 2018 IP2Location All Rights Reserved
Using option --mrtvo <TOKEN> (Machine Readable Token Value Only) can be used to display only thevalue of a selected token
$ ipv6calc -q -i --mrtvo IPV6_TYPE 2a01:238:423d:8800:85b3:9e6b:3019:8909 unicast,global-unicast,productive,iid-random,iid,iid-local
Using option --mrqva (Machine Readable Quote Values Always) can be used to quote values always of a selected token
$ ipv6calc -q -i --mrqva --mrtvo IPV6_TYPE 2a01:238:423d:8800:85b3:9e6b:3019:8909 "unicast,global-unicast,productive,iid-random,iid,iid-local"
Using option --mrqvn (Machine Readable Quote Values Never) can be used to never quote values of a selected token
$ ipv6calc -q -i --mrqvn --mrst IPV6_AS_TEXT 2a01:238:423d:8800:85b3:9e6b:3019:8909 IPV6_AS_TEXT=AS6724 STRATO AG
Using option --mrstpq (Machine Readable Select Token Print Always) can be used to print always token/value regardless it's contained
$ ipv6calc -q -i --mrqva --mrstpa IPV4 2a01:238:423d:8800:85b3:9e6b:3019:8909 IPV4="" $ ipv6calc -q -i --mrqva --mrst IPV4 2a01:238:423d:8800:85b3:9e6b:3019:8909 (no output)
“ipv6calc” can run in filter mode to be able to extract from a huge list of IPv4/IPv6 addresses ones which are interesting or ones which are not interesting (see printout of online help below).
Filter tokens are the ones which are listed on “TYPE” lines shown in “-m -i” information mode.
Example for searching for Teredo addresses:
$ cat ip.bieringer.de-log.201310 | awk '{ print $1 }' | sort | uniq | ipv6calc -A filter -E teredo 2001:0:9d38:90d7:34f7:1a26:8599:e079
For more information see below
Note: since version 0.95.0 '-A filter' is optional if option '-E <filter expression>' is given (autoselected action).
Since version 0.40 new-style option handling was introduced, using
--in <inputtype>
--out <outputtype>
--action <actiontype>
and many more conversions were added. A built-in check matrix should prevent misconversions.
Up to version 0.39, only old-style options (aka “shortcut” options). They are one-in-all options, specifying input/action/output in one token. Internally this options will be converted into new-style options.
Online help always shows the currently implemented features.
External database options only appear if compiled with related support.
$ ipv6calc -h ipv6calc: version 3.0.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID (P) & (C) 2001-2020 by Peter Bieringer <pb (at) bieringer.de> This program formats and calculates IPv6/IPv4/MAC addresses and can do many more tricky things [-d|--debug <debug value>] : debug value (bitwise like) can also be set by IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional detail levels) [-v|--version -h] : explanation of feature tokens [-V|--verbose] : be more verbose [-h|--help|-?] : this online help [--disable-ip2location ] : IP2Location support disabled [--db-ip2location-disable ] : IP2Location support disabled [--db-ip2location-dir <directory>] : IP2Location database directory (default: /usr/share/IP2Location) [--db-ip2location-only-type <TYPE>]: IP2Location database only selected type (1-120) [--db-ip2location-allow-softlinks] : IP2Location database softlinks allowed by default they are ignored because it is hard to autodetect COMM/LITE/SAMPLE [--db-ip2location-lite-to-sample-autoswitch-max-delta-months <MONTHS>]: autoswitch from LITE to SAMPLE databases if possible and delta is not more than 12 months (0=disabled) [--db-ip2location-comm-to-lite-switch-min-delta-months <MONTHS>]: switch from COMM to LITE databases if possible and delta more than 12 months (0=disabled) [--disable-geoip2 ] : GeoIP(MaxMindDB) support disabled [--db-geoip2-disable ] : GeoIP(MaxMindDB) support disabled [--db-geoip2-dir <directory>] : GeoIP(MaxMindDB) database directory (default: /usr/share/GeoIP) [--disable-dbip2 ] : db-ip.com(MaxMindDB) support disabled [--db-dbip2-disable ] : db-ip.com(MaxMindDB) support disabled [--db-dbip2-dir <directory>] : db-ip.com(MaxMindDB) database directory (default: /usr/share/DBIP) [--db-dbip2-only-type <TYPE>] : db-ip.com(MaxMindDB) database only selected type (1-6) [--db-dbip2-comm-to-free-switch-min-delta-months <MONTHS>]: switch from COMM to FREE databases if possible and delta more than 12 months (0=disabled) [--disable-external ] : External support disabled [--db-external-disable ] : External support disabled [--db-external-dir <directory>] : External database directory (default: /usr/share/ipv6calc/db) [--disable-builtin ] : BuiltIn support disabled [--db-builtin-disable ] : BuiltIn support disabled [--db-priorization <entry1>[:...]] : Database priorization order list (overwrites default) colon separated: GeoIP GeoIP2 IP2Location DBIP DBIP2 External BuiltIn Hint: all long options can be predefined from environment by using prefix: IPV6CALC_ and conversion: '-' -> '_' and lowercase -> uppercase example for options with values : --db-dbip2-dir=<DIR> -> environment: IPV6CALC_DB_DBIP2_DIR=<DIR> example for options without values: --db-dbip2-disable -> environment: IPV6CALC_DB_DBIP2_DISABLE=1 on|off|0|1 is supported [-q|--quiet] : be more quiet (auto-enabled in pipe mode) [-f|--flush] : flush each line in pipe mode Usage with new style options: [--in|-I <input type>] : specify input type (default: autodetect) [--out|-O <output type>] : specify output type (sometimes: autodetect) [--action|-A <action>] : specify action (default: format conversion, sometimes: autodetect) [<format option> ...] : specify format options <input data> [...] : input data Available input types: [-m] -I|--in -?|-h|--help Available output types: [-m] -O|--out -?|-h|--help Available action types: [-m] -A|--action -?|-h|--help Special filter action : -E -?|-h|--help Other usage: --showinfo|-i [--machine_readable|-m] : show information about input data --showinfo|-i --mrqva : Machine Readable Quote Values Always --showinfo|-i --mrqvn : Machine Readable Quote Values Never --showinfo|-i --mrst <TOKEN> : Machine Readable Select Token --showinfo|-i --mrstpa <TOKEN> : Machine Readable Select Token Print Always --showinfo|-i --mrmt <TOKENPREFIX> : Machine Readable Match Token Prefix --showinfo|-i --mrmts <TOKENSUFFIX> : Machine Readable Match Token Suffix --showinfo|-i --mrtvo <TOKEN> : Machine Readable Token Value Only --showinfo|-i --show-tokens : show available tokens (aka types) on '-m' Usage with shortcut options: <shortcut option> [<format option> ...] <input data> for more information and available format options use: <shortcut option> -?|-h|--help -r|--addr2ip6_int (-O revnibbles.int) -r|--addr_to_ip6int (-O revnibbles.int) -a|--addr2ip6_arpa (-O revnibbles.arpa) -a|--addr_to_ip6arpa (-O revnibbles.arpa) -b|--addr_to_bitstring (-O bitstring) --addr2compaddr (--printcompressed) --addr_to_compressed (--printcompressed) --addr2uncompaddr (--printuncompressed) --addr_to_uncompressed (--printuncompressed) --addr_to_base85 (-I ipv6addr -O base85) --base85_to_addr (-I base85 -O ipv6addr) --mac_to_eui64 (-I mac -O eui64) --addr2fulluncompaddr (--printfulluncompressed) --addr_to_fulluncompressed (--printfulluncompressed) --addr2if_inet6 (-I ipv6addr -O ifinet6) --addr_to_ifinet6 (-I ipv6addr -O ifinet6) --if_inet62addr (-I ifinet6 -O ipv6addr --printcompressed) --ifinet6_to_compressed (-I ifinet6 -O ipv6addr --printcompressed) --eui64_to_privacy (-I iid_token -O iid_token -A genprivacyiid) --ipv4_to_6to4addr (-I ipv4 -O ipv6addr -A conv6to4) --addr2cc (-A addr2cc)
each internal/external database can be disabled by option
directory of database files can be given via related option
databases requiring external library the library file can be given in case of dynamic load and linking
for geolocation databases specific file can be selected (see --db-<PROVIDER>-only-type <TYPE>)
IP2location database directory can contain a bunch of files, the best ones are selected automatically (since 0.99.0). “Best” can be controlled via two options:
--db-ip2location-lite-to-sample-autoswitch-max-delta-months <MONTHS>: switches from LITE to SAMPLE databases in case of
existing SAMPLE database
SAMPLE database not older than default/given MONTHS than the LITE database
IP address is in range of SAMPLE database (IPv4: 0.0.0.0-99.255.255.255, IPv6: 2a04::/16)
autoswitch can be disabled by using MONTHS=0
reason for implementation: show maximum possible IP2Location features
--db-ip2location-comm-to-lite-switch-min-delta-months <MONTHS>: switches from COMMercial to LITE databases in case of
existing LITE database
COMMercial database is default/given MONTHS older than the LITE database
switch can be disabled by using MONTHS=0
reason for implementation: avoid using old COMMercial databases
--db-ip2location-only-type <TYPE>: only selects databases of given type
reason for implementation: be able to select a specific database type
--db-ip2location-allow-softlinks: allow softlinked IP2Location database files
by default, softlinked database files are skipped, because it's hard to detect whether one is COMMercial, LITE or SAMPLE
use “ipv6calc -vv” or “ipv6calc -vvv” for verification, which databases are selected finally.
$ ipv6calc --in -? ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID (P) & (C) 2001-2023 by Peter Bieringer <pb (at) bieringer.de> Available input types: auto : automatic detection revnibbles.int : dot separated nibbles reverse, ending with ip6.int. revnibbles.arpa : dot separated nibbles reverse, ending with ip6.arpa. bitstring : bitstring labes, ending with ip6.arpa. ipv6addr : IPv6 address ipv6literal : IPv6 address in literal ipv4addr : IPv4 address ipv4hex : IPv4 in hexadecimal format ipv4revhex : IPv4 in byte-reversed hexadecimal format mac : MAC address (48 bits) eui64 : EUI-64 identifier (64 bits) base85 : Base-85 string ifinet6 : Like line in /proc/net/if_inet6 iid+token : Interface identifier and token ipv6logconv : ipv6logconv (currently not supported) prefix+mac : IPv6 prefix and a MAC address asn : Autonomous System Number
$ ipv6calc --out -? ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID (P) & (C) 2001-2023 by Peter Bieringer <pb (at) bieringer.de> Available output types: revnibbles.int : dot separated nibbles reverse, ending with ip6.int. revnibbles.arpa : dot separated nibbles reverse, ending with ip6.arpa. bitstring : bitstring labes, ending with ip6.arpa. ipv6addr : IPv6 address ipv4addr : IPv4 address mac : MAC address (48 bits) eui64 : EUI-64 identifier (64 bits) base85 : Base-85 string ifinet6 : Like line in /proc/net/if_inet6 iid : Interface identifier iid+token : Interface identifier and token addrtype : Address type ouitype : OUI (IEEE) type ipv6addrtype : IPv6 address type any : any type (currently not supported) revipv4 : reverse IPv4, ending with in-addr.arpa ipv4hex : IPv4 in hexadecimal format octal : IP address in escaped octal format hex : IP address in hexadecimal format ipv6literal : IPv6 address in literal ipv6to4 : IPv6 address based on 6to4 converted IPv4 address For examples and available format options use: -O|--out <type> --examples
$ ipv6calc --action -? ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID (P) & (C) 2001-2023 by Peter Bieringer <pb (at) bieringer.de> Available action types: auto : Automatic selection of action (default) geneui64 : Converts a MAC address to an EUI-64 address conv6to4 : Converts IPv4 address <-> 6to4 IPv6 address (prefix) convnat64 : Converts IPv4 address <-> NAT64 IPv6 address ipv6tomac : Extracts MAC of an IPv6 address (if detected) ipv6toeui64 : Extracts EUI64 of an IPv6 address (if detected) genprivacyiid : Generates a privacy interface ID out of a given one (arg1) and a token (arg2) prefixmac2ipv6 : Generates an IPv6 address out of a prefix and a MAC address anonymize : Anonymize IPv4/IPv6 address without loosing much information 6rd_local_prefix : Calculate the 6rd prefix from given IPv6 prefix (& relay prefix) and IPv4 Options: --6rd_prefix ... (required) --6rd_relay_prefix ... (optional) 6rd_extract_ipv4 : Extract from 6rd address the include IPv4 address Options: --6rd_prefixlength ... (required) filter : Filter addresses related to filter options test : Test address against given prefix or address Options: --test_prefix ... (optional) --test_gt ... (optional) --test_ge ... (optional) --test_lt ... (optional) --test_le ... (optional) addr2cc : Converts IPv4/IPv6 address into Country Code dbdump : Dump Database
Special action “filter” can be used especially in pipe mode to filter IP addresses related to their type and since 0.99.0 also related to database results (CountryCode, ASN or Registry).
$ ipv6calc --action filter -h ipv6calc: version 4.2.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID Filter given addresses from stdin by filter expression, e.g. echo '2001:db8::1' | ipv6calc [-A filter] -E iid-local echo '2001:db8::1' | ipv6calc [-A filter] -E iid-local,global-unicast echo '2001:db8::1' | ipv6calc [-A filter] -E ^iid-random (note: since version 0.95.0 '-A filter' is autoselected if option '-E <filter expression>' is given) negation of filter expression with prefix: ^ IPv6 address filter tokens: ipv6 unknown unicast multicast anycast loopback link-local site-local compat-v4 mapped reserved unique-local-unicast anonymized-iid anonymized-prefix 6to4 6bone global-unicast unspecified solicited-node productive 6to4-microsoft teredo orchid link-local-teredo nat64 iid-random iid iid-local iid-global iid-teredo iid-eui48 iid-eui64 iid-isatap iid-includes-ipv4 IPv4 address filter tokens: ipv4 any unicast multicast anycast broadcast loopback unspecified unknown reserved zeroconf site-local anonymized anonymized-geonameid global 6to4relay lisp lisp-proxyegresstunnelrouter-anycast lisp-mapresolver-anycast IPv4/v6 address filter tokens based on databases: [^][ipv4.|ipv6.]db.cc=<CC>|unknown (Country Code [2 chars]) [^][ipv4.|ipv6.]db.asn=<ASN>|unknown (Autonomous System Number) [^][ipv4.|ipv6.]db.reg=<REGISTRY> Registry tokens: 6BONE IANA APNIC ARIN RIPENCC LACNIC AFRINIC 6TO4 reserved unknown IPv4/v6 address filter tokens based on address/mask: [^]ipv4.addr=<IPV4-ADDRESS>[<PREFIX-LENGTH>] [^]ipv6.addr=<IPV6-ADDRESS>[<PREFIX-LENGTH>] IPv4/v6 address filter tokens based on address ranges (<=|<|>|>=): [^]ipv4.addr(<=|<|>|>=)<IPV4-ADDRESS> [^]ipv6.addr(<=|<|>|>=)<IPV6-ADDRESS> as alternative in case <|> creating problems also supported: =(le|lt|gt|ge)=: [^]ipv4.addr=(le|lt|gt|ge)=<IPV4-ADDRESS> [^]ipv6.addr=(le|lt|gt|ge)=<IPV6-ADDRESS> EUI-48/MAC address filter tokens: IMPLEMENTATION MISSING EUI-64 address filter tokens: IMPLEMENTATION MISSING
Example for some filter expressions:
$ cat ip.bieringer.de-log.201504 | ipv6calc -E ipv6.db.cc=DE | wc -l 5068 $ cat ip.bieringer.de-log.201504 | ipv6calc -E ipv6.db.cc=US | wc -l 305 $ cat ip.bieringer.de-log.201504 | ipv6calc -E ipv6.db.reg=ARIN | wc -l 306 $ cat ip.bieringer.de-log.201504 | ipv6calc -E iid-random | wc -l 4806 $ cat ip.bieringer.de-log.201504 | ipv6calc -E ipv6.db.cc=US,iid-random | wc -l 16 $ cat ip.bieringer.de-log.201504 | ipv6calc -A filter -E ipv6.db.cc=US,iid-random,ipv4.db.cc=US | wc -l 1842 $ cat ip.bieringer.de-log.201504 | ipv6calc -A filter -E db.asn=8767 | wc -l 2363 $ cat ip.bieringer.de-log.201504 | ipv6calc -A filter -E ipv6.db.asn=8767 | wc -l 1452 $ cat ip.bieringer.de-log.201504 | ipv6calc -A filter -E ipv4.db.asn=8767 | wc -l 911
Example for searching for addresses in a specific range (supported since 0.99.2):
$ cat ip.bieringer.de-log.201609 | awk '{ print $1 }' | sort | uniq | ipv6calc -E ipv6.addr=ge=2002::,ipv6.addr=lt=2003:: 2002:2518:0:1:2:3:4:5 ... 2002:d950:0:1:2:3:4:5
Special action “test” (since 0.99.2) can be used in command line or pipe mode (single address only) to test IP addresses related to a given prefix or range .
$ ipv6calc -A test -? ipv6calc: version 2.1.1 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID Test given address(es) against supported tests: --test_prefix <PREFIX> : inside a prefix --test_gt|--test_ge <ADDRESS>: greater(/equal) than an address --test_lt|--test_le <ADDRESS>: less(/equal) than an address Test given address(es) from stdin, e.g. echo '2001:db8::1' | ipv6calc [-A test] --test_prefix 2001:db8::/32 echo '2001:db8::1' | ipv6calc [-A test] --test_prefix 2001:db9::/32 Single address test, return code: 0=inside/matching 1=outside/not-matching 2=uncomparable ipv6calc [-A test] --test_prefix 2001:db8::/32 2001:db8::1 ipv6calc [-A test] --test_prefix 2001:db9::/32 2001:db8::1 ipv6calc [-A test] --test_ge 2001:db8:: --test_le 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff 2001:db8::1 ipv6calc [-A test] --test_ge 2001:db9:: --test_le 2001:db9:ffff:ffff:ffff:ffff:ffff:ffff 2001:db8::1 ipv6calc [-A test] --test_ge 2001:db9:: --test_lt 2001:dba:: 2001:db8::1 ipv6calc [-A test] --test_ge 2001:db8:: --test_lt 2001:db9:: 2001:db8::1
Example for command line mode:
$ ipv6calc --test_ge 2001:db8:: --test_le 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff 2001:db8::1; echo $? no input type specified, try autodetection...found type: ipv6addr no output type specified, try autodetection...found type: ipv6addr 2001:db8::1 greater/equal than 2001:db8:: less/equal than 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff 0
Example for command line mode (quiet):
$ ipv6calc -q --test_ge 2001:db8:: --test_le 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff 2001:db8::1; echo $? 2001:db8::1 greater/equal than 2001:db8:: less/equal than 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff 0
Example for pipe mode:
$ echo -e "1.2.3.4\n1.2.4.4" | ipv6calc --test_prefix 1.2.3.0/24 1.2.3.4 inside 1.2.3.0/24 1.2.4.4 NOT inside 1.2.3.0/24
Special action “conv6to4” (since at least 0.99.1) can be used in command line or pipe mode to convert 6to4-IPv6 in IPv4 addresses and vice versa.
$ ipv6calc: version 3.2.1 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO ANON_ZEROISE ANON_ANONYMIZE Convert IPv4 to 6to4 prefix / extract IPv4 from 6to4 prefix ipv6calc -A conv6to4 192.0.2.1 -> 2002:c000:201:: ipv6calc -A conv6to4 192.0.2.1/24 -> 2002:c000:200::/40 ipv6calc -A conv6to4 192.0.2.0/24 -> 2002:c000:200::/40 ipv6calc -A conv6to4 2002:c000:201:: -> 192.0.2.1 ipv6calc -A conv6to4 2002:c000:201::/40 -> 192.0.2.0/24 See '-O ipv4 -h' or '-O ipv6 -h' for optional output modifications Can also be used in PIPE mode to convert a list of IP addresses/networks
Example for command line mode:
$ ipv6calc -q -A conv6to4 192.0.2.1 2002:c000:201::
Example for pipe mode:
echo -e "1.2.3.4\n1.2.4.4" | ipv6calc -A conv6to4 2002:102:304:: 2002:102:404:: $ echo -e "1.2.3.0/24\n1.2.4.0/24" | ipv6calc -A conv6to4 2002:102:300::/40 2002:102:400::/40
Since version 3.3.0, action “dbdump” is provided
Version >= 3.3.0: database “External”, type: IPv4/IPv6 addresses, suppported filter: CountryCode
Precondition: created/updated “External” database
$ /usr/share/ipv6calc/tools/ipv6calc-db-update.sh ...
Precondition: active “database dump” support
$ ipv6calc -vv 2>&1 | grep -E '(DB_IPV4_DUMP_CC|DB_IPV6_DUMP_CC)' ipv6calc: version 3.3.0 GeoIP GeoIPv6 IP2Location IP2Location6 DBIPv4 DBIPv6 DB_AS_REG DB_IPV4_REG DB_IPV6_REG DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_IPV4_COUNTRY DB_IPV6_COUNTRY DB_IPV4_CITY DB_IPV6_CITY DB_IPV4_REGION DB_IPV6_REGION DB_CC_REG DB_IEEE DB_IPV4_INFO DB_IPV6_INFO DB_IPV4_GEONAMEID DB_IPV6_GEONAMEID DB_IPV4_DUMP_CC DB_IPV6_DUMP_CC ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID DB_IPV4_DUMP_CC (IPv4 Database Dump by CountryCode): External DB_IPV6_DUMP_CC (IPv6 Database Dump by CountryCode): External
Precondition: recognized “External” database
$ ipv6calc -vv 2>&1 | grep -E '(External: IPv. CountryCode)' External: IPv4 CountryCode : ipv6calc-external-ipv4-countrycode.db (EXTDB-3/AFRINIC/20210919 APNIC/20210917 ARIN/20210919 IANA/20210205 LACNIC/20210918 LISP/20200318 RIPENCC/20210918, created: 20210919-152957 UTC) External: IPv6 CountryCode : ipv6calc-external-ipv6-countrycode.db (EXTDB-4/AFRINIC/20210919 APNIC/20210917 ARIN/20210919 IANA/20191106 LACNIC/20210918 LISP/20200318 RIPENCC/20210918, created: 20210919-155049 UTC)
Usage Example: dump all IPv4 networks which have not “unknown” CountryCode
$ ipv6calc -A dbdump -E ^ipv4.db.cc=unknown # 'External' database dump (with 121894 entries) start with filter IPv4 && CountryCode(s): ^unknown (suppress this line with option '-q') 1.0.0.0/24 1.0.1.0/24 ... # 'External' database dump finished displaying 121894 entries with filter IPv4 && CountryCode(s): ^unknown (suppress this line with option '-q')
Usage Example: dump all IPv6 networks of a given CountryCode
$ ipv6calc -A dbdump -E ipv6.db.cc=VN # 'External' database dump (with 56097 entries) start with filter IPv6 && CountryCode(s): VN (suppress this line with option '-q') 2001:7fa:6::/28 2001:dc8::/28 ... # 'External' database dump finished displaying 344 entries with filter IPv6 && CountryCode(s): VN (suppress this line with option '-q')
Usage Example: dump all IPv4 networks of two given CountryCodes
$ ipv6calc -A dbdump -E ipv4.db.cc=VN,ipv4.db.cc=CN # 'External' database dump (with 121894 entries) start with filter IPv4 && CountryCode(s): VN CN (suppress this line with option '-q') 1.0.1.0/24 1.0.2.0/23 ... # 'External' database dump finished displaying 4631 entries with filter IPv4 && CountryCode(s): VN CN (suppress this line with option '-q')
Usage Example: dump all IPv4 networks of a given CountryCode incl. automatic conversion into 6to4 addresses
$ ipv6calc -A dbdump -E ipv4.db.cc=VN -I ipv4 -O ipv6to4 # 'External' database dump (with 121894 entries) start with filter IPv4 && CountryCode(s): VN (output format: 6to4) (suppress this line with option '-q') 2002:134::/30 2002:e00:1000::/36 ... # 'External' database dump finished displaying 569 entries with filter IPv4 && CountryCode(s): VN (output format: 6to4) (suppress this line with option '-q')
Usage Example: dump all IPv6to4 networks of a given CountryCode in “ipset restore” compatible format and create/update “ipset” (related “sudo” command whitelist have to be created in advance)
$ ipv6calc -A dbdump -E ipv4.db.cc=VN -I ipv4 -O ipv6to4 -q --print-ipset Net_VN_IPv6to4 >/path/to/ipset-Net_VN_IPv6to4.txt $ sudo ipset restore -f /path/to/ipset-Net_VN_IPv6to4.txt $ sudo ipset list Net_VN_IPv6to4 -t Name: Net_VN_IPv6to4 Type: hash:net Revision: 7 Header: family inet6 hashsize 1024 maxelem 65536 bucketsize 12 initval 0x30b0bdaf Size in memory: 41344 References: 0 Number of entries: 723
Hint: try also helper script for 'ipset' management
$ tools/ipv6calc-create-update-ipset.sh
This program parses address tokens of a given webserver logfile and converts them to special strings, useful for statistics (e.g. created by using "analog").
$ ipv6logconv -h ipv6logconv: version 2.1.1 CONV_REG CONV_IEEE (P) & (C) 2002-2019 by Peter Bieringer <pb (at) bieringer.de> This program converts IPv4/IPv6 addresses in HTTP server log files [-d|--debug <debug value>] : debug value (bitwise like) can also be set by IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional detail levels) [-v|--version -h] : explanation of feature tokens [-V|--verbose] : be more verbose [-h|--help|-?] : this online help Performance options: [-n|--nocache] : disable caching [-c|--cachelimit <value>] : set cache limit default: 20 maximum: 200 Output options: [--out <output type>] : specify output type addrtype : Address type ouitype : OUI (IEEE) type ipv6addrtype : IPv6 address type any : any type Takes data from stdin, proceed it to stdout
A demonstration about which kind of statistics are possible to produce is shown at http://www.ipv6.bieringer.de/ (IPv6 only).
On autoconfiguration, the interface part of an IPv6 address is based on the MAC address of the network interface card (NIC). This address is used for outgoing requests, if privacy option (RFC3041 / RFC4941) is not enabled. This results in many privacy related information on web- or mail-server log files. Administrators, which won't (be allowed to) store such information over time, but still do not want to loose information about address type distribution should use 'ipv6loganon' to anonymize their log files.
Since version 0.94.0 internally also IID anonymization is possible without loosing any information for “ipv6logstats”.
Since version 0.95.0 internally also prefix anonymization is possible without loosing any information for “ipv6logstats”.
The anonymizer would keep as much information as possible for IPv6 address types.
Client-side IID would be anonymized by
EUI-48 based: serial number would be zero'ed, keeping OID
EUI-64 based: serial number would be zero'ed, keeping OID
ISATAP: client IPv4 address would be anonymized by given IPv4 mask
TEREDO: client IPv4 address would be anonymized by given IPv4 mask, client port would be zero'ed
6to4(Microsoft): client IPv4 address would be anonymized by given IPv4 mask
local: whole IID would be zero'ed
Client-side SLA would be anonymized by
SLA would be zero'ed
Prefix would be anonymized by
6to4: client IPv4 address would be anonymized by given IPv4 mask
Compat/Mapped IPv4 addresses would be anonymized by
IPv4 address would be anonymized by given IPv4 mask
The anonymizer would keep as much information as possible for the IID of an IPv6 address.
Description from libipv6addr.h:
* IID anonymization is done by replacing with related information (64-bit) * xxxx:xxxx:xxxx:xxxC (C = 4-bit checksum) * * a9p9 4941 0000 000C -> RFC 4941 anonymized privacy extension Interface ID * * a9p9 4291 4xxx xxxC -> RFC 4291 anonymized EUI-48 Interface ID, xxx xxx = converted OUI * a9p9 4291 5xxx xxxC -> RFC 4291 anonymized EUI-48 Interface ID, xxx xxx = converted mapped IAB/OUI-36 * a9p9 4291 6xxx xxxC -> RFC 4291 anonymized EUI-64 Interface ID, xxx xxx = converted OUI * a9p9 4291 7xxx xxxC -> RFC 4291 anonymized EUI-64 Interface ID, xxx xxx = converted mapped IAB/OUI-36 * a9p9 4291 8xxx xxxC -> RFC 4291 embedded anonymized IPv4 address, xxx xxx = first 24 bit of included (anonymized) IPv4 address * a9p9 4291 c02d 5d1C -> RFC 4291 Chapter 2.5.1 anonymized static Interface ID * * a9p9 5214 4xxx xxxC -> RFC 5214 anonymized ISATAP Interface ID, xxx xxx = first 24 bit of included (anonymized) IPv4 address (local scope) * a9p9 5214 5xxx xxxC -> RFC 5214 anonymized ISATAP Interface ID, xxx xxx = first 24 bit of included (anonymized) IPv4 address (global scope) * a9p9 5214 cxx0 000C -> RFC 5214 anonymized ISATAP Interface ID, xx = first 8 bit of included vendor ID (local scope) * a9p9 5214 dxx0 000C -> RFC 5214 anonymized ISATAP Interface ID, xx = first 8 bit of included vendor ID (global scope) * a9p9 5214 exxx xxxC -> RFC 5214 anonymized ISATAP Interface ID, xxx xxx = first 24 bit of included extension ID (local scope) * a9p9 5214 fxxx xxxC -> RFC 5214 anonymized ISATAP Interface ID, xxx xxx = first 24 bit of included extension ID (global scope) * * a9p9 4843 0000 000C -> RFC 4843 anonymized ORCHID hash
Depending on given mask, the part of the prefix will be replaced:
* SLA/NLA prefix part anonymization is done by replacing with pattern a909a909 * p = number of nibbles anonymized
In addition to “anonymize” (of IID) this method anonymizes also the prefix of an IPv6 address or a whole IPv4 address by keeping ASN (Autonomous System Number, Country Code and Type).
Description from libipv6addr.h:
* Prefix anonymization in case of method=kp: p=0x0f * a909:ccca:aaaa:aaaC (C = 4-bit checksum) * ccc -> 10-bit Country Code mapping [A-Z]*[A-Z0-9] (936) * 0x3FD = LISP * 0x3FE = unknown country * 0x3FF - 16 + REGISTRY_6BONE && ASN=0 = 6bone * 0x000-0x3A7: c1= c / 36, c2 = c % 36 * aaaaaaaa -> 32-bit ASN
Description from libipv4addr.h:
* Global IPv4 addresses are anoymized by storing country code and AS number * and using prefix of experimental range (240-255.x.y.z) * * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 1 1 1 1 * |p p p p| * Prefix * 0xF * * Pariy Bit (odd parity) * |P| * * Mapping of Country Code * |c c c c c c c c c c| * 10-bit Country Code mapping [A-Z]*[A-Z0-9] (936) * 0x3FF = unknown country * 0x000-0x3A7: c1= c / 36, c2 = c % 36 * * Mapping of ASN <= 65535 * 0|a a a a a a a a a a a a a a a a| * 16-bit ASN * * Mapping of ASN >= 65536, ASN & 0xE000 == 0 (12-bit LSB is ok) * 1|r r r|0|l l l l l l l l l l l l| * 13-bit LSB of ASN * * Mapping of ASN >= 65536, ASN & 0xE000 != 0 (12-bit LSB overflow) => unspecified * 1|r r r|1|0 0 0 0 0 0 0 0 0 0 0 0| * * Mapping of ASN registry for ASN >= 65536 * 0 0 0 = "unknown ASN registry" * 0 1 0 = APNIC * 0 1 1 = RIPE * 1 0 0 = LACNIC * 1 0 1 = AFRINIC * 1 1 0 = ARIN * Mapping of LISP * 1|r r r|1|1|0 0 0 0 0 0 0 0 0 0 0|
In difference to keep-type-asn-cc this method anonymizes the prefix of an IPv6 address or a whole IPv4 address by keeping the GeonameID and Type.
Description from libipv6addr.h:
* a909:sssg:gggg:gggC (C = 4-bit checksum) * sss -> 10-bit source mapping * GeonameID source information * 0x000 = unknown * 0x001 = continent (prio: lowest) * 0x002 = country * 0x003 = state/prov * 0x004 = district * 0x005 = city (prio: highest) * 0x006 = (reserved) * 0x007 = LISP * 0x0r. = registry * -> 2 leftmost bit are |0 1| * gggggggg -> 32-bit GeonameID * 0x11800 = LISP
Description from libipv4addr.h:
* IPv4 address anonymization type "keep-type-geonameid" * Global IPv4 addresses are anonymized by storing GeonameID * and using prefix of experimental range (240-255.x.y.z) * * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 1 1 1 1 * |p p p p| * Prefix * 0xF * * Parity Bit (even parity) * |P| * * Mapping of GeonameID source * |s s s| * 3-bit GeonameID source information * 0 0 0 (0x0) = unknown * 0 0 1 (0x1) = continent (prio: lowest) * 0 1 0 (0x2) = country * 0 1 1 (0x3) = state/prov * 1 0 0 (0x4) = district * 1 0 1 (0x5) = city (prio: highest) * 1 1 0 (0x6) = (reserved) * 1 1 1 (0x7) = LISP * * Mapping of GeonameID (limited to IDs < 2^24, in worst case ID from source with lower prio is used) * |g g g g g g g g g g g g g g g g g g g g g g g g| * * Mapping of LISP registry * 0 0 0 = "unknown ASN registry" * 0 1 0 = APNIC * 0 1 1 = RIPE * 1 0 0 = LACNIC * 1 0 1 = AFRINIC * 1 1 0 = ARIN * |0 0 0 0 0 0 0 1 r r r 1 1 0 0 0 0 0 0 0 0 0 0 0|
Currently native supported log files:
Apache log file format, 1st token is IPv4 or IPv6 address
There are plans to support also mail server log files sometimes in the future, but because of different formats, this would be probably done by a Perl program which parses the log file and a (cached) 'ip6calc' call with action 'anonymize'.
$ ipv6loganon -h ipv6loganon: version 4.2.0 ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC ANON_KEEP-TYPE-GEONAMEID (P) & (C) 2007-2023 by Peter Bieringer <pb (at) bieringer.de> This program anonymizes IPv4/IPv6 addresses in e.g. HTTP server log files [-d|--debug <debug value>] : debug value (bitwise like) can also be set by IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional detail levels) [-v|--version -h] : explanation of feature tokens [-V|--verbose] : be more verbose [-h|--help|-?] : this online help [-q|--quiet] : be more quiet [--disable-ip2location ] : IP2Location support disabled [--db-ip2location-disable ] : IP2Location support disabled [--db-ip2location-dir <directory>] : IP2Location database directory (default: /usr/share/IP2Location) [--db-ip2location-only-type <TYPE>]: IP2Location database only selected type (1-666) [--db-ip2location-allow-softlinks] : IP2Location database softlinks allowed by default they are ignored because it is hard to autodetect COMM/LITE/SAMPLE [--db-ip2location-lite-to-sample-autoswitch-max-delta-months <MONTHS>]: autoswitch from LITE to SAMPLE databases if possible and delta is not more than 12 months (0=disabled) [--db-ip2location-comm-to-lite-switch-min-delta-months <MONTHS>]: switch from COMM to LITE databases if possible and delta more than 12 months (0=disabled) [--disable-geoip2 ] : GeoIP(MaxMindDB) support disabled [--db-geoip2-disable ] : GeoIP(MaxMindDB) support disabled [--db-geoip2-dir <directory>] : GeoIP(MaxMindDB) database directory (default: /usr/share/GeoIP) [--disable-dbip2 ] : db-ip.com(MaxMindDB) support disabled [--db-dbip2-disable ] : db-ip.com(MaxMindDB) support disabled [--db-dbip2-dir <directory>] : db-ip.com(MaxMindDB) database directory (default: /usr/share/DBIP) [--db-dbip2-only-type <TYPE>] : db-ip.com(MaxMindDB) database only selected type (1-6) [--db-dbip2-comm-to-free-switch-min-delta-months <MONTHS>]: switch from COMM to FREE databases if possible and delta more than 12 months (0=disabled) [--disable-external ] : External support disabled [--db-external-disable ] : External support disabled [--db-external-dir <directory>] : External database directory (default: /usr/share/ipv6calc/db) [--disable-builtin ] : BuiltIn support disabled [--db-builtin-disable ] : BuiltIn support disabled [--db-priorization <entry1>[:...]] : Database priorization order list (overwrites default) colon separated: GeoIP2 IP2Location DBIP2 External BuiltIn Hint: all long options can be predefined from environment by using prefix: IPV6CALC_ and conversion: '-' -> '_' and lowercase -> uppercase example for options with values : --db-dbip2-dir=<DIR> -> environment: IPV6CALC_DB_DBIP2_DIR=<DIR> example for options without values: --db-dbip2-disable -> environment: IPV6CALC_DB_DBIP2_DISABLE=1 on|off|0|1 is supported [-w|--write] : write output to file instead of stdout [-a|--append] : append output to file instead of stdout [-f|--flush] : flush output after each line [-V|--verbose] : be verbose [-n|--nocache] : disable caching [-c|--cachelimit <value>] : set cache limit default: 20 maximum: 200 Shortcut for anonymization presets: --anonymize-standard (default) --anonymize-careful --anonymize-paranoid Supported methods [--anonymize-method METHOD]: anonymize : reliable anonymization, keep as much type information as possible zeroize : simple zeroizing according to given masks, probably loose type information keep-type-asn-cc: special reliable anonymization, keep type & Autonomous System Number and CountryCode keep-type-geonameid: special reliable anonymization, keep type & GeonameID Available presets (shortcut names) [--anonymize-preset|ap PRESET-NAME]: anonymize-standard (as): mask-ipv6= 56 mask-ipv4=24 mask-eui64=40 mask-mac=24 mask-autoadjust=yes method=anonymize anonymize-careful (ac): mask-ipv6= 48 mask-ipv4=20 mask-eui64=24 mask-mac=24 mask-autoadjust=yes method=anonymize anonymize-paranoid (ap): mask-ipv6= 40 mask-ipv4=16 mask-eui64= 0 mask-mac=24 mask-autoadjust=no method=anonymize zeroize-standard (zs): mask-ipv6= 56 mask-ipv4=24 mask-eui64=40 mask-mac=24 mask-autoadjust=yes method=zeroize zeroize-careful (zc): mask-ipv6= 48 mask-ipv4=20 mask-eui64=24 mask-mac=24 mask-autoadjust=yes method=zeroize zeroize-paranoid (zp): mask-ipv6= 40 mask-ipv4=16 mask-eui64= 0 mask-mac=24 mask-autoadjust=no method=zeroize keep-type-asn-cc (kp): mask-ipv6= 56 mask-ipv4=24 mask-eui64=40 mask-mac=24 mask-autoadjust=yes method=keep-type-asn-cc keep-type-geonameid (kg): mask-ipv6= 56 mask-ipv4=24 mask-eui64=40 mask-mac=24 mask-autoadjust=yes method=keep-type-geonameid Custom control: --mask-ipv4 <bits> : mask IPv4 address [0-32] (even if occurs in IPv6 address) --mask-ipv6 <bits> : mask IPv6 prefix [0-64] (only applied to related address types) --mask-eui64 <bits> : mask EUI-64 address or IPv6 interface identifier [0-64] --mask-mac <bits> : mask MAC address [0-48] --mask-autoadjust yes|no: autoadjust mask to keep type/vendor information regardless of less given mask Takes data from stdin, outputs the processed data to stdout (default)
Note: since 0.91.1 also a module for Apache Webserver is available (see below) supporting anonymized logging
(Supported since 0.90.0)
Adjust or add (note: more than one CustomLog directive is supported by Apache) httpd.conf like following:
CustomLog "|/usr/local/bin/ipv6loganon -a -f /var/log/httpd/access_log" combined
In case of “cronolog” is used on the system, configure like this:
Apache version < 2.4:
CustomLog "|/usr/bin/ipv6loganon -f |/usr/sbin/cronolog /var/log/httpd/access.log-%Y%m%d" combined
Apache version >= 2.4:
CustomLog "|$/usr/bin/ipv6loganon -f |/usr/sbin/cronolog /var/log/httpd/access.log-%Y%m%d" combined
The “tools” subdirectory contains helper scripts for updating external databases.
$ /usr/share/ipv6calc/tools/IP2Location-update.sh -h Usage: IP2Location-update.sh [-D <dir>] [-n] [-s] -D <dir> database destination directory (optional) -n no action (dry-run) -s skip already successfully downloaded files database directory: /usr/share/IP2Location (default: /usr/share/IP2Location) it honors externally defined environment value: IP2LOCATION_DAT_DIR this script will download data from ip2location.com into given/set database directory Sample databases: IP2LOCATION_DAT_FILES_SAMPLE=IPv4:20 IPv6:20 IPv4:24 IPv6:24 Lite (free) databases: IP2LOCATION_DAT_FILES_LITE_FREE=IPv4:1 IPv6:1 With authentication (requires login/password in /home/compile/.ip2location) and a valid subscription IP2LOCATION_DAT_FILES_LITE= Credentials must be defined in $HOME/.ip2location by login=IP2LOCATION-LOGIN password=IP2LOCATION-PASSWORD In addition settings from above can be overwritten by setting related variables
Just note that old database format (version 1) is no longer supported for free download, ipv6calc >= 2.0.0 supports also MaxMindDB format, ipv6calc >= 3.0.0 drops legacy download capability
$ /usr/share/ipv6calc/tools/GeoIP-update.sh -h Usage: GeoIP-update.sh [-D <dir>] [-v] [-s] [-L] [-G] -s skip download -D <dir> database directory (optional) -v verbose database directory: @GEOIP2_DB@ (default: @GEOIP2_DB@) it honors externally defined environment value: prio 1: GEOIP_DAT_DIR prio 2: IPV6CALC_DB_GEOIP2_DIR adjust /etc/GeoIP.conf in advance: EditionIDs GeoLite2-Country GeoLite2-City GeoLite2-ASN (in case a valid license key exists, add key and extend EditionIDs related) see also https://dev.maxmind.com/geoip/geoipupdate/
Since ipv6calc >= 2.0.0 supports also MaxMindDB format, so download of CSV files and converting them into BerkeleyDB format is no longer required.
$ /usr/share/ipv6calc/tools/DBIP-update.sh -h Usage: DBIP-update.sh [-v] [-s] [-D <dir>] [-U <url>] [-T <type>] -s skip download -v verbose -D <dir> database directory (optional) -U <url> use URL to download full database -T <type> set type of via URL downloaded file MMDB: country|isp|location|*location-isp* CSV : isp|location|*full* database directory: /usr/share/DBIP (default: /usr/share/DBIP) it honors externally defined environment value: prio 1: DBIP_DAT_DIR prio 2: IPV6CALC_DB_DBIP2_DIR this script will download data from DB-IP.com (default: free versions) the MaxMindDB (mmdb) files DB files for ipv6calc "DBIP" database support DBIP_DAT_URL_BASE=http://download.db-ip.com/free/ DBIP_DAT_FILES=dbip-country-lite-%Y-%m.mmdb.gz dbip-city-lite-%Y-%m.mmdb.gz in case -U <url> (take URL from subscription e-mail) is provided, it downloads the database use -T <type> in case it's not "location-isp"
$ /usr/share/ipv6calc/tools/ipv6calc-db-update.sh -h Usage: ipv6calc-db-update.sh [-s] [-u] [-D <dir>] -s skip download -u unconditional update -D <dir> database directory (optional) database directory: /usr/share/ipv6calc/db (default: /usr/share/ipv6calc/db) it honors externally defined environment value: IPV6CALC_DAT_DIR this script (and its helper scripts) will download data from registries and generate Berkeley DB files for ipv6calc "external" database support
Because calling C programs directly as CGI isn't really recommended (too much security troubles all the time), I wrote a small wrapper utility which calls "ipv6calc" to get information about client and server address for displaying on a web page.
A demonstration about which kind of output is possible to produce is shown at
http://ip.bieringer.net/ (IPv4/IPv6)
http://www.ipv6.bieringer.de/ (IPv6 only)
http://mirrors.bieringer.de/ (IPv4/IPv6)
This program parses a given webserver logfile and count addresses, useful for time period statistics.
Since version 0.95.0 it has extended output, adding a date/time line and statistics by Country Code and ASN (if required databases are available).
$ ipv6logstats -h ipv6logstats: version 4.2.0 STAT_REG STAT_CC STAT_AS (P) & (C) 2003-2023 by Peter Bieringer <pb (at) bieringer.de> Takes web server log data (or any other data which has IPv4/v6 address in first column) from stdin and print statistics table/list (depending on option) to stdout [-d|--debug <debug value>] : debug value (bitwise like) can also be set by IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional detail levels) [-v|--version -h] : explanation of feature tokens [-V|--verbose] : be more verbose [-h|--help|-?] : this online help [-q|--quiet] : be more quiet [--disable-ip2location ] : IP2Location support disabled [--db-ip2location-disable ] : IP2Location support disabled [--db-ip2location-dir <directory>] : IP2Location database directory (default: /usr/share/IP2Location) [--db-ip2location-only-type <TYPE>]: IP2Location database only selected type (1-666) [--db-ip2location-allow-softlinks] : IP2Location database softlinks allowed by default they are ignored because it is hard to autodetect COMM/LITE/SAMPLE [--db-ip2location-lite-to-sample-autoswitch-max-delta-months <MONTHS>]: autoswitch from LITE to SAMPLE databases if possible and delta is not more than 12 months (0=disabled) [--db-ip2location-comm-to-lite-switch-min-delta-months <MONTHS>]: switch from COMM to LITE databases if possible and delta more than 12 months (0=disabled) [--disable-geoip2 ] : GeoIP(MaxMindDB) support disabled [--db-geoip2-disable ] : GeoIP(MaxMindDB) support disabled [--db-geoip2-dir <directory>] : GeoIP(MaxMindDB) database directory (default: /usr/share/GeoIP) [--disable-dbip2 ] : db-ip.com(MaxMindDB) support disabled [--db-dbip2-disable ] : db-ip.com(MaxMindDB) support disabled [--db-dbip2-dir <directory>] : db-ip.com(MaxMindDB) database directory (default: /usr/share/DBIP) [--db-dbip2-only-type <TYPE>] : db-ip.com(MaxMindDB) database only selected type (1-6) [--db-dbip2-comm-to-free-switch-min-delta-months <MONTHS>]: switch from COMM to FREE databases if possible and delta more than 12 months (0=disabled) [--disable-external ] : External support disabled [--db-external-disable ] : External support disabled [--db-external-dir <directory>] : External database directory (default: /usr/share/ipv6calc/db) [--disable-builtin ] : BuiltIn support disabled [--db-builtin-disable ] : BuiltIn support disabled [--db-priorization <entry1>[:...]] : Database priorization order list (overwrites default) colon separated: GeoIP2 IP2Location DBIP2 External BuiltIn Hint: all long options can be predefined from environment by using prefix: IPV6CALC_ and conversion: '-' -> '_' and lowercase -> uppercase example for options with values : --db-dbip2-dir=<DIR> -> environment: IPV6CALC_DB_DBIP2_DIR=<DIR> example for options without values: --db-dbip2-disable -> environment: IPV6CALC_DB_DBIP2_DISABLE=1 on|off|0|1 is supported [-u|--unknown] : print unknown IP addresses to stderr [-c|--columns] : print statistics in columns (1) [-N|--column-numbers] : print column numbers [-n|--noheader] : don't print header in columns mode (1) [-o|--onlyheader] : print only header in columns mode (1) [-p|--prefix <token>] : print token as prefix (1) [-s|--simple] : disable extended statistic (CountryCode/ASN) (1) unsupported for CountryCode & ASN statistics
There are a README and some helper scripts available in the package how to use this program and how to generate a graph using Gnuplot.
The example shows output version 4.0, which
$ cat ip.bieringer.de-log.202401 | ipv6logstats
Header section, since output version 3.0 (>= 0.95.0) additional lines starting with '*3*' and '*DateTime' and '*UnixTime' included
*Version 4.0 *DateTime: 2024:01:21 08:07:59+0000 GMT *UnixTime: 1705824479 *3*DB-Info: DB features: 0xff1fffff *3*DB-Info: GeoIP(MaxMindDB): features available/implemented: 0x03063ff0/0x03063ff0 *3*DB-Info: GeoIP2: info of available databases in directory: /var/local/share/GeoIP *3*DB-Info: GeoIP2: IPv4/v6 CountryCode (FREE) : [1] GeoLite2-Country.mmdb (GeoLite2-Country Copyright (c) 2024 MaxMind All Rights Reserved, created: 20240112-201408 UTC) *3*DB-Info: GeoIP2: IPv4/v6 City (FREE) : [2] GeoLite2-City.mmdb (GeoLite2-City Copyright (c) 2024 MaxMind All Rights Reserved, created: 20240112-195220 UTC) *3*DB-Info: GeoIP2: IPv4/v6 ASN (FREE) : [3] GeoLite2-ASN.mmdb (GeoLite2-ASN Copyright (c) 2024 MaxMind All Rights Reserved, created: 20240112-193300 UTC) *3*DB-Info: IP2Location: features available/implemented: 0x0c003fc0/0x0c003ff0 *3*DB-Info: IP2Location: info of available databases in directory: /var/local/share/IP2Location *3*DB-Info: IP2Location: Copyright (c) IP2Location All Rights Reserved *3*DB-Info: IP2Location: IPv4 Co/Re/Ci/LaLo/ZI/TZ/IS/Do/Ne/Ar/We/Mo :[220] IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-SAMPLE.BIN (IP2L-DB20 IPv4 IPv6 SAMPLE 20240101) *3*DB-Info: IP2Location: IPv4 Co/Re/Ci/LaLo/ZI/TZ/IS/Do/Ne/Ar/We/Mo/El/Us:[224] IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-SAMPLE.BIN (IP2L-DB24 IPv4 IPv6 SAMPLE 20240101) *3*DB-Info: IP2Location: IPv6 Co/Re/Ci/LaLo/ZI/TZ/IS/Do/Ne/Ar/We/Mo :[320] IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.SAMPLE.BIN (IP2L-DB20 IPv4 IPv6 SAMPLE 20240101) *3*DB-Info: IP2Location: IPv6 Co/Re/Ci/LaLo/ZI/TZ/IS/Do/Ne/Ar/We/Mo/El/Us:[324] IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.SAMPLE.BIN (IP2L-DB24 IPv4 IPv6 SAMPLE 20240101) *3*DB-Info: IP2Location: IPv4 Country :[401] IP2LOCATION-LITE-DB1.BIN (IP2L-DB1 IPv4 IPv6 LITE 20231215) *3*DB-Info: IP2Location: IPv4 Co/Re/Ci/LattLong/ZIP/TZ :[411] IP2LOCATION-LITE-DB11.BIN (IP2L-DB11 IPv4 IPv6 LITE 20231215) *3*DB-Info: IP2Location: IPvx Country :[501] IP2LOCATION-LITE-DB1.IPV6.BIN (IP2L-DB1 IPv4 IPv6 LITE 20231215) *3*DB-Info: IP2Location: IPvx Co/Re/Ci/LattLong/ZIP/TZ :[511] IP2LOCATION-LITE-DB11.IPV6.BIN (IP2L-DB11 IPv4 IPv6 LITE 20231215) *3*DB-Info: IP2Location: IPvx Co/Re/Ci/LattLong/ZIP/TZ :[111] IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.BIN (IP2L-DB11 IPv4 IPv6 20231215) *3*DB-Info: db-ip.com(MaxMindDB): features available/implemented: 0x30063ff0/0x30063ff0 *3*DB-Info: DBIP2: info of available databases in directory: /var/local/share/DBIP *3*DB-Info: DBIP2: IPv4/v6 CountryCode (FREE) : [1] dbip-country-lite.mmdb (DBIP-Country-Lite Copyright (c) 2024 db-ip.com All Rights Reserved, created: 20240101-231423 UTC) *3*DB-Info: DBIP2: IPv4/v6 City (FREE) : [2] dbip-city-lite.mmdb (DBIP-City-Lite Copyright (c) 2024 db-ip.com All Rights Reserved, created: 20240101-231818 UTC) *3*DB-Info: DBIP2: IPv4/v6 Location+ISP (COMM) : [6] dbip-location-isp.mmdb (DBIP-Location-ISP (compat=Enterprise) Copyright (c) 2024 db-ip.com All Rights Reserved, created: 20240102-010801 UTC) *3*DB-Info: External: features available/implemented: 0xc01980cc/0xc01980cc *3*DB-Info: External: info of available databases in directory: /var/local/share/ipv6calc *3*DB-Info: External: IPv4 Registry : ipv6calc-external-ipv4-registry.db (EXTDB-1/AFRINIC/20240107 APNIC/20240106 ARIN/20240107 IANA/20231218 LACNIC/20240105 LISP/20200318 RIPENCC/20240106, created: 20240107-161126 UTC) *3*DB-Info: External: IPv6 Registry : ipv6calc-external-ipv6-registry.db (EXTDB-2/AFRINIC/20240107 APNIC/20240106 ARIN/20240107 IANA/20191106 LACNIC/20240105 LISP/20200318 RIPENCC/20240106, created: 20240107-162146 UTC) *3*DB-Info: External: IPv4 CountryCode : ipv6calc-external-ipv4-countrycode.db (EXTDB-3/AFRINIC/20240107 APNIC/20240106 ARIN/20240107 IANA/20231218 LACNIC/20240105 LISP/20200318 RIPENCC/20240106, created: 20240107-161126 UTC) *3*DB-Info: External: IPv6 CountryCode : ipv6calc-external-ipv6-countrycode.db (EXTDB-4/AFRINIC/20240107 APNIC/20240106 ARIN/20240107 IANA/20191106 LACNIC/20240105 LISP/20200318 RIPENCC/20240106, created: 20240107-162146 UTC) *3*DB-Info: BuiltIn: features available/implemented: 0x0001c00f/0x0001c00f *3*DB-Info: BuiltIn: info of available databases *3*DB-Info: BuiltIn: ASN : IANA/20230810 *3*DB-Info: BuiltIn: CC : AFRINIC/20240119 APNIC/20240119 ARIN/20240119 LACNIC/20240119 RIPENCC/20240119 *3*DB-Info: BuiltIn: IPv4 : AFRINIC/20240119 APNIC/20240119 ARIN/20240119 IANA/20231218 LACNIC/20240119 LISP/20200318 RIPENCC/20240119 (created: 20240120-044633 UTC) *3*DB-Info: BuiltIn: IPv6 : AFRINIC/20240119 APNIC/20240119 ARIN/20240119 IANA/20191106 LACNIC/20240119 LISP/20200318 RIPENCC/20240119 (created: 20240120-050328 UTC) *3*DB-Info: BuiltIn: IEEE : IAB/20240120 OUI/20240120 OUI28/20240120 OUI36/20240120 *3*DB-Info: Database selection or priorization ('->': subsequential calls) *3*DB-Info: Database priorization default: GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB)->GeoIP->db-ip.com->External->BuiltIn *3*DB-Info: DB_AS_REG (AS-Number to Registry database): BuiltIn *3*DB-Info: DB_CC_REG (CountryCode to Registry database): BuiltIn *3*DB-Info: DB_IPV4_REG (IPv4 to Registry database): BuiltIn *3*DB-Info: DB_IPV6_REG (IPv6 to Registry database): BuiltIn *3*DB-Info: DB_IPV4_AS (IPv4 to AS database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV6_AS (IPv6 to AS database): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV4_CC (IPv4 to CountryCode database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB)->External *3*DB-Info: DB_IPV6_CC (IPv6 to CountryCode database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB)->External *3*DB-Info: DB_IPV4_COUNTRY (IPv4 to Country database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV6_COUNTRY (IPv6 to Country database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV4_CITY (IPv4 to City database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV6_CITY (IPv6 to City database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV4_REGION (IPv4 to Region database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV6_REGION (IPv6 to Region database): GeoIP(MaxMindDB)->IP2Location->db-ip.com(MaxMindDB) *3*DB-Info: DB_IEEE (IEEE/OUI/OUI28/OUI36 Vendor database): BuiltIn *3*DB-Info: DB_IPV4_INFO (IPv4 additional information): External->BuiltIn *3*DB-Info: DB_IPV6_INFO (IPv6 additional information): External->BuiltIn *3*DB-Info: DB_IPV4_GEONAMEID (IPv4 GeonameID): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV6_GEONAMEID (IPv6 GeonameID): GeoIP(MaxMindDB)->db-ip.com(MaxMindDB) *3*DB-Info: DB_IPV4_DUMP_CC (IPv4 Database Dump by CountryCode): External *3*DB-Info: DB_IPV6_DUMP_CC (IPv6 Database Dump by CountryCode): External
Simple statistics section
ALL 68612 IPv4 57311 IPv6 11301 UNKNOWN 0 IPv4/APNIC 4154 IPv4/ARIN 27873 IPv4/RIPE 24889 IPv4/LACNIC 305 IPv4/AFRINIC 90 IPv4/UNKNOWN 0 IPv6/6bone 0 IPv6/IANA 0 IPv6/APNIC 506 IPv6/ARIN 1475 IPv6/RIPE 9103 IPv6/LACNIC 216 IPv6/AFRINIC 0 IPv6/RESERVED 0 IPv6/UNKNOWN 0 IPv6/6to4/IANA 0 IPv6/6to4/APNIC 0 IPv6/6to4/ARIN 0 IPv6/6to4/RIPE 1 IPv6/6to4/LACNIC 0 IPv6/6to4/AFRINIC 0 IPv6/6to4/RESERVED 0 IPv6/6to4/UNKNOWN 0 IPv6/Teredo/IANA 0 IPv6/Teredo/APNIC 0 IPv6/Teredo/ARIN 0 IPv6/Teredo/RIPE 0 IPv6/Teredo/LACNIC 0 IPv6/Teredo/AFRINIC 0 IPv6/Teredo/RESERVED 0 IPv6/Teredo/UNKNOWN 0 IPv6/NAT64/IANA 0 IPv6/NAT64/APNIC 0 IPv6/NAT64/ARIN 0 IPv6/NAT64/RIPE 0 IPv6/NAT64/LACNIC 0 IPv6/NAT64/AFRINIC 0 IPv6/NAT64/RESERVED 0 IPv6/NAT64/UNKNOWN 0 IPv6/IID/Global 2581 IPv6/IID/Random 6880 IPv6/IID/Manual 1839 IPv6/IID/ISATAP 0 IPv6/IID/Unknown 0
External database supported output since output version 3.0 (>= 0.95.0)
Country Code / Proto
... *3*CC-code-proto/DE/ALL 9126 *3*CC-code-proto/DE/IPv4 5381 *3*CC-code-proto/DE/IPv6 3745 *3*CC-code-proto-list/DE 9126 5381 3745 ...
Proto / Country Code (“ALL” line contains: ALL IPv4 IPv6)
... *3*CC-proto-code/ALL/DE 96450 *3*CC-proto-code/IPv4/DE 36486 *3*CC-proto-code/IPv6/DE 59964 ... *3*CC-proto-code-list/ALL 108525 46483 62042
Autonomous System number / Proto
... *3*AS-num-proto/8767/ALL 6054 *3*AS-num-proto/8767/IPv4 2705 *3*AS-num-proto/8767/IPv6 3349 *3*AS-num-proto-list/8767 6054 2705 3349 ...
Proto / Autonomous System number (“ALL” line contains: ALL IPv4 IPv6)
... *3*AS-proto-num/ALL/8767 6054 *3*AS-proto-num/IPv4/8767 2705 *3*AS-proto-num/IPv6/8767 3349 ... *3*AS-proto-num-list/ALL 108525 46483 62042
Column output does not support version 3 extension, only simple statistics with a header line:
$ zcat ip.bieringer.de-log.201*.gz | ipv6logstats -q -c IPv4 IPv6 UNKNOWN IPv4/APNIC IPv4/ARIN IPv4/RIPE IPv4/LACNIC IPv4/UNKNOWN IPv6/6bone IPv6/IANA IPv6/APNIC IPv6/ARIN IPv6/RIPE IPv6/LACNIC IPv6/RESERVED IPv6/UNKNOWN IPv6/6to4/IANA IPv6/6to4/APNIC IPv6/6to4/ARIN IPv6/6to4/RIPE IPv6/6to4/LACNIC IPv6/6to4/RESERVED IPv6/6to4/UNKNOWN IPv6/Teredo/IANA IPv6/Teredo/APNIC IPv6/Teredo/ARIN IPv6/Teredo/RIPE IPv6/Teredo/LACNIC IPv6/Teredo/RESERVED IPv6/Teredo/UNKNOWN IPv6/NAT64/IANA IPv6/NAT64/APNIC IPv6/NAT64/ARIN IPv6/NAT64/RIPE IPv6/NAT64/LACNIC IPv6/NAT64/RESERVED IPv6/NAT64/UNKNOWN IPv6/IID/Global IPv6/IID/Random IPv6/IID/Manual IPv6/IID/ISATAP IPv6/IID/Unknown 46233 62292 0 2397 3525 40198 97 16 0 0 129 839 61074 0 0 0 0 0 16 51 0 0 0 0 63 0 90 30 0 0 0 0 0 0 0 0 0 1436 58198 2055 353 0
An optional prefix token can be given (“-p <prefix>”) to create e.g. in a for-loop one line per month and put month in front of statistics, also the header line can be suppressed (“-n”).
$ zcat ip.bieringer.de-log.201*.gz | ipv6logstats -q -c -n -p ALL ALL 46233 62292 0 2397 3525 40198 97 16 0 0 129 839 61074 0 0 0 0 0 16 51 0 0 0 0 63 0 90 30 0 0 0 0 0 0 0 0 0 1436 58198 2055 353 0
A demonstration with real data is available at http://mirrors.bieringer.de/stats/timeline.html.
This Apache web server module (since version 0.99.1, released 2015) interfaces with internal ipv6calc library to support
Client IP address anonymization “on-the-fly”, exported to IPV6CALC_CLIENT_IP_ANON
depending on the configured anonymization method 3rd party database is required
Country code of client IP address, exported to IPV6CALC_CLIENT_COUNTRYCODE
requires 3rd party database: GeoIP or IP2Location or DB-IP.com
Autonomous System Number (ASN) of client IP address, exported to IPV6CALC_CLIENT_ASN
requires 3rd party database: GeoIP
Registry of client IP address, exported to IPV6CALC_CLIENT_REGISTRY
requires internal or “external” database
Configured IP address anonymization method, exported to IPV6CALC_ANON_METHOD
Install compiled Apache module “mod_ipv6calc” to Apache's module directory
Install included default configuration file “ipv6calc.conf” to Apache's config directory (usually conf.d)
Enable in “ipv6calc.conf” loading of module
LoadModule ipv6calc_module modules/mod_ipv6calc.so
Enable module itself
ipv6calcEnable on
Adjust configuration settings, if needed (see examples in “ipv6calc.conf”)
Review predefined log format
LogFormat "%{IPV6CALC_CLIENT_IP_ANON}e \"%{IPV6CALC_CLIENT_COUNTRYCODE}e/%{IPV6CALC_CLIENT_ASN}e/%{IPV6CALC_CLIENT_REGISTRY}e/%{IPV6CALC_ANON_METHOD}e\" %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_anon
Enable custom log with anonymized information, using the predefined LogFormat
CustomLog logs/access_anon_log combined_anon
Restart Apache web server, check error_log for any issues
The new log file contains anonymized requests like
252.176.92.172 "CN/23724/APNIC/keep-type-asn-cc" - [25/Jul/2015:13:20:25 +0200] "GET / HTTP/1.1" 200 3569 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" a909:390a:909a:81d9:a909:4291:c02d:5d1d "CZ/43037/RIPENCC/keep-type-asn-cc" - [25/Jul/2015:12:59:00 +0200] "GET /robots.txt HTTP/1.1" 200 33 "-" "Mozilla/5.0 (compatible; SeznamBot/3.2; +http://fulltext.sblog.cz/)"
In case “keep-type-asn-cc” is configured and also working (required databases are available), related information of anonymized IP addresses can be retrieved using “ipv6calc” or “ipv6logstats”.
$ ipv6calc -q -m -i 252.176.92.172 IPV4=252.176.92.172 IPV4_TYPE=unicast,anonymized,global IPV4_AS_NUM=23724 IPV4_COUNTRYCODE=CN IPV4_REGISTRY=APNIC ... $ ipv6calc -q -m -i a909:390a:909a:81d9:a909:4291:c02d:5d1d IPV6=a909:390a:909a:81d9:a909:4291:c02d:5d1d IPV6_TYPE=unicast,anonymized-iid,anonymized-prefix,global-unicast,productive,iid,iid-local IPV6_COUNTRYCODE=CZ IPV6_AS_NUM=43037 IPV6_REGISTRY=RIPENCC ...
Major extensions/changes are listed here
add support for compressed IPv4 addresses like 10/8 (>= 3.1.0)
add support for octal representation of IPv4 addresses (>= 3.3.0)
add Database Dump action (>= 3.3.0)
add OUI-28 support (>= 2.2.0)
add action “addr2cc” (can be used as replacement for geoiplookup) (>= 2.1.0)
enable “geonameid” also in mod_ipv6calc (>= 2.1.0)
add anonymization method “keep-type-geonameid” (>= 2.1.0)
add support for MaxMindDB (GeoIP, db-ip.com) (>= 2.0.0)
drop support of IP2Location libraries < 7.0.1 (>= 2.0.0)
add support for LISP detection
add support for non-free versions DB-IP.com databases
finally release 1.0.0 after 16 year of development
Introduce mod_ipv6calc for Apache web server (>= 0.99.1)
Add support for DB-IP.com databases (by generated Berkeley DB files) (>= 0.98.0)
Add support for “External” database files (generated Berkeley DB files), superseeding (if newer) built-in IPv4/IPv6->Registry and adding IPv4/IPv6->CountryCode support (>= 0.98.0)
Extend filter options with support of CountryCode, ASN or Registry (>= 0.99.0)
Add support for IP2Location LITE databases (>= 0.99.0), add configurable IP2Location database autoselection support
Prefix and IID anonymization methods
Support of dynamic load of GeoIP and IP2Location libraries
Specifying dedicated GeoIP and IP2Location database files is now replaced by specifying dedicated database directories to make especially for GeoIP use of more database files.
ipv6calc/ipv6calcweb.cgi: enable included GeoIP support with IPv6 (usable with GeoIP >= 1.4.5)
ipv6calc: extend for 6rd support (--action 6rd_local_prefix --6rd_prefix <PREFIX> --6rd_relay_prefix <RELAY_PREFIX>)
ipv6calc: enable stdin support for bulk transformation
ipv6calc: add support for NAT64 address type
ipv6calc: add option “forceprefix <LENGTH>” to print prefix of an address without a given prefix length
ipv6loganon: extend for pipe usage (e.g. in Apache log file directive) and write/append to specified file
General: add configure options to disable built-in databases (reduce binary size a lot, e.g. for embedded devices)
See ChangeLog@GitHub for now
Updated 18.02.2017 | Sources | DeepSpace6 |
Your connection is via:
IPv4
Your address: 44.222.134.250 |
mirrors.bieringer.de is maintained by webmaster at bieringer dot de (Impressum) |