Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Last active March 7, 2020 04:52
Show Gist options
  • Save hoangdh/c294250487d440864f872a252d1c036d to your computer and use it in GitHub Desktop.
Save hoangdh/c294250487d440864f872a252d1c036d to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -n "$1" ]
then
sudo iptables -I INPUT -s $1 -j DROP -m comment --comment "Block. Reason: $2"
echo "This IP ($1) has been blocked by $2"
else
echo -e "Usage: ./$0 <ip> <reason>\nExample: ./$0 1.2.3.4 \"Bruteforce site abc.com\""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment