源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Shell监控iptables运行状态

  • 时间:2020-09-25 08:14 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Shell监控iptables运行状态
最近在调试服务器的iptables,自己做了个定时关iptables,但晚上回家很少开电脑,所以就没法去启动iptables,当然你可能会说,为什么不取消定时关闭iptables,我只能说个人的环境不一样,需求也就不一样. 脚本内容:
[u]复制代码[/u] 代码如下:
vi iptables-reset.sh #!/bin/bash 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
验证图: [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100122_0_86057.jpg[/img] 大家可以先在虚拟机里测试下,再放到服务器上执行,当然如果你服务器性能好,也可以改成死循环去检测的。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部