#!/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