Last active
May 21, 2020 15:17
-
-
Save eksiscloud/e5020a4e165b050aed9c44521d4166c0 to your computer and use it in GitHub Desktop.
Udating GeoIP2 database for iptables monthly by cron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# this script is intended to run with sudo privileges | |
# It is using GeoLite2xtables to do csv's from MaxMind databases | |
# Make this executable: sudo chmod +x /etc/cron.monthly/geoip-updater | |
echo 'Removing old database---------------------------------------------------' | |
rm -rf /usr/share/xt_geoip/* | |
mkdir /usr/share/xt_geoip | |
echo 'Downloading country databases-------------------------------------------' | |
/usr/local/src/GeoLite2xtables/00_download_geolite2 | |
echo 'Building countryinfo----------------------------------------------------' | |
/usr/local/src/GeoLite2xtables/10_download_countryinfo | |
echo 'Building GeoIP-legacy.csv-----------------------------------------------' | |
cat /tmp/GeoLite2-Country-Blocks-IPv{4,6}.csv | ./20_convert_geolite2 /tmp/CountryInfo.txt > /usr/share/xt_geoip/GeoIP-legacy.csv | |
echo 'Let's fix a minor issue in the script------------------------------------' | |
cp /tmp/GeoLite2-Country-Blocks-IPv4.csv /usr/local/src/GeoLite2xtables/GeoLite2-Country-Blocks-IPv4.csv | |
cp /tmp/GeoLite2-Country-Blocks-IPv6.csv /usr/local/src/GeoLite2xtables/GeoLite2-Country-Blocks-IPv6.csv | |
echo 'Building *.csv------------------------------------------------------------' | |
/usr/lib/xtables-addons/xt_geoip_build -D /usr/share/xt_geoip /usr/share/xt_geoip/GeoIP-legacy.csv | |
echo 'That's it, folks. CU next month!-------------------------------------------' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment