Show iptable blocks

#!/bin/bash
range="$1 $2"
cntonly="$3"

if  [[ $cntonly == "c" ]] ;
then #Count only
    res=$(grep -c "$range.*iptables denied" /var/log/debug*)
    echo "$res"
else #Get actual lines
    res=$(grep "$range.*iptables denied" /var/log/debug*)
    echo "$res"
fi

exit 1

Example usage:
./scriptname.sh Nov 11
Will show all dropped connections on November the 11th
or
./scriptname.sh Nov 11 c
Will show *amount* of dropped connections on November the 11th

Leave a Reply

Your email address will not be published. Required fields are marked *