rbl: sanity checks, fix IPv6 geoip lookup, extend duration to 4 days
This commit is contained in:
parent
553fe88d83
commit
5eae4ecb43
2 changed files with 10 additions and 5 deletions
|
|
@ -58,7 +58,7 @@ fi
|
|||
|
||||
# fail2ban
|
||||
for ip in ${iptables_banned[@]}; do
|
||||
if [[ $(grep -c $ip $rblfile) -lt 1 ]]; then
|
||||
if [[ $(grep -c "$ip" $rblfile) -lt 1 ]]; then
|
||||
# Add IP
|
||||
geoip=$(geoiplookup $ip | sed 's/GeoIP Country Edition: //' | awk {' if($1=="IP") print $0; else print $2,$3,$4,$5,$6,$7,$8'})
|
||||
printf "%s # $(date +%s) # Service login attempts/misconfiguration # %s\n" "$ip" "$geoip" >> $rblfile
|
||||
|
|
@ -67,9 +67,14 @@ done
|
|||
|
||||
# SPAM
|
||||
for ip in ${spamtrap[@]}; do
|
||||
if [[ $(grep -c $ip $rblfile) -lt 1 ]]; then
|
||||
if [[ $(grep -c "$ip" $rblfile) -lt 1 ]]; then
|
||||
# Add IP
|
||||
geoip=$(geoiplookup $ip | sed 's/GeoIP Country Edition: //' | awk {' if($1=="IP") print $0; else print $2,$3,$4,$5,$6,$7,$8'})
|
||||
# IPv4 or IPv6 switch
|
||||
if [ $(echo "$ip" | grep -c ':') -gt 0 ]; then
|
||||
geoip=$(geoiplookup6 $ip | sed 's/GeoIP Country V6 Edition: //' | awk {' if($1=="IP") print $0; else print $2,$3,$4,$5,$6,$7,$8'})
|
||||
else
|
||||
geoip=$(geoiplookup $ip | sed 's/GeoIP Country Edition: //' | awk {' if($1=="IP") print $0; else print $2,$3,$4,$5,$6,$7,$8'})
|
||||
fi
|
||||
printf "%s # $(date +%s) # SPAM mail to trap address # %s\n" "$ip" "$geoip" >> $rblfile
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue