Linux check firewall, open ports

1. Check the firewall status

systemctl status firewalld

2. If the active status is not displayed, you need to open the firewall.

Insert image description here

systemctl start firewalld

3. View all open ports

#临时端口(默认为空)
firewall-cmd --list-ports
#永久开放端口(默认为空)
firewall-cmd --list-ports --permanent

4. Add firewall port

#添加临时开放端口
firewall-cmd --add-port=8080/tcp
#添加永久开放端口
firewall-cmd --add-port=8080/tcp --permanent

5. Close the firewall port

#关闭临时端口
firewall-cmd --remove-port=8080/tcp
#关闭永久端口
firewall-cmd --remove-port=8080/tcp --permanent

6. Reload the firewall and restart the firewall

The configuration will not take effect after the configuration is completed. The policy needs to reload or restart the firewall to take effect.

#重载防火墙
firewall-cmd --reload
#重启防火墙
systemctl restart firewalld

Guess you like

Origin blog.csdn.net/weixin_46010834/article/details/131061552