C library for the MaxMind DB file format http://maxmind.github.io/libmaxminddb/ https://github.com/maxmind/libmaxminddb MaxMind DB File Format Specification https://maxmind.github.io/MaxMind-DB/ https://maxmind.github.io/libmaxminddb/ https://maxmind.github.io/libmaxminddb/#example GeoLite2 Free Downloadable Databases https://dev.maxmind.com/geoip/geolite2-free-geolocation-data #FreeBSD: #pkg install libmaxminddb #[ -d /usr/local/share/GeoIP ] || mkdir -p /usr/local/share/GeoIP #wget "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_LICENSE_KEY&suffix=tar.gz" -O/tmp/GeoLite2-Country.tar.gz #tar -xz --cd /tmp -f /tmp/GeoLite2-Country.tar.gz $(tar -tzf /tmp/GeoLite2-Country.tar.gz | grep GeoLite2-Country.mmdb) #mv /tmp/$(tar -tzf /tmp/GeoLite2-Country.tar.gz | grep GeoLite2-Country.mmdb) /usr/local/share/GeoIP/ #rm -rf /tmp/$(tar -tzf /tmp/GeoLite2-Country.tar.gz | grep GeoLite2-Country.mmdb | xargs dirname) /tmp/GeoLite2-Country.tar.gz #wget "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_LICENSE_KEY&suffix=tar.gz" -O/tmp/GeoLite2-City.tar.gz #tar -xz --cd /tmp -f /tmp/GeoLite2-City.tar.gz $(tar -tzf /tmp/GeoLite2-City.tar.gz | grep GeoLite2-City.mmdb) #mv /tmp/$(tar -tzf /tmp/GeoLite2-City.tar.gz | grep GeoLite2-City.mmdb) /usr/local/share/GeoIP/ ##rm -rf /tmp/$(tar -tzf /tmp/GeoLite2-City.tar.gz | grep GeoLite2-City.mmdb | xargs dirname) /tmp/GeoLite2-City.tar.gz FreeBSD: pkg install libmaxminddb [ -d /usr/local/share/GeoIP ] || mkdir -p /usr/local/share/GeoIP curl https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-City wget --user=YOUR_ACCOUNT_ID --password=YOUR_LICENSE_KEY https://updates.maxmind.com/geoip/databases/GeoLite2-City/update -O/usr/local/share/GeoIP/GeoLite2-City.mmdb.gz gzip -t /usr/local/share/GeoIP/GeoLite2-City.mmdb.gz && gzip -d -f /usr/local/share/GeoIP/GeoLite2-City.mmdb.gz curl https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-Country wget --user=YOUR_ACCOUNT_ID --password=YOUR_LICENSE_KEY https://updates.maxmind.com/geoip/databases/GeoLite2-Country/update -O/usr/local/share/GeoIP/GeoLite2-Country.mmdb.gz gzip -t /usr/local/share/GeoIP/GeoLite2-Country.mmdb.gz && gzip -d -f /usr/local/share/GeoIP/GeoLite2-Country.mmdb.gz CentOS 8 yum install -y libmaxminddb libmaxminddb-devel geoipupdate perl -pi -e 's|^AccountID 0$|AccountID YOUR_ACCOUNT_ID|; s|^LicenseKey 000000000000$|LicenseKey YOUR_LICENSE_KEY|;' /etc/GeoIP.conf geoipupdate -v ls -l /usr/share/GeoIP/GeoLite2-*.mmdb #CentOS 9 #yum install -y libmaxminddb libmaxminddb-devel #yum install -y rpm-build perl-PerlIO-gzip #wget https://vault.centos.org/centos/8-stream/AppStream/Source/SPackages/geoipupdate-2.5.0-2.el8.src.rpm -O/tmp/geoipupdate-2.5.0-2.el8.src.rpm #rpmbuild --rebuild /tmp/geoipupdate-2.5.0-2.el8.src.rpm #rpm -Uvh ~/rpmbuild/RPMS/x86_64/geoipupdate-2.5.0-2.el9.x86_64.rpm ~/rpmbuild/RPMS/noarch/geoipupdate-cron-2.5.0-2.el9.noarch.rpm #perl -pi -e 's|^AccountID 0$|AccountID YOUR_ACCOUNT_ID|; s|^LicenseKey 000000000000$|LicenseKey YOUR_LICENSE_KEY|;' /etc/GeoIP.conf #geoipupdate -v #ls -l /usr/share/GeoIP/GeoLite2-*.mmdb CentOS 9 yum install -y libmaxminddb libmaxminddb-devel yum install -y rpm-build perl-PerlIO-gzip yum install -y perl-LWP-Protocol-https wget https://vault.centos.org/centos/8-stream/AppStream/Source/SPackages/geoipupdate-2.5.0-2.el8.src.rpm -O/tmp/geoipupdate-2.5.0-2.el8.src.rpm rpm -i /tmp/geoipupdate-2.5.0-2.el8.src.rpm wget https://mta.org.ua/GeoIP/packages/rpms-redhat/geoipupdate-2.5.0-2.el8.corvax/specs/geoipupdate.spec -O ~/rpmbuild/SPECS/geoipupdate.spec rsync -avL rsync://rsync.mta.org.ua/GeoIP/packages/rpms-redhat/geoipupdate-2.5.0-2.el8.corvax/sources/ ~/rpmbuild/SOURCES/ rpmbuild -ba ~/rpmbuild/SPECS/geoipupdate.spec rpm -Uvh ~/rpmbuild/RPMS/x86_64/geoipupdate-2.5.0-2.el9.corvax.x86_64.rpm ~/rpmbuild/RPMS/noarch/geoipupdate-cron-2.5.0-2.el9.corvax.noarch.rpm perl -pi -e 's|^AccountID 0$|AccountID YOUR_ACCOUNT_ID|; s|^LicenseKey 000000000000$|LicenseKey YOUR_LICENSE_KEY|;' /etc/GeoIP.conf #geoipupdate-pureperl.pl -v -f /etc/GeoIP.conf -d /usr/share/GeoIP geoipupdate -v ls -l /usr/share/GeoIP/GeoLite2-*.mmdb Ubuntu: apt-get update && apt-get install -y libmaxminddb0 libmaxminddb-dev geoipupdate mmdb-bin perl -pi -e 's|^\# AccountID YOUR_ACCOUNT_ID_HERE$|AccountID YOUR_ACCOUNT_ID|; s|^\# LicenseKey YOUR_LICENSE_KEY_HERE$|LicenseKey YOUR_LICENSE_KEY|;' /etc/GeoIP.conf geoipupdate -v ls -l /var/lib/GeoIP/GeoLite2-*.mmdb warn set acl_m_maxminddb_result = ${dlfunc{/usr/local/libexec/exim/exim-dlfunc.so}{maxminddb}{/usr/local/share/GeoIP/GeoLite2-Country.mmdb}{$sender_host_address}{country registered_country continent}{YES}} set acl_m_ip2country_result = ${extract{country}{$acl_m_maxminddb_result}} warn set acl_m_maxminddb_result = ${dlfunc{/usr/local/libexec/exim/exim-dlfunc.so}{maxminddb}{/usr/local/share/GeoIP/GeoLite2-ASN.mmdb}{$sender_host_address}{asn}{YES}} set acl_m_ip2asn_result = ${extract{asn}{$acl_m_maxminddb_result}}