Shell monitors whether iptables is running

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.