pb at bieringer dot de
Revision History | ||
---|---|---|
Revision 4.0 | 2013-11-02 | Revised by: PB |
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 utiltity 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 freshmeat / ipv6calc page (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)
If not disabled during compiling the tool, following databases are statically included, now internally mentioned as “BuiltIn”:
IEEE & OUI databases (for decoding vendor part of MAC/EUI-48)
IPv4 assignment database (for selecting proper registry in ipv6calcweb.cgi)
IPv6 database (for selecting proper registry in ipv6calcweb.cgi)
If enabled during compiling the tool, following external (but local stored) databases can be used
GeoIP IPv4, IPv6 (since 0.90.0, req. GeoIP >= 1.4.5)
IP2Location IPv4, IPv6
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 disabled.
Via CVS at DeepSpace6: DeepSpace6 / CVS instructions
Via web interface to CVS at DeepSpace6: DeepSpace6 / CVS web interface
Via FTP at DeepSpace6: DeepSpace6 / anonymous FTP
A SPEC file is included, so you can build a RPM from source tarball using
$ rpmbuild -ta path/to/ipv6calc-$version.tar.gz |
Currently only on rpmfind / ipv6calc, but there are plans to publish at least source RPMS on DeepSpace6 some day.
Fedora 19 is the current developing platform, so use given hints above to create a RPM. Since Fedora 7 this package is included by default.
It's tested by the developer that creation of the RPM is working fine on RHEL 4. Since RHEL 5 this package is included by default.
CentOS 5 and CentOS 6 are also platforms for regression tests.
Linux Mandrake is very similar to Red Hat Linux, therefore a rebuild should work, too.
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/
Following “ipc6calc” related configure options are currently supported (note: disabling the internal databases reduces the size of the resulting binary 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) --enable-ip2location Enable IP2Location support (default: disabled) --enable-geoip Enable GeoIP support (default: disabled) --with-ip2location-headers=DIR IP2Location include files location --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-headers=DIR GeoIP include files location --with-geoip-lib=DIR GeoIP library location --with-geoip-static Explicitly link GeoIP statically (default=no) --with-geoip-dynamic Enable use of dynamic loading of GeoIP library (default=no) --with-geoip-db=DIR Use specified GeoIP database directory, default: /usr/share/GeoIP --with-geoip-dyn-lib=NAME Use specified GeoIP dynamic library, default: libGeoIP.so.1 --with-geoip-ipv6-compat Use IPv6 interface of GeoIP in compatibility mode (supporting 1.4.5) |
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 -W : use extra CFLAGS=-Werror -n|--no-make : stop before running 'make' -a|--all : enable GeoIP and IP2Location support -g|--geoip : enable GeoIP support --geoip-dyn|-G : switch to dynamic library loading of GeoIP -i|--ip2location : enable IP2Location support --ip2location-dyn|-I: switch to dynamic library loading of IP2Location --disable-db-ieee : disable built-in IEEE database --disable-db-ipv4 : disable built-in IPv4 database --disable-db-ipv6 : disable builtin IPv6 database --geoip-ipv6-compat : enable GeoIP IPv6 compatibility mode |
sending announcements of new versions
very low
only moderators are allowed to post
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/ipv6calc -v ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC |
Option “-v -v” (since 0.91.0) shows built-in features in detail, depending on configuration before compiling:
$ ./ipv6calc/ipv6calc -v -v ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC GeoIP support by dynamic library load, compiled with IPv4 & IPv6 support GeoIP configured dynamic library file and version: libGeoIP.so.1 1.5.1 GeoIP available databases: Country4=1 Country6=1 ASN4=1 ASN6=1 City4=1 City6=1 IP2Location support by dynamic library load IP2Location configured dynamic library file and version: libIP2Location.so version-unknown BuiltIn databases available: ASN=1 IPv4=1 IPv6=1 IEEE=1 CC_REG=1 DB features: 0x0000133f GeoIP: features: 0x00000330 GeoIP: info of available databases in directory: /usr/share/GeoIP (max: 31) GeoIP: GeoIP Country Edition :[ 1] /usr/share/GeoIP/GeoIP.dat (GEO-106FREE 20131001 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved) GeoIP: GeoIP City Edition, Rev 1 :[ 2] /usr/share/GeoIP/GeoIPCity.dat (GEO-533LITE 20131001 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved) GeoIP: GeoIP ASNum Edition :[ 9] /usr/share/GeoIP/GeoIPASNum.dat (GEO-117 20130926 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved) GeoIP: GeoIP Country V6 Edition :[12] /usr/share/GeoIP/GeoIPv6.dat (GEO-106FREE 20131001 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved) GeoIP: GeoIP ASNum V6 Edition :[21] /usr/share/GeoIP/GeoIPASNumv6.dat (GEO-117 20130306 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved) GeoIP: GeoIP City Edition V6, Rev 1 :[30] /usr/share/GeoIP/GeoIPCityv6.dat (GEO-536LITE 20131001 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved) IP2Location: features: 0x00000300 IP2Location: info of available databases in directory: /usr/share/IP2Location IP2Location: IPv4 Country : /usr/share/IP2Location/IP-COUNTRY.BIN (IP2L-DB24 20130411 Copyright (c) 2013 IP2Location All Rights Reserved) IP2Location: IPv6 Country : /usr/share/IP2Location/IPV6-COUNTRY.BIN (IP2L-DB1 20130307 Copyright (c) 2013 IP2Location All Rights Reserved) BuiltIn: features: 0x0000100f BuiltIn: info of available databases BuiltIn: ASN : IANA/20130730 BuiltIn: CC : AFRINIC/20130806 APNIC/20130805 ARIN/20130805 LACNIC/20130805 RIPENCC/20130805 BuiltIn: IPv4 : AFRINIC/20131014 APNIC/20131014 ARIN/20131014 IANA/20130520 LACNIC/20131014 RIPENCC/20131014 BuiltIn: IPv6 : AFRINIC/20131015 APNIC/20131014 ARIN/20131014 IANA/20130215 LACNIC/20131014 RIPENCC/20131014 BuiltIn: IEEE : IAB/20131015 OUI/20131015 OUI36/20131015 |
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. There are at least plans to create an overlay to built-in databases by publishing and use some “precompiled” newer 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.
Information about a simple IPv6 address:
$ ./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 |
Information about a Teredo IPv6 address:
$ ./ipv6calc -q -i 3ffe:831f:ce49:7601:8000:efff:af4a:86BF Address type: unicast, 6bone, global-unicast, productive, teredo IPv4 address: 80.181.121.64 IPv4 registry[80.181.121.64]: RIPENCC IPv4 address: 206.73.118.1 IPv4 registry[206.73.118.1]: ARIN Address type is Teredo and included IPv4 server address is: 80.181.121.64 and client port: 4096 IPv4 registry for Teredo server address: ARIN Registry for address: reserved |
There exists also a machine readable output (e.g. used by 'ipv6calcweb.cgi') - in addition, IP2Location and/or GeoIP 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=2a01:0238:423d:8809:a929:4941:0000:000c IPV6_TYPE=unicast,global-unicast,productive,iid-random,iid,iid-local SLA=8800 IPV6_REGISTRY=RIPENCC IPV6_COUNTRYCODE=DE IPV6_AS_NUM=6724 IID=85b3:9e6b:3019:8909 EUI64_SCOPE=local-random IP2LOCATION_COUNTRY_SHORT=DE IP2LOCATION_COUNTRY_LONG=GERMANY GEOIP_AS_TEXT=AS6724 STRATO STRATO AG GEOIP_LATITUDE=51.000000 GEOIP_LONGITUDE=9.000000 GEOIP_COUNTRY_SHORT=DE GEOIP_COUNTRY_LONG=Germany IP2LOCATION_DATABASE_INFO=IP2L-DB1 20130307 Copyright (c) 2013 IP2Location All Rights Reserved GEOIP_DATABASE_INFO=GEO-106FREE 20131001 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved / GEO-117 20130306 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved / GEO-536LITE 20131001 Build 1 Copyright (c) 2013 MaxMind Inc All Rights Reserved IPV6CALC_NAME=ipv6calc IPV6CALC_VERSION=0.95.0.rc.1 IPV6CALC_COPYRIGHT="(P) & (C) 2001-2013 by Peter Bieringer <pb (at) bieringer.de>" IPV6CALC_OUTPUT_VERSION=7 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="IP2Location(dyn-load) GeoIP(dyn-load) GeoIPv6 ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE" |
“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 |
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 (which perhaps - but it's not planned at the moment - are going obsolete sometimes the future) were available. 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.
IP2Location and GeoIP options only appear if compiled with such support.
ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE (P) & (C) 2001-2013 by Peter Bieringer <pb (at) bieringer.de> This program formats and calculates IPv6 addresses and can do many more tricky things [-d|--debug <debug value>] : debug value (bitwise like) can also be set IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional verbose levels) [-h|--help|-?] : this online help [--db-ip2location-disable ] : IP2Location support disabled [--db-ip2location-dir <directory>] : IP2Location database directory (default: /usr/share/IP2Location) [--db-ip2location-lib <file>] : IP2Location library file (default: libIP2Location.so) [--db-geoip-disable ] : GeoIP support disabled [--db-geoip-dir <directory>] : GeoIP database directory (default: /usr/share/GeoIP) [--db-geoip-lib <file>] : GeoIP library file (default: libGeoIP.so.1) [-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 Other usage: --showinfo|-i [--machine_readable|-m] : show information about input data --showinfo|-i --show_types : show available types on '-m' To see old-style option use: --printoldoptions |
$ ./ipv6calc --in -? ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE (P) & (C) 2001-2013 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 hexdecimal format ipv4revhex : IPv4 in byte-reversed hexdecimal format mac : MAC address (48 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 |
$ ./ipv6calc --out -? ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE (P) & (C) 2001-2013 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 hexdecimal format octal : IP address in escaped octal format ipv6literal : IPv6 address in literal For examples and available format options use: --out <type> --examples |
$ ./ipv6calc --action -? ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE (P) & (C) 2001-2013 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) 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 Required options: --6rd_prefix ... --6rd_relay_prefix ... filter : Filter addresses related to filter options |
Special action “filter”:
$ ./ipv6calc --action filter -h ipv6calc: version 0.95.0 IP2Location GeoIP GeoIPv6 DB_AS DB_IPV4 DB_IPV6 DB_IPV4_AS DB_IPV6_AS DB_IPV4_CC DB_IPV6_CC DB_CC_REG DB_IEEE Filter given addresses from stdout 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' is given) 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 global 6to4relay MAC address filter tokens: IMPLEMENTATION MISSING EUI-64 address filter tokens: IMPLEMENTATION MISSING |
$ ./ipv6calc --printoldoptions ipv6calc: version 0.81.0 (P) & (C) 2001-2011 by Peter Bieringer <pb (at) bieringer.de> Usage with old style (shortcut) options (going obsolete): <shortcut option> [<format option> ...] <input data> [...] --addr2ip6_int --addr_to_ip6int --addr2ip6_arpa --addr_to_ip6arpa --addr_to_bitstring --addr2compaddr --addr_to_compressed --addr2uncompaddr --addr_to_uncompressed --addr_to_base85 --base85_to_addr --mac_to_eui64 --addr2fulluncompaddr --addr_to_fulluncompressed --addr2if_inet6 --addr_to_ifinet6 --if_inet62addr --ifinet6_to_compressed --eui64_to_privacy --ipv4_to_6to4addr |
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").
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) * 0x3FF = unknown country * 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 |
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: version 0.95.0 ANON_ZEROISE ANON_ANONYMIZE ANON_KEEP-TYPE-ASN-CC (P) & (C) 2007-2013 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 IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional verbose levels) [-h|--help|-?] : this online help [--db-ip2location-disable ] : IP2Location support disabled [--db-ip2location-dir <directory>] : IP2Location database directory (default: /usr/share/IP2Location) [--db-ip2location-lib <file>] : IP2Location library file (default: libIP2Location.so) [--db-geoip-disable ] : GeoIP support disabled [--db-geoip-dir <directory>] : GeoIP database directory (default: /usr/share/GeoIP) [--db-geoip-lib <file>] : GeoIP library file (default: libGeoIP.so.1) [-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 Available presets (shortcut names) [--anonymize-preset PRESET-NAME]: anonymize-standard (as): mask-ipv6= 56 mask-ipv4=24 mask-iid=40 mask-mac=24 method=anonymize anonymize-careful (ac): mask-ipv6= 48 mask-ipv4=20 mask-iid=24 mask-mac=24 method=anonymize anonymize-paranoid (ap): mask-ipv6= 40 mask-ipv4=16 mask-iid= 0 mask-mac=24 method=anonymize zeroize-standard (zs): mask-ipv6= 56 mask-ipv4=24 mask-iid=40 mask-mac=24 method=zeroize zeroize-careful (zc): mask-ipv6= 48 mask-ipv4=20 mask-iid=24 mask-mac=24 method=zeroize zeroize-paranoid (zp): mask-ipv6= 40 mask-ipv4=16 mask-iid= 0 mask-mac=24 method=zeroize keep-type-asn-cc (kp): mask-ipv6= 56 mask-ipv4=24 mask-iid=40 mask-mac=24 method=keep-type-asn-cc 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-iid <bits> : mask IPv6 interface identifiers [0-64] --mask-mac <bits> : mask MAC address [0-48] Takes data from stdin, outputs the processed data to stdout (default) |
$ cat /path/to/http_log | ./ipv6loganon >/path/to/http_log_anonymized |
(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 |
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.de/ (IPv4/IPv6)
http://www.ipv6.bieringer.de/ (IPv6 only)
http://mirrors.bieringer.de/ (IPv4/IPv6)
http://www.sixxs.net/tools/ipv6calc/ (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: version 0.95.0.rc.1 STAT_REG STAT_CC STAT_AS (P) & (C) 2003-2013 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 IPV6CALC_DEBUG environment value [-v|--version [-v [-v]]] : version information (2 optional verbose levels) [-h|--help|-?] : this online help [--db-ip2location-disable ] : IP2Location support disabled [--db-ip2location-dir <directory>] : IP2Location database directory (default: /usr/share/IP2Location) [--db-ip2location-lib <file>] : IP2Location library file (default: libIP2Location.so) [--db-geoip-disable ] : GeoIP support disabled [--db-geoip-dir <directory>] : GeoIP database directory (default: /usr/share/GeoIP) [--db-geoip-lib <file>] : GeoIP library file (default: libGeoIP.so.1) [-u|--unknown] : print unknown IP addresses to stderr [-c|--colums] : print statistics in colums (1) [-n|--noheader] : don't print header in colums mode (1) [-o|--onlyheader] : print only header in colums mode (1) [-p|--prefix <token>] : print token as prefix (1) [-q|--quiet] : be more quiet (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.
A demonstration with real data is available at http://mirrors.bieringer.de/stats/timeline.html.
Major extensions/changes are listed here
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)