1、查看所有已经开放的端口列表
firewall-cmd --permanent --list-ports
2、开启某个端口(例如:80)
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd | 用于配置和管理防火墙规则 |
--zone=public | 指定了端口添加到哪个区域, public 区域是预定义的一个区域,它表示任何连接到此计算机的设备都可能尝试访问该计算机的公共网络服务 |
--add-port=80/tcp | 表示添加对 80/TCP 端口的访问规则,80 是端口号 |
--permanent | 表示这条规则是持久的,在重启后仍然有效 |
3、关闭某个端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
4、重启防火墙
systemctl restart firewalld.service
5、关闭防火墙
systemctl stop firewalld
6、永久关闭防火墙
systemctl disable firewalld