iptables is running shell monitor

Recently in debug server of iptables, himself a timer to turn off iptables, but go home at night rarely drives the computer, so I can’t go to start iptables, of course, you might say, why not cancel a scheduled off iptables, I can only say that a person’s environment are not the same, demand will be different.

Script:
vi iptables-reset.sh

#!/bin/bash
#Powered by blog.slogra.com
port=’iptables -vL|grep ssh|awk ‘{split($NF,a,”:”);print a[2]}’|wc -l’
if [ $port = 1 ];then
echo “ok!”
else
/etc/init.d/iptables start
sleep 2
port=’iptables -vL|grep ssh|awk ‘{split($NF,a,”:”);print a[2]}’|wc -l’
if [ $port = 1 ];then
echo “ok!”
else
/etc/init.d/iptables restart
fi
fi

Validation:

Click to view original image
We can first testing in the virtual machine, and then executed on the server, of course, if your server performance is good, it can go into an infinite loop detection.

Leave a Reply

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