① Scripting
to create scripts
vim closeFirewall.sh
Add the script reads as follows:
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
Saving exit :wq
② run scripts
chmod u+x closeFirewall.sh
./closeFirewall.sh
或者
bash closeFirewall.sh
③ script Description of content
这是一个centos7和centos6 2个版本防火墙脚本
先去查看/etc/redhat-release文件中的系统版本内容,然后用正则表达式区配7.x还是6.x,然后使用管道命令过滤,最后,针对不同系统走不同分支