Advertisement
Santeador

Fail2ban_to_hosts.deny

Oct 8th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | None | 0 0
  1. #!/bin/bash
  2. #Look for "already" banned IP
  3. if tail -n 1 /var/log/fail2ban.log | grep -q already
  4. then
  5.    IP=$(awk -F' ' 'END{print $6}' /var/log/fail2ban.log)
  6. else
  7.   exit
  8. fi
  9. #Look if IP is already in hosts.deny
  10. if grep -q $IP /etc/hosts.deny
  11. then
  12.    exit
  13. else
  14.    echo ALL: $IP >> /etc/hosts.deny
  15. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement