开启、关闭防火墙或者开放端口

本地开发可以这样操作,生产环境应避免关闭防火墙
1
2
3
4
5
6
systemctl status firewalld #查看防火墙状态
systemctl start firewalld #开启防火墙
sudo systemctl disable firewalld # 关闭防火墙自启
service firewalld start #开启防火墙
systemctl stop firewalld #关闭防火墙
systemctl stop firewalld #关闭防火墙
若遇到无法开启
1
2
systemctl unmask firewalld.service #1
systemctl start firewalld.service #2
开放端口
1
2
3
4
5
6
#查询端口号80是否开启:
firewall-cmd --query-port=80/tcp
#重启防火墙:
firewall-cmd --reload
#查询有哪些端口是开启的:
firewall-cmd --list-port
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×