转至:https://blog.csdn.net/weixin_40816738/article/details/105244851

① 脚本编写
创建脚本

vim closeFirewall.sh

添加脚本内容如下:

if egrep "7.[0-9]" /etc/redhat-release &>/dev/null;then

  systemctl stop firewalld

   systemctl disable firewalld

elif

  egrep "6.[0-9]" /etc/redhat-release &>/dev/null; then

   service iptables stop

   chkconfig iptables off

fi

保存退出:wq

 

② 运行脚本

chmod u+x closeFirewall.sh

./closeFirewall.sh

或者

bash closeFirewall.sh

 

③ 脚本内容简述

这是一个centos7和centos6 2个版本防火墙脚本
先去查看/etc/redhat-release文件中的系统版本内容,然后用正则表达式区配7.x还是6.x,然后使用管道命令过滤,最后,针对不同系统走不同分支

 

相关文章:

  • 2021-09-25
  • 2021-12-27
猜你喜欢
  • 2021-12-05
  • 2021-11-18
  • 2021-12-27
相关资源
相似解决方案