Changes

From SME Server
Jump to navigationJump to search
140 bytes added ,  00:07, 18 June 2015
m
Line 167: Line 167:  
====Show IPs banned by service====
 
====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:
+
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
+
nano -w /root/IP_list.sh
   −
#!/bin/sh
+
and copy and paste the below code into the file:
# Set CLI vars to something we can read
+
 
TYPE=$1
+
#!/bin/sh
LOG=$2
+
# Set CLI vars to something we can read
# Set main grep string
+
TYPE=$1
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])"
+
LOG=$2
# Add the search term
+
SEARCH="\[$TYPE]\ $SEARCH"
+
# Set main grep string
# Now search the log
+
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])"
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
+
 +
# 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
 +
 
 +
Save the file and make it executable:
 +
chmod 755 /root/IP_list.sh
    
Usage :  
 
Usage :  

Navigation menu