Advertisement
eugeniabahit

JackTheStripper - blockip command

Jun 14th, 2013
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ "$USER" == "root" ]; then
  4.     if [ "$1" != "" ]; then
  5.         rule="-I INPUT -s $1 -j DROP"
  6.         sed s/COMMIT//g /etc/iptables.firewall.rules > /tmp/blockip.tmp
  7.         echo $rule >> /tmp/blockip.tmp
  8.         echo "COMMIT" >> /tmp/blockip.tmp
  9.         mv /tmp/blockip.tmp /etc/iptables.firewall.rules
  10.         iptables-restore < /etc/iptables.firewall.rules
  11.         echo "Rule added."
  12.     else
  13.         echo "No IP found."
  14.     fi
  15. else
  16.     echo "Permiso denegado."
  17. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement