RiptideTempora

Lazy IP ban command for bash v2

May 29th, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. # For Debian-based systems
  2. # Add this to your .bashrc
  3. banip() {
  4.   if [ -z $1 ]
  5.     echo "Parameter not passed."
  6.   then
  7.     iptables -A INPUT -s $1 -j DROP
  8.     iptables -A OUTPUT -d $1 -j DROP
  9.     echo "$1 banned."
  10.     #If you get an error, switch the comment out below 
  11.     #/etc/init.d/iptables save
  12.     iptables-save
  13.   fi
  14. }
  15. #usage: banip XX.XX.XX.XX
  16. # Blocks incoming and outgoing connections to a given IP or subnet
Advertisement
Add Comment
Please, Sign In to add comment