Skip to content

Instantly share code, notes, and snippets.

@canbingzt
Created July 16, 2025 00:14
Show Gist options
  • Select an option

  • Save canbingzt/c081dffe72deded1663851826d9c5598 to your computer and use it in GitHub Desktop.

Select an option

Save canbingzt/c081dffe72deded1663851826d9c5598 to your computer and use it in GitHub Desktop.
修复docker容器内无法访问网络的问题
# 查看防火墙状态
firewall-cmd --state
# 查看防火墙是否开启ip地址转发(ip地址伪装)
firewall-cmd --query-masquerade
# 开启ip地址转发
firewall-cmd --add-masquerade --permanent
# 将网络接口 docker0 加入 trusted zone,解决 DNS 问题
firewall-cmd --permanent --zone=trusted --add-interface=docker0
# 更新防火墙规则
firewall-cmd --reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment