Changes

Jump to navigation Jump to search
203 bytes added ,  17:02, 5 December 2017
Line 25: Line 25:  
#!/bin/bash
 
#!/bin/bash
 
# GET BAD IP'S
 
# GET BAD IP'S
cat /var/log/mail.log | grep rejected | cut -d"[" -f3 | cut -d"]" -f1 > /tmp/firewall.txt
+
cat /var/log/mail.log | grep rejected | cut -d"[" -f3 | cut -d"]" -f1|grep -v '^$' > /tmp/firewall.txt
 
# insert to Firewall
 
# insert to Firewall
 
while read line; do sudo ufw insert 1 deny from $line to any; done < /tmp/firewall.txt
 
while read line; do sudo ufw insert 1 deny from $line to any; done < /tmp/firewall.txt
Line 32: Line 32:  
</pre>
 
</pre>
 
run by cron hourly..
 
run by cron hourly..
 +
 +
Info:
 +
 +
This Script scan the mail.log File for "rejected" entries (replace rejected by fail or other abuse words you see at the log, cut the IP, delete empty lines and write to firewall.txt

Navigation menu