centos7關(guān)閉防火墻命令 centos7永久防火墻關(guān)閉

2022-01-13 15:49

centos7關(guān)閉防火墻命令?centos7是一款免費(fèi)的開源系統(tǒng),在centos7時(shí)代防火墻已由iptable轉(zhuǎn)向firewalld,很多小伙伴們就不知道命令是什么了,也不知道如何關(guān)閉開啟防火墻,那么今天小編就為大家?guī)砹薱entos7關(guān)閉防火墻命令以及centos7永久防火墻關(guān)閉全部?jī)?nèi)容,一起來看看吧。

centos7關(guān)閉防火墻命令

1、有些人安裝的linux的系統(tǒng)默認(rèn)防火墻不是iptables,而是firewall,那就得使用以下方式關(guān)閉防火墻了。

>>>關(guān)閉防火墻

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall開機(jī)啟動(dòng)

>>>開啟端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含義

--zone #作用域

--add-port=80/tcp #添加端口,格式為:端口/通訊協(xié)議

--permanent #永久生效,沒有此參數(shù)重啟后失效

>>>重啟防火墻

firewall-cmd --reload

其他常用命令:

firewall-cmd --state ##查看防火墻狀態(tài),是否是running

firewall-cmd --reload ##重新載入配置,比如添加規(guī)則之后,需要執(zhí)行此命令

firewall-cmd --get-zones ##列出支持的zone

firewall-cmd --get-services ##列出支持的服務(wù),在列表中的服務(wù)是放行的

firewall-cmd --query-service ftp ##查看ftp服務(wù)是否支持,返回yes或者no

firewall-cmd --add-service=ftp ##臨時(shí)開放ftp服務(wù)

firewall-cmd --add-service=ftp --permanent ##永久開放ftp服務(wù)

firewall-cmd --remove-service=ftp --permanent ##永久移除ftp服務(wù)

firewall-cmd --add-port=80/tcp --permanent ##永久添加80端口

iptables -L -n ##查看規(guī)則,這個(gè)命令是和iptables的相同的

man firewall-cmd ##查看幫助

更多命令,使用 firewall-cmd --help 查看幫助文件

2、 CentOS 7.0默認(rèn)使用的是firewall作為防火墻,使用iptables必須重新設(shè)置一下

>>>直接關(guān)閉防火墻

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall開機(jī)啟動(dòng)

>>>設(shè)置 iptables service

yum -y install iptables-services

如果要修改防火墻配置,如增加防火墻端口3306

vi /etc/sysconfig/iptables

增加規(guī)則

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重啟防火墻使配置生效

systemctl enable iptables.service #設(shè)置防火墻開機(jī)啟動(dòng)

以上就是小編今天為大家?guī)淼腸entos7關(guān)閉防火墻命令以及centos7永久防火墻關(guān)閉全部?jī)?nèi)容,希望能夠幫助到大家。

網(wǎng)友評(píng)論

相關(guān)閱讀