Created
November 18, 2010 21:51
-
-
Save tskrynnyk/705711 to your computer and use it in GitHub Desktop.
ipdeny2ipset
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
#! /bin/bash | |
# ipdeny2ipset: | |
# | |
# http://ipset.netfilter.org/ | |
# http://www.ipdeny.com/ipblocks/ | |
# IPdeny fair Usage Limits policy: http://www.ipdeny.com/usagelimits.php | |
# | |
# CHINA (CN) | |
# KAZAKHSTAN (KZ) | |
# KOREA (KR) | |
# MEXICO (MX) | |
# RUSSIAN FEDERATION (RU) | |
# UKRAINE (UA) | |
IPDENY_URL='http://www.ipdeny.com/ipblocks/data/countries' | |
COUNTRIES=(cn kz kr mx ru ua) | |
SETLIST_NAME=ipdeny | |
ipset -N $SETLIST_NAME setlist | |
for i in ${COUNTRIES[*]}; do | |
wget --quiet -c ${IPDENY_URL}/${i}.zone && \ | |
#ZONE=$i && \ | |
ZONE=`echo $i | tr '[:lower:]' '[:upper:]'` && \ | |
ipset -N $ZONE nethash && \ | |
(cat ${i}.zone | while read ip; do ipset -A $ZONE $ip; done) && \ | |
ipset -A $SETLIST_NAME $ZONE | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment