Skip to content

Instantly share code, notes, and snippets.

@aristidesneto
Created May 2, 2018 01:22
Show Gist options
  • Select an option

  • Save aristidesneto/1af8b30b61d98273f1d2909de6ef85ac to your computer and use it in GitHub Desktop.

Select an option

Save aristidesneto/1af8b30b61d98273f1d2909de6ef85ac to your computer and use it in GitHub Desktop.
MY_IP=0.0.0.0
# Create the ipset list
ipset -N china hash:net
ipset -N tor iphash
# remove any old list that might exist from previous runs of this script
rm cn.zone
rm tor.zone
# Pull the latest IP set for China and Tor
wget -P . http://www.ipdeny.com/ipblocks/data/countries/cn.zone
wget -q https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$MY_IP -O -|sed '/^#/d' > tor.zone
# Add each IP address from the downloaded list into the ipset 'china'
for i in $(cat cn.zone ); do ipset -A china $i; done
for i in $(cat tor.zone); do ipset -A tor $i; done
# Restore iptables
/sbin/iptables-restore < /etc/iptables/rules.v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment