Recently, when I debug iptables on the server, I made a timer to disable iptables. However, when I go home at night, I seldom turn on my computer, so I cannot start iptables. of course, you may say, why don't I disable iptables when I cancel the task? I can only say that my personal environment is different and the requirements are different. script content: viiptables-reset.sh #! /Bin/bash # Poweredbyblog. slogra. comport recently debugged iptables on the server and made a timed shutdown iptables on its own. However, when I go home at night and seldom turn on my computer, I cannot start iptables. of course, you may say, why don't I disable iptables when I cancel the task? I can only say that my personal environment is different and the requirements are different.
Script content:
Vi iptables-reset.sh
#!/bin/bash#Powered by blog.slogra.comport=`iptables -vL|grep ssh|awk '{split($NF,a,":");print a[2]}'|wc -l`if [ $port = 1 ];thenecho "ok!"else/etc/init.d/iptables startsleep 2port=`iptables -vL|grep ssh|awk '{split($NF,a,":");print a[2]}'|wc -l`if [ $port = 1 ];thenecho "ok!"else/etc/init.d/iptables restartfifi
Verification diagram:
You can test it in a virtual machine and then execute it on the server. of course, if your server has good performance, you can change it to an endless loop to detect it.