#!/bin/bash
function killfirewall(){
systemver=`cat /etc/*release* 2>/dev/null | awk 'NR==1{print}' |sed -r 's/.* ([0-9]+)\..*/\1/'`
if [[ $systemver = "6" ]];then
echo "当前是Centos6系统,禁用防火墙"
service iptables stop
chkconfig iptables off
elif [[ $systemver = "7" ]];then
echo "当前是Centos7系统,禁用防火墙"
systemctl disable firewalld
systemctl stop firewalld
else
echo "非Centos6、centos7、NeoKylin系统 无法关闭防火墙,安装失败!!!"
exit 1
fi
}
killfirewall
本文分享了一个用于CentOS 6和CentOS 7系统的一键关闭防火墙的bash脚本。脚本会自动检测系统版本,并执行相应的防火墙关闭命令。对于非CentOS 6或7的系统,脚本将提示错误并退出。
3654





