亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        Shell腳本實現(xiàn)監(jiān)控iptables規(guī)則是否被修改

        字號:


            最近看了一篇通過nagios實現(xiàn)MD5實時監(jiān)控iptables狀態(tài)的文章,就想是否可以用shell也做到監(jiān)控iptables規(guī)則改變,經(jīng)過實驗,就有了下面這個腳本.
            系統(tǒng):centos 5.x
            腳本內(nèi)容:
            cat check_iptables.sh
            代碼如下:
            #!/bin/bash
            if [ ! -f .count ];then
            iptables -L -n|md5sum|awk '{print $1}' > ~/.count
            exit 1
            else
            iptables -L -n|md5sum|awk '{print $1}' >~/1.txt
            difffile=`diff ~/.count ~/1.txt|wc -l`
            if [[ $difffile = 0 ]];then
            echo "file is ok!"
            sleep 1
            rm -f ~/1.txt
            else
            echo "file is no ok!"
            cat ~/1.txt >~/.count
            sleep 1
            rm -f ~/1.txt
            fi
            fi
            然后丟到crontab里.以每隔3分鐘檢測一次.
            代碼如下:
            chmod +x /root/check_iptables.sh
            */3 * * * * /bin/sh /root/check_iptables.sh
            當然你也可以加上郵件報警來通知iptables規(guī)則有改變.