启动firewalld
[root@localhost]# service firewalld start
关闭firewalld
[root@localhost]# service firewalld stop
重启firewalld
[root@localhost]# service firewalld restart
永久关闭防火墙
[root@localhost]# chkconfig iptables off
永久关闭后重启
[root@localhost]# chkconfig iptables on
检查防火墙状态
[root@localhost]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
查看防火墙运行状态
[root@localhost]# firewall-cmd --state
running
查看防火墙规则
[root@localhost]# firewall-cmd --list-all
如果发现没有80端口号,这里需要添加一下80端口,网站才能正常访问
[root@localhost]# firewall-cmd --permanent --zone=public --add-port=80/tcp --permanent
查看端口,执行命令,提示yes,即查询成功
[root@localhost]# firewall-cmd --permanent --query-port=80/tcp
添加完端口之后一定要reload一下,重新加载防火墙配置
[root@localhost]# firewall-cmd --reload
然后再查看防火墙规则就有80端口号了
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: ssh dhcpv6-client
ports: 80/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
上面操作完成后,就可以正常访问网站了