Last active
February 5, 2021 22:57
-
-
Save SystemZ/0d599505069b5a01f227 to your computer and use it in GitHub Desktop.
Geoblock IPs from China
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 | |
#install this first | |
#apt-get install ipset | |
#add kernel module | |
modprobe -v ip_set | |
modprobe -v ip_set_hash_netport | |
#create list for IPs | |
ipset create geoblock hash:net | |
#Sorry China, too much attacks and spam from you, please be careful and responsive to abuses next time :( | |
for IP in $(wget -O - http://ipdeny.com/ipblocks/data/countries/cn.zone) | |
do | |
sudo ipset add geoblock $IP | |
done | |
#Think about adding more countries like ru,vn,ng | |
#https://en.wikipedia.org/wiki/ISO_3166-2 | |
iptables -I INPUT -m set --set geoblock src -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, Michał
I added 2 more
jp.zone
ru.zone
I couldn't keep counting banned addresses on VESTA
what a time !!!