Shell monitors whether iptables is running
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:
Vi iptables-reset.sh
#! /Bin/bash # Powered by blog. slogra. comport = 'iptables-vL | grep ssh | awk' {split ($ NF, ,":"); print a [2]} '| wc-l' if [$ port = 1]; thenecho "OK! "Else/etc/init. d/iptables startsleep 2 port = 'iptables-vL | grep ssh | awk' {split ($ NF, ,":"); 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.