防火墙设置
服务设置
查看防火墙状态
使用systemctl status firewalld命令
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-09-02 13:03:48 CST; 20min ago
Docs: man:firewalld(1)
Main PID: 1065 (firewalld)
Tasks: 2
Memory: 34.6M
CGroup: /system.slice/firewalld.service
└─1065 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid
9月 02 13:03:48 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
9月 02 13:03:48 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
开启防火墙服务
使用systemctl start firewalld命令
[root@localhost ~]# systemctl start firewalld
关闭防火墙服务
使用systemctl stop firewalld命令
[root@localhost ~]# systemctl stop firewalld
查看防火墙自启
使用systemctl is-enabled firewalld命令
[root@localhost ~]# systemctl is-enabled firewalld
enabled
开启防火墙自启
使用systemctl enable firewalld命令
[root@localhost ~]# systemctl enable firewalld
Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.
关闭防火墙自启
使用systemctl disable firewalld命令
[root@localhost ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
端口设置
查看开放端口
使用firewall-cmd --list-ports命令
[root@localhost ~]# firewall-cmd --list-ports
5236/tcp
添加端口开放
使用firewall-cmd --add-port命令
[root@localhost ~]# firewall-cmd --add-port=5236/tcp --permanent
success
重载端口设置
使用firewall-cmd --reload命令
[root@localhost ~]# firewall-cmd --reload
success

浙公网安备 33010602011771号