Changes

From SME Server
Jump to navigationJump to search
655 bytes added ,  14:06, 17 June 2015
Line 163: Line 163:  
to launch the script, do the following command:
 
to launch the script, do the following command:
 
  /root/checklist_ban
 
  /root/checklist_ban
 +
 +
 +
====Show IPs banned by service====
 +
 +
Here is another quick script that shows you the most recent IPs banned in the logs. Note that they may have been unbanned but there is no check for this:
 +
 +
nano /root/IP_list
 +
 +
#!/bin/sh
 +
# Set CLI vars to something we can read
 +
TYPE=$1
 +
LOG=$2
 +
# Set main grep string
 +
SEARCH="Ban ((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])"
 +
# Add the search term
 +
SEARCH="\[$TYPE]\ $SEARCH"
 +
# Now search the log
 +
grep -oE "\[$TYPE\] Ban ((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])" $LOG
 +
 +
Usage :
 +
IP_List [service] [log]
 +
 +
e.g.
 +
IP_List qpsmtpd /var/log/fail2ban/daemon.log
    
==== Unban an IP ====
 
==== Unban an IP ====

Navigation menu