firewalld添加端口

CentOS7默认的防火墙是firewalld
如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装

2|0firewalld防火墙启用与关闭

启动systemctl start firewalld
关闭systemctl stop firewalld
查看状态systemctl status firewalld
查看状态firewall-cmd --state
开机启用systemctl enable firewalld
开机禁用systemctl disable firewalld

3|0添加开放端口

     3|1查看开放了哪些端口

      firewall-cmd --zone=public --list-ports

    3|2添加端口

      firewall-cmd --add-port=443/tcp --permanent //永久添加443端口,协议为tcp firewall-cmd --reload //重新加载

4|0删除端口

      firewall-cmd --zone=public --remove-port=80/tcp --permanent //删除tcp下的80端口

参数介绍:
firewall-cmd:是Linux提供的操作firewall的一个工具(注意没有字母“d”);
--permanent:表示设置为持久;
--add-port:标识添加的端口
--remove-port:标识删除的端口

5|0配置文件

      firewalld的默认区域配置文件位置在/etc/firewalld/zones/下的.xml文件中,如下图:   

另外,firewall中有Zone的概念,可以将具体的端口制定到具体的zone配置文件中。
例如:添加8010端口

 

firewall-cmd --zone=public --permanent --add-port=8010/tcp // --zone=public:指定的zone为public;

6|0systemctl

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

猜你喜欢

转载自blog.csdn.net/Helios32/article/details/109674895