centos 我不能在牧场主的豆荚里上网

mfuanj7w  于 2022-11-07  发布在  其他
关注(0)|答案(1)|浏览(115)

我运行牧场主在centos与主节点是同一台机器。我可以做的一切,但当我试图“apt-get update”内的吊舱,我得到:

Err:1 http://archive.ubuntu.com/ubuntu focal InRelease                   
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease         
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease           
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done        
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

问题出在Centos的防火墙里,因为当我关闭防火墙的时候,我可以在pod里面上网。我已经添加了link提供的端口。但是我仍然不能上网。有没有其他方法可以不关闭Centos的防火墙呢?
我用的是Centos 8和Rancher 2。

falq053o

falq053o1#

我能够解决这个问题。问题是Docker无法解析容器内的DNS查询。解决方法是,首先添加ports,然后执行以下命令:


# Check what interface docker is using, e.g. 'docker0'

ip link show

# Check available firewalld zones, e.g. 'public'

sudo firewall-cmd --get-active-zones

# Check what zone the docker interface it bound to, most likely 'no zone' yet

sudo firewall-cmd --get-zone-of-interface=docker0

# So add the 'docker0' interface to the 'public' zone. Changes will be visible only after firewalld reload

sudo nmcli connection modify docker0 connection.zone public

# Masquerading allows for docker ingress and egress (this is the juicy bit)

sudo firewall-cmd --zone=public --add-masquerade --permanent

# Reload firewalld

sudo firewall-cmd –reload

# Reload dockerd

sudo systemctl restart docker

相关问题