Vagrant / VirtualBox无法从VM中解析某些域


10

只是想出来的VirtualBox和流浪汉,我最初的lucid64VM解决不了us.archive.ubuntu.com,但可以解决security.ubuntu.comgoogle.comwww.apple.com(但不是apple.com瓦特/出www?!?!)。

VM运行所在的主机以及其他所有域都可以正常解析us.archive.ubuntu.com

不知道发生了什么?!?

vagrant@lucid64:~$ sudo apt-get install dkms -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  fakeroot make patch
Suggested packages:
  make-doc diffutils-doc
The following NEW packages will be installed:
  dkms fakeroot make patch
0 upgraded, 4 newly installed, 0 to remove and 23 not upgraded.
Need to get 458kB of archives.
After this operation, 2,359kB of additional disk space will be used.
Err http://us.archive.ubuntu.com/ubuntu/ lucid/main make 3.81-7ubuntu1
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com/ubuntu/ lucid/main patch 2.6-2ubuntu1
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main dkms 2.1.1.2-2ubuntu1
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com/ubuntu/ lucid/main fakeroot 1.14.4-1ubuntu1
  Could not resolve 'us.archive.ubuntu.com'
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/m/make-dfsg/make_3.81-7ubuntu1_amd64.deb  Could not resolve 'us.archive.ubuntu.com'
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/patch/patch_2.6-2ubuntu1_amd64.deb  Could not resolve 'us.archive.ubuntu.com'
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/d/dkms/dkms_2.1.1.2-2ubuntu1_all.deb  Could not resolve 'us.archive.ubuntu.com'
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/f/fakeroot/fakeroot_1.14.4-1ubuntu1_amd64.deb  Could not resolve 'us.archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

香草安装。我的第一次尝试。按照《部署Rails》一书中的说明进行操作。

编辑:添加/etc/resolv.conf

vagrant@lucid64:~$ cat /etc/resolv.conf 
nameserver 10.0.2.3
domain mydomain.com
search mydomain.com

还有一些挖掘信息:

vagrant@lucid64:~$ dig us.archive.ubuntu.com
;; Truncated, retrying in TCP mode.

; <<>> DiG 9.7.0-P1 <<>> us.archive.ubuntu.com
;; global options: +cmd
;; connection timed out; no servers could be reached

但是+trace使用该标志时似乎可以解析域名?!?(或者我读错了吗?)

vagrant@lucid64:~$ dig us.archive.ubuntu.com +trace

; <<>> DiG 9.7.0-P1 <<>> us.archive.ubuntu.com +trace
;; global options: +cmd
.           199183  IN  NS  d.root-servers.net.
.           199183  IN  NS  k.root-servers.net.
.           199183  IN  NS  m.root-servers.net.
.           199183  IN  NS  a.root-servers.net.
.           199183  IN  NS  j.root-servers.net.
.           199183  IN  NS  e.root-servers.net.
.           199183  IN  NS  l.root-servers.net.
.           199183  IN  NS  b.root-servers.net.
.           199183  IN  NS  f.root-servers.net.
.           199183  IN  NS  g.root-servers.net.
.           199183  IN  NS  h.root-servers.net.
.           199183  IN  NS  i.root-servers.net.
.           199183  IN  NS  c.root-servers.net.
;; Received 256 bytes from 10.0.2.3#53(10.0.2.3) in 1 ms

com.            172800  IN  NS  a.gtld-servers.net.
com.            172800  IN  NS  b.gtld-servers.net.
com.            172800  IN  NS  c.gtld-servers.net.
com.            172800  IN  NS  d.gtld-servers.net.
com.            172800  IN  NS  e.gtld-servers.net.
com.            172800  IN  NS  f.gtld-servers.net.
com.            172800  IN  NS  g.gtld-servers.net.
com.            172800  IN  NS  h.gtld-servers.net.
com.            172800  IN  NS  i.gtld-servers.net.
com.            172800  IN  NS  j.gtld-servers.net.
com.            172800  IN  NS  k.gtld-servers.net.
com.            172800  IN  NS  l.gtld-servers.net.
com.            172800  IN  NS  m.gtld-servers.net.
;; Received 499 bytes from 193.0.14.129#53(k.root-servers.net) in 191 ms

ubuntu.com.     172800  IN  NS  ns1.canonical.com.
ubuntu.com.     172800  IN  NS  ns2.canonical.com.
ubuntu.com.     172800  IN  NS  ns3.canonical.com.
;; Received 151 bytes from 192.42.93.30#53(g.gtld-servers.net) in 46 ms

us.archive.ubuntu.com.  600 IN  A   91.189.92.192
us.archive.ubuntu.com.  600 IN  A   91.189.92.193
us.archive.ubuntu.com.  600 IN  A   91.189.91.13
us.archive.ubuntu.com.  600 IN  A   91.189.91.23
us.archive.ubuntu.com.  600 IN  A   91.189.91.24
us.archive.ubuntu.com.  600 IN  A   91.189.91.25
us.archive.ubuntu.com.  600 IN  A   91.189.92.151
us.archive.ubuntu.com.  600 IN  A   91.189.92.152
us.archive.ubuntu.com.  600 IN  A   91.189.92.153
us.archive.ubuntu.com.  600 IN  A   91.189.92.154
us.archive.ubuntu.com.  600 IN  A   91.189.92.155
us.archive.ubuntu.com.  600 IN  A   91.189.92.176
us.archive.ubuntu.com.  600 IN  A   91.189.92.177
us.archive.ubuntu.com.  600 IN  A   91.189.92.179
us.archive.ubuntu.com.  600 IN  A   91.189.92.180
us.archive.ubuntu.com.  600 IN  A   91.189.92.181
us.archive.ubuntu.com.  600 IN  A   91.189.92.182
us.archive.ubuntu.com.  600 IN  A   91.189.92.183
us.archive.ubuntu.com.  600 IN  A   91.189.92.184
ubuntu.com.     172800  IN  NS  ns2.canonical.com.
ubuntu.com.     172800  IN  NS  ns3.canonical.com.
ubuntu.com.     172800  IN  NS  ns1.canonical.com.
;; Received 455 bytes from 91.189.95.3#53(ns2.canonical.com) in 183 ms

Edit2-更多挖掘:

vagrant@lucid64:~$ dig @10.0.2.3 security.ubuntu.com +short
91.189.92.181
91.189.92.184
91.189.92.151
91.189.92.166
vagrant@lucid64:~$ dig @10.0.2.3 us.archive.ubuntu.com
;; Truncated, retrying in TCP mode.

; <<>> DiG 9.7.0-P1 <<>> @10.0.2.3 us.archive.ubuntu.com
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached

VM上的网络配置是什么样的?您正在使用什么DNS服务器?您与他们之间有可靠的连接吗?
Shane Madden

嗯,我什至不知道该怎么讲。我是Ubuntu和Vagrant的新手。我将添加/etc/resolv.conf信息(上方)。莱姆知道您
要不

Answers:


13

我通过在Vagrantfile中添加以下行来解决该问题:

config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

以下是全部内容:

$setup = <<SCRIPT
    DEBIAN_FRONTEND=noninteractive apt-get update
SCRIPT

$dependencies = <<SCRIPT
    DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql libpq-dev
    DEBIAN_FRONTEND=noninteractive apt-get install -y python-dev libjpeg-dev zlib1g-dev
    DEBIAN_FRONTEND=noninteractive apt-get install -y python-virtualenv virtualenvwrapper
SCRIPT

Vagrant.configure('2') do |config|

    config.vm.box = 'ubuntu/trusty64'

    # config.ssh.forward_agent = true
    config.vm.network "private_network", ip: "192.168.10.90"

    config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
    config.vm.synced_folder ".", "/siaq"

    config.vm.provider :virtualbox do |vb|
        vb.name = "siaq"
        vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        vb.customize ["modifyvm", :id, "--memory", "512"]
    end

    config.vm.provision "shell", inline: $setup
    config.vm.provision "shell", inline: $dependencies
end

0

看起来是因为您根本无法联系设置的DNS服务器,并且它正在尝试使用根目录提示(以我的经验,这对于最终用户而言非常不可靠)。你能ping通吗?您是否设置为桥接模式,而没有防火墙阻碍?


不,我无法ping通10.0.2.3主机。看来VirtualBox(或Vagrant)已将VM的IP分配为10.0.2.2。主持人在10.0.1.201。VB / Vagrant将名称服务器设置为10.0.2.3可“工作” 的名称服务器,并解析某些域(请参见上面的edit2),但对于Ubuntu盒而言并不是最重要的。
Meltemi 2012年

0

当我将Mac OS主机从Lion(10.7.4)升级到Mountain Lion(10.8)时,这似乎已经“神奇地”解决了,因此不会再浪费时间了。


我有同样的问题,似乎只有在第一次运行时才会发生,就像DNS未准备好一样,而当我第二次“无用配置”时,主机就会解析。
Benja 2013年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.