1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #!/bin/bash
block_list_file="/etc/block_list.txt"
if [ ! -f $block_list_file ]; then touch $block_list_file fi
timestamp=`date +%s`
while read line; do ip=`echo $line | awk '{print $1}'` last_block_time=`echo $line | awk '{print $2}'`
if [ $((timestamp-last_block_time)) -gt 3600 ]; then /sbin/iptables -A INPUT -s $ip -j DROP sed -i "s/${ip}.*/${ip} ${timestamp}/g" $block_list_file fi done < $block_list_file
|