added RBL generate/expire scripts
This commit is contained in:
parent
8042d2cc25
commit
72eb89db56
2 changed files with 89 additions and 0 deletions
17
rbl_expire.sh
Executable file
17
rbl_expire.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Expire old RBL records
|
||||
|
||||
maxage=48 # in hours
|
||||
rblfile="/var/lib/rbldns/list"
|
||||
|
||||
egrep '^[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' $rblfile | while read -r ip delimiter timestamp foo; do
|
||||
if [ "$timestamp" -gt "0" ]; then
|
||||
expiration=$(echo "$(date +%s)-$timestamp" | bc)
|
||||
|
||||
if [ "$expiration" -gt "$(($maxage * 3600))" ]; then
|
||||
#echo "entry $ip older than $maxage hours (expired $(($expiration / 3600)) hours ago)"
|
||||
sed -i "/^$ip.*# $timestamp.*$/d" $rblfile || echo "Error while deleting $ip: $?"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue