虚拟机CentOS7防火墙的设置
查看防火墙的状态
[root@localhost ~]# firewall-cmd --state
running
关闭/打开防火墙状态
[root@localhost ~]# systemctl start firewalld.service -- 打开
[root@localhost ~]# systemctl stop firewalld.service -- 关闭
防火墙打开状态查看开发端口
[root@localhost ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports: -- 开发的端口
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
开发某端口号
以3306
端口为例
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports: 3306/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: