Skip to content

Instantly share code, notes, and snippets.

@SystemZ
Last active February 5, 2021 22:57
Show Gist options
  • Save SystemZ/0d599505069b5a01f227 to your computer and use it in GitHub Desktop.
Save SystemZ/0d599505069b5a01f227 to your computer and use it in GitHub Desktop.
Geoblock IPs from China
#!/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
@BlackGlassSkin
Copy link

Thanks, Michał

I added 2 more
jp.zone
ru.zone
I couldn't keep counting banned addresses on VESTA
what a time !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment