Skip to content

Instantly share code, notes, and snippets.

@tg12
Last active March 7, 2020 15:43
Show Gist options
  • Save tg12/902c462b2220eb5b7e2239db4426ddb8 to your computer and use it in GitHub Desktop.
Save tg12/902c462b2220eb5b7e2239db4426ddb8 to your computer and use it in GitHub Desktop.
If you are a masochist, Create iptables from ALL Firehol lists
#this may take a while, run with no hup and monitor the log
rm blocklist-ipsets/ -r
git clone https://github.com/firehol/blocklist-ipsets.git
cd blocklist-ipsets/
#We just want the IP's
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" *.ipset > merged-file
#We just want the unique IP's across the board
sort -u merged-file > merged-file_output
#Just the unique ips, iptables
for IP in $(cat merged-file_output | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | awk '{print $1}' | sort | uniq); do echo "Banning $IP"; iptables -A INPUT -s $IP/32 -d 0/0 -j DROP; iptables -A INPUT -s $IP/32 -d 0/0 -j LOG --log-prefix 'firehol-iptables-rule-js'; done
echo "yay, Finished!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment