无法在 VirtualBox 中运行的 Fedora 中执行“yum update”

无法在 VirtualBox 中运行的 Fedora 中执行“yum update”

我刚刚在 VirtualBox 中全新安装了 Fedora 20 作为虚拟机。我将虚拟机设置为使用 NAT 作为 VirtualBox 网络配置的一部分。

一开始我可以 ping google.com,但无法使用 Firefox 浏览。当我尝试执行时,yum update出现了以下错误:

Loaded plugins: langpacks, refresh-packagekit
Error: Cannot retrieve metalink for repository: fedora/20/x86_64. Please verify its path and try again

然后我在网络设置中禁用了 IPv6,并在 Firefox 中禁用了此选项。结果我能够使用 Firefox 进行浏览,但执行时仍然不断收到错误yum update

当我这样做时,URLGRABBER_DEBUG=1 yum check-update我得到:

2013-12-20 11:33:35,612 attempt 1/10: https://mirrors.fedoraproject.org/metalink?repo=fedora-20&arch=x86_64
2013-12-20 11:33:35,612 opening local file "/var/cache/yum/x86_64/20/fedora/metalink.xml.tmp" with mode wb
* Adding handle: conn: 0x1c896d0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 9 (0x1c896d0) send_pipe: 1, recv_pipe: 0
* Could not resolve host: mirrors.fedoraproject.org
* Closing connection 9
2013-12-20 11:33:45,169 exception: [Errno 14] curl#6 - "Could not resolve host: mirrors.fedoraproject.org"
2013-12-20 11:33:45,169 retrycode (14) not in list [-1, 2, 4, 5, 6, 7], re-raising
Error: Cannot retrieve metalink for repository: fedora/20/x86_64. Please verify its path and try again

但当我这样做时,ping mirrors.fedoraproject.org我得到:

ping mirrors.fedoraproject.org
PING wildcard.fedoraproject.org (209.132.181.16) 56(84) bytes of data.
64 bytes from wildcard.fedoraproject.org (209.132.181.16): icmp_seq=1 ttl=63 time=104 ms
64 bytes from wildcard.fedoraproject.org (209.132.181.16): icmp_seq=2 ttl=63 time=115 ms
64 bytes from wildcard.fedoraproject.org (209.132.181.16): icmp_seq=3 ttl=63 time=135 ms

其结果nslookup mirrors.fedoraproject.org是:

Server:     192.168.0.1
Address:    192.168.0.1#53

Non-authoritative answer:
mirrors.fedoraproject.org   canonical name = wildcard.fedoraproject.org.
Name:   wildcard.fedoraproject.org
Address: 209.132.181.16
Name:   wildcard.fedoraproject.org
Address: 67.203.2.67
Name:   wildcard.fedoraproject.org
Address: 213.175.193.206
Name:   wildcard.fedoraproject.org
Address: 140.211.169.197
Name:   wildcard.fedoraproject.org
Address: 152.19.134.146
Name:   wildcard.fedoraproject.org
Address: 80.239.156.215
Name:   wildcard.fedoraproject.org
Address: 66.35.62.166
Name:   wildcard.fedoraproject.org
Address: 66.135.62.201
Name:   wildcard.fedoraproject.org
Address: 85.236.55.6

我尝试在 VirtualBox 中使用桥接适配器选项,但遇到了同样的错误。

我按照建议在 NAT 模式下启用 DNS 代理,但同样的问题仍然存在(我仍然可以在 Firefox 中浏览,但 yum 无法解析主机 mirrors.fedoraproject.org)。现在命令ifconfig显示以下内容:

p2p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::a00:27ff:fea4:a4c6  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a4:a4:c6  txqueuelen 1000  (Ethernet)
        RX packets 723  bytes 695639 (679.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 628  bytes 77437 (75.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  base 0xd020 

显示cat /etc/resolv.conf如下:

nameserver 10.0.2.3

最后,我尝试了“在 NAT 模式下使用主机的解析器作为 DNS 代理”,问题终于解决了。

答案1

我按照 Michael 的建议采取了以下两个步骤:

NAT 模式下启用 DNS 代理

在 NAT 模式下使用主机的解析器作为 DNS 代理

现在我已经能够yum成功浏览和使用。

相关内容