最新消息:阿里云双12优惠,史上最低折扣。

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

服务器租用 aliyun 179浏览

正则表达式语法是什么?

​正则表达式(Regular expression,简写为Regexes)是一种用来操作和检验字符串数据的强大工具。它相当与一串特殊的字符,用它可以转换成算法,对文本进行匹配等操作。

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个部分》

使用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

转载请注明:小猪云服务器租用推荐 » Centos 7 关闭防火墙 两种方式搞定CentOS防火墙设置