Linux firewall related operation command firewalld-cmd


foreword

工作中docker部署生产项目时遇到前端项目无论如何都代理不到后端接口遇到以下问题

Nginx connect() failed (113: No route to host) while connecting to upstream

Finally, it was found out that the firewalld firewall was enabled on the production linux server and the ports used by the front and rear services were not enabled for the corresponding ports. If they were not added to the whitelist, the services could not access each other even if they were on the same network bridge.

最后记录一些开启防火墙常用命令,牢记!!!

1. View all open ports:

 firewall-cmd--zone=public --list-ports

Second, the command to add

firewall-cmd --zone=public --add-port=80/tcp --permanent   

添加多个端口
firewall-cmd --zone=public --add-port=8001~8004/tcp --permanent   

(--permanent will take effect permanently, and will fail after restarting without this parameter

3. View

查看指定端口
firewall-cmd --zone=public --query-port=80/tcp

查看当前开了哪些端口
firewall-cmd --list-services

查看还有哪些服务可以打开
firewall-cmd --get-services

查看所有打开的端口
firewall-cmd --zone=public --list-ports

更新防火墙规则
firewall-cmd --reload

4. Delete

firewall-cmd --zone=public --remove-port=80/tcp --permanent

Guess you like

Origin blog.csdn.net/wei1359765074410/article/details/125611179
Recommended