新睿云

> 知识库 > Centos 7 关闭防火墙 两种方式搞定CentOS防火墙设置

Centos 7 关闭防火墙 两种方式搞定CentOS防火墙设置

作者/来源:新睿云 发布时间:2019-11-11

CentOS防火墙设置

CentOS 7.0默认使用的是firewall作为防火墙


1、直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动


2、设置 iptables service

yum -y install iptables-services

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

vi /etc/sysconfig/iptables 

增加规则

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

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。

相关推荐文章《免费建论坛可行吗?建网站论坛等需要注意6个部分


Centos 7 关闭防火墙


使用firewalld打开关闭防火墙与端口

1、firewalld的基本使用

启动:systemctl start firewalld

关闭:systemctl stop firewalld

查看状态:systemctl status firewalld

开机禁用  :systemctl disable firewalld

开机启用  :systemctl enable firewalld


2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed


3.配置firewalld-cmd

查看版本:firewall-cmd --version

查看帮助:firewall-cmd --help

显示状态:firewall-cmd --state

查看所有打开的端口:firewall-cmd --zone=public --list-ports

更新防火墙规则:firewall-cmd --reload

查看区域信息:  firewall-cmd --get-active-zones

查看指定接口所属区域:firewall-cmd --get-zone-of-interface=eth0

拒绝所有包:firewall-cmd --panic-on

取消拒绝状态:firewall-cmd --panic-off

查看是否拒绝:firewall-cmd --query-panic

热门标签
new year
在线咨询
咨询热线 400-1515-720
投诉与建议
{{item.description}}

—您的烦恼我们已经收到—

我们会将处理结果发送至您的手机

请耐心等待