原文 超链接…
原作者 伯牙绝音…
1、查看firewall服务状态
systemctl status firewalld
执行结果----
[root@localhost /]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since 四 2021-12-09 16:05:45 CST; 2min 16s ago
Docs: man:firewalld(1)
Main PID: 3053 (firewalld)
Tasks: 2
Memory: 28.4M
CGroup: /system.slice/firewalld.service
└─3053 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
12月 09 16:05:45 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
12月 09 16:05:45 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
12月 09 16:05:46 localhost.localdomain firewalld[3053]: WARNING: AllowZoneDrifting is enabled. This is considered an in... now.
12月 09 16:06:29 localhost.localdomain firewalld[3053]: WARNING: AllowZoneDrifting is enabled. This is considered an in... now.
Hint: Some lines were ellipsized, use -l to show in full.
2、查看firewall的状态
firewall-cmd --state
执行结果--
[root@localhost /]# firewall-cmd --state
running
3、开启、重启、关闭、firewalld.service服务
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
4、查看防火墙规则
firewall-cmd --list-all
执行结果--
[root@localhost /]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports: 3360/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
5、查询、开放、关闭端口
# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
操作端口后需要重启防火墙
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
# 参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;