Skip to content

Instantly share code, notes, and snippets.

View sanderbaas's full-sized avatar

Sander Baas sanderbaas

  • Dordrecht, Netherlands
  • 23:03 (UTC +02:00)
View GitHub Profile
@sanderbaas
sanderbaas / block_ip.sh
Last active June 10, 2019 12:59
Bash script to add myip.ms IP blacklist to iptables
#!/bin/bash
SETNAME="ip_blacklist"
SETNAME6="ip6_blacklist"
SOURCE="https://myip.ms/files/blacklist/general/full_blacklist_database.zip"
ADDRESSES=$(curl $SOURCE 2>/dev/null | gunzip | awk '$1 ~ /^[^#]/ {print $1}')
# only proceed if new ip's are obtained
if [ -n "$ADDRESSES" ]; then
# ensure list ipv4 exists