查看已开放的端口

firewall-cmd –list-ports

开放端口(开放后需要要重启防火墙才生效)

firewall-cmd –zone=public –add-port=3338/tcp –permanent

关闭端口(关闭后需要要重启防火墙才生效)

firewall-cmd –zone=public –remove-port=3338/tcp –permanent

重启防火墙

firewall-cmd –reload

开机启动防火墙

systemctl enable firewalld

开启防火墙

systemctl start firewalld

禁止防火墙开机启动

systemctl disable firewalld

停止防火墙

systemctl stop firewalld

Ubutun UFW 常用命令分享

开启防火墙:

sudo ufw enable

关闭防火墙:

sudo ufw disable

重启防火墙:

sudo ufw reload

查看防火墙状态:

sudo ufw status

放行TCP端口:

sudo ufw allow 80/tcp

放行UDP端口:

sudo ufw allow 5000/udp

关闭端口:
sudo ufw delete allow 80/tcp

开放端口:sudo ufw allow 端口号

开放范围端口:sudo ufw allow 40000:50000/tcp & sudo ufw allow 40000:50000/udp