Ip2Range creates or queries a mysql database mapping ipV4 addresses to countries with the option of overriding the country code by ranges in cidr notation. For example the ip address of google-bot becomes 'google-bot' instead of 'us'. You are free to enter other ranges.
$ composer install
$ php ip2range.php
$ nano ip2range.ini
Configuration of ip2range.php can be changed by editing the iniFile. The stem of the programme name is used determining the default iniFile name.
Ip2range.php can be called with input from a pipe and to create an ip address information table.
If a database is given in an iniFile a table with ip ranges can be built from ftp registries of ip address ranges assigned to countries.
$ php ip2range.php -b
Or with a logfile:
$ php ip2range.php -b -l logfile -d DEBUG &
$ tail -f logfile
Instead of ftp the database can be created using the zip file from ip2nation.com. This database cannot be used for inserting a cidr to.
$ php ip2range.php -z
Name will be derived from filename.
$ php ip2range.php -c
$ php ip2range.php -ip 104.132.0.1
A googlebot
$ cat access.log | php ip2range.php
Line endings in piped input work only in php < 6
CustomLog "|/usr/bin/php /home/pi/ip2range/ip2range.php -out ${APACHE_LOG_DIR}/extended_access.log" combined
Warning and error messages are put to stderr and will be visible in httpd error log file.