centos7使用了firewall防火墙,且默认是开启状态(ubuntu系统默认关闭)
查看防火墙状态
systemctl status firewalld
如果显示中包含类似:Active: active (running) since Wed 2021-11-03 09:18:49 CST; 2 months 3 days ago
则说明防火墙开启,否则说明处于关闭状态
关闭防火墙
systemctl stop firewalld
打开防火墙
systemctl start firewalld
打开一个端口(例如8082),其中的 –permanent表示重启不失效
firewall-cmd --zone=public --add-port=8082/tcp --permanent
重启防火墙
systemctl restart firewalld.service
重新加载配置文件
firewall-cmd --reload
本篇完,还有疑问?留下评论吧