[Discuss] VirtualBox and Vagrant: DNS won't work on guest

Greg Rundlett (freephile) greg at freephile.com
Fri Dec 19 14:12:15 EST 2014


I am working on a MediaWiki project.  I use Mediawiki-Vagrant to setup a
development environment.  I had everything working perfectly on a Windows
8.1 host, but decided that I needed to run on my Linux box for the fact
that it's my main machine, has dual 27" monitors and is ergonomically setup
in my office (besides the fact that I detest Windows).  I know I could have
worked on the Windows machine across the LAN, but it just seemed like a
hassle when ultimately I'd be deploying onto *nix anyway.  (Aside: The
Windows setup is not working because there is a version mismatch between
the guest additions which seems to make the guest additions fail
completely, and creates a chicken/egg problem because the apt-cache is
setup to use the shared folders of the host.  So, the guest can't update
it's guest additions.  But that doesn't matter because I really just want
to get the setup working on my Linux host.)

I've got the latest versions of Virtual Box (4.3.20 r96996), and vagrant
(1.7.1) running on Ubuntu Linux 14.04

uname -a
greg-laptop 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:44 UTC 2014
i686 i686 i686 GNU/Linux

lsb_release -a
LSB Version:
 core-2.0-ia32:core-2.0-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:core-4.0-ia32:core-4.0-noarch:core-4.1-ia32:core-4.1-noarch:cxx-3.0-ia32:cxx-3.0-noarch:cxx-3.1-ia32:cxx-3.1-noarch:cxx-3.2-ia32:cxx-3.2-noarch:cxx-4.0-ia32:cxx-4.0-noarch:cxx-4.1-ia32:cxx-4.1-noarch:desktop-3.1-ia32:desktop-3.1-noarch:desktop-3.2-ia32:desktop-3.2-noarch:desktop-4.0-ia32:desktop-4.0-noarch:desktop-4.1-ia32:desktop-4.1-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:graphics-3.1-ia32:graphics-3.1-noarch:graphics-3.2-ia32:graphics-3.2-noarch:graphics-4.0-ia32:graphics-4.0-noarch:graphics-4.1-ia32:graphics-4.1-noarch:languages-3.2-ia32:languages-3.2-noarch:languages-4.0-ia32:languages-4.0-noarch:languages-4.1-ia32:languages-4.1-noarch:multimedia-3.2-ia32:multimedia-3.2-noarch:multimedia-4.0-ia32:multimedia-4.0-noarch:multimedia-4.1-ia32:multimedia-4.1-noarch:printing-3.2-ia32:printing-3.2-noarch:printing-4.0-ia32:printing-4.0-noarch:printing-4.1-ia32:printing-4.1-noarch:qt4-3.1-ia32:qt4-3.1-noarch:security-4.0-ia32:security-4.0-noarch:security-4.1-ia32:security-4.1-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

I cloned Mediawiki-Vagrant <http://www.mediawiki.org/wiki/MediaWiki-Vagrant>
 (5cd35415dd2c2e1d0ab19ebca47d23340878e435)

At the bottom of this message is a transcript of what happened when I ran
vagrant up for the first time on my linux host (greg-laptop).

After first giving an error about SSH, I issued a vagrant reload and it
appeared to get the correct guest additions installed and the virtual
machine is up and running.  However, there is no mediawiki directory, and
thus no website.  So, I think I need to provision it.

(I was able to vagrant ssh to the machine, and it was running in VB)

I ran vagrant provision

That errored trying to get composer.org

several attempts were made at vagrant reload --provision

Trying to modify composer.pp didn't work, but simply ssh'ing into the guest
and executing the download of composer worked.

The next problem was
Error: Execution of '/usr/bin/apt-get -q -y -o
DPkg::Options::=--force-confold install build-essential' returned 100:
Reading package lists...

Which again seems to be a DNS issue:

==> default: Need to get 9000 kB of archives.
==> default: After this operation, 32.9 MB of additional disk space will be
used.
==> default: Err http://archive.ubuntu.com/ubuntu/ trusty/main
libstdc++-4.8-dev amd64 4.8.2-19ubuntu1
==> default:   Could not resolve 'archive.ubuntu.com'

I used vagrant ssh to get onto the guest, and sudo /usr/bin/apt-get -q -y
-o DPkg::Options::=--force-confold install build-essential worked flawlessly

However, it quickly failed on the next DNS resolution issue when updating
or installing packages.  It seemed that DNS was either not fast enough, or
not reliable enough.

DNS is handled by my router, which has been set to use Comcast DNS servers.

Looking at Google's Public DNS guide, I ended up changing the networking
settings on my router from *DHCP*
to* DHCP, addresses only*
plus I also changed the servers from Comcast to Google (8.8.8.8 8.8.4.4)
and then retried the vagrant provision.  But it's still failing on DNS.

Even when I log in to the guest (vagrant ssh), I am unable to issue
commands directly because they timeout.

e.g. vagrant at mediawiki-vagrant:~$ sudo apt-get update
Err http://apt.wikimedia.org trusty-wikimedia InRelease


Err http://apt.wikimedia.org trusty-wikimedia Release.gpg

  Could not resolve 'apt.wikimedia.org'
Err http://security.ubuntu.com trusty-security InRelease

Err http://security.ubuntu.com trusty-security Release.gpg
  Could not resolve 'security.ubuntu.com'

I thought maybe I had missed a step and so did a
    git submodule update --init --recursive
from the vagrant directory on the host, but that didn't change a thing.

I've looked at the puppet configs, and the supposed "fixes" for networking
are directly in the Vagrantfile

    config.vm.provider :virtualbox do |vb|
        # See http://www.virtualbox.org/manual/ch08.html for additional
options.
        vb.customize ['modifyvm', :id, '--memory', settings[:vagrant_ram]]
        vb.customize ['modifyvm', :id, '--cpus', settings[:vagrant_cores]]
        vb.customize ['modifyvm', :id, '--ostype', 'Ubuntu_64']
        vb.customize ['modifyvm', :id, '--ioapic', 'on']  # Bug 51473

        # Speed up dns resolution in some cases
        vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
        vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']

So it finally dawned on me to look at the actual network interfaces.  It
seems strange to me that the host is at 10.0.3.1, while eth0 on the guest
is  10.0.2.15

But, I can ping host from guest

vagrant at mediawiki-vagrant:~$ ping 10.0.3.1
PING 10.0.3.1 (10.0.3.1) 56(84) bytes of data.
64 bytes from 10.0.3.1: icmp_seq=1 ttl=63 time=0.131 ms
64 bytes from 10.0.3.1: icmp_seq=2 ttl=63 time=0.990 ms
64 bytes from 10.0.3.1: icmp_seq=3 ttl=63 time=0.000 ms
64 bytes from 10.0.3.1: icmp_seq=4 ttl=63 time=1.18 ms
64 bytes from 10.0.3.1: icmp_seq=5 ttl=63 time=1.25 ms
64 bytes from 10.0.3.1: icmp_seq=6 ttl=63 time=0.752 ms
64 bytes from 10.0.3.1: icmp_seq=7 ttl=63 time=0.984 ms
64 bytes from 10.0.3.1: icmp_seq=8 ttl=63 time=1.39 ms
64 bytes from 10.0.3.1: icmp_seq=9 ttl=63 time=0.919 ms
64 bytes from 10.0.3.1: icmp_seq=10 ttl=63 time=3.86 ms
64 bytes from 10.0.3.1: icmp_seq=11 ttl=63 time=1.94 ms
64 bytes from 10.0.3.1: icmp_seq=12 ttl=63 time=0.584 ms
64 bytes from 10.0.3.1: icmp_seq=13 ttl=63 time=1.46 ms
64 bytes from 10.0.3.1: icmp_seq=14 ttl=63 time=0.405 ms
64 bytes from 10.0.3.1: icmp_seq=15 ttl=63 time=2.61 ms
^C
--- 10.0.3.1 ping statistics ---
15 packets transmitted, 15 received, 0% packet loss, time 14048ms
rtt min/avg/max/mdev = 0.000/1.232/3.863/0.956 ms

nslookup from the host shows that it's using Google's nameservers

greg at greg-laptop:~/vagrant$ nslookup slashdot.org
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   slashdot.org
Address: 216.34.181.45


*When I do nslookup from the guest, it's using 10.0.2.3 -- I don't even
know who that is! and it takes entirely too long.*

vagrant at mediawiki-vagrant:~$ time nslookup slashdot.org
Server:         10.0.2.3
Address:        10.0.2.3#53

Name:   slashdot.org
Address: 216.34.181.45


real    0m5.109s
user    0m0.032s
sys     0m0.050s


$$$$$$$$$$$ Host network settings $$$$$$$$$$$$$$$$$$$$$
greg at greg-laptop:~/vagrant$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1f:16:25:48:30
          inet addr:192.168.1.8  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:16ff:fe25:4830/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:58086 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37025 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:53444168 (53.4 MB)  TX bytes:11824810 (11.8 MB)
          Interrupt:20 Memory:fc200000-fc220000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:4642 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4642 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:930009 (930.0 KB)  TX bytes:930009 (930.0 KB)





lxcbr0    Link encap:Ethernet  HWaddr f6:7f:db:21:0e:5f

          inet addr:10.0.3.1  Bcast:10.0.3.255  Mask:255.255.255.0

          inet6 addr: fe80::f47f:dbff:fe21:e5f/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1461 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:171354 (171.3 KB)






vboxnet0  Link encap:Ethernet  HWaddr 0a:00:27:00:00:00

          inet addr:10.11.12.1  Bcast:10.11.12.255  Mask:255.255.255.0

          inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1393 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:164027 (164.0 KB)

%%%%%%%% Guest network settings %%%%%%%%%%%%
vagrant at mediawiki-vagrant:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:22:6c:74
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe22:6c74/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2786 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2606 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:268312 (268.3 KB)  TX bytes:647185 (647.1 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:74:1f:4e
          inet addr:10.11.12.13  Bcast:10.11.12.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:965 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1225 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:148839 (148.8 KB)  TX bytes:586744 (586.7 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:124 errors:0 dropped:0 overruns:0 frame:0
          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:20652 (20.6 KB)  TX bytes:20652 (20.6 KB)


####################### Original "vagrant up" #######################
greg at greg-laptop:~/vagrant$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'trusty-cloud' could not be found. Attempting to find and
install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Adding box 'trusty-cloud' (v0) for provider: virtualbox
    default: Downloading:
https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
==> default: Successfully added box 'trusty-cloud' (v0) for 'virtualbox'!
==> default: Importing base box 'trusty-cloud'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrant_default_1418918147177_40503
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 => 8080 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically
replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if its present...
    default: Key inserted! Disconnecting and reconnecting using new SSH
key...
==> default: Machine booted and ready!
GuestAdditions versions on your host (4.3.20) and guest (4.3.10) do not
match.
stdin: is not a tty
 * Stopping VirtualBox Additions
   ...done.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer
required:
  dkms fakeroot gcc gcc-4.8 libasan0 libatomic1 libc-dev-bin libc6-dev
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfakeroot libfontenc1
  libgcc-4.8-dev libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgomp1
  libice6 libitm1 libllvm3.4 libpciaccess0 libpixman-1-0 libquadmath0 libsm6
  libtsan0 libtxc-dxtn-s2tc0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-sync1 libxcomposite1 libxdamage1
  libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1
  libxshmfence1 libxt6 libxxf86vm1 linux-libc-dev manpages-dev x11-common
  x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common
  xserver-xorg-core
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  virtualbox-guest-dkms* virtualbox-guest-utils* virtualbox-guest-x11*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 12.1 MB disk space will be freed.
(Reading database ... 60964 files and directories currently installed.)
Removing virtualbox-guest-dkms (4.3.10-dfsg-1) ...

-------- Uninstall Beginning --------
Module:  virtualbox-guest
Version: 4.3.10
Kernel:  3.13.0-43-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxguest.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-43-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxsf.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-43-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxvideo.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.13.0-43-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.

------------------------------
Deleting module version: 4.3.10
completely from the DKMS tree.
------------------------------
Done.
Removing virtualbox-guest-x11 (4.3.10-dfsg-1) ...
Purging configuration files for virtualbox-guest-x11 (4.3.10-dfsg-1) ...
Removing virtualbox-guest-utils (4.3.10-dfsg-1) ...
Purging configuration files for virtualbox-guest-utils (4.3.10-dfsg-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.4) ...
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
dkms set to manually installed.
linux-headers-3.13.0-43-generic is already the newest version.
linux-headers-3.13.0-43-generic set to manually installed.
The following packages were automatically installed and are no longer
required:
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgl1-mesa-dri
  libgl1-mesa-glx libglapi-mesa libice6 libllvm3.4 libpciaccess0
libpixman-1-0
  libsm6 libtxc-dxtn-s2tc0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-sync1 libxcomposite1 libxdamage1
  libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1
  libxshmfence1 libxt6 libxxf86vm1 x11-common x11-xkb-utils xfonts-base
  xfonts-encodings xfonts-utils xserver-common xserver-xorg-core
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box
/tmp/VBoxGuestAdditions.iso
stdin: is not a tty
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected,
mounting read-only
Installing Virtualbox Guest Additions 4.3.20 - guest version is 4.3.10
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.20 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 4.3.20.
Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation
failed.


stdin: is not a tty
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will
be required...
nfsd running
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check'
specified for export "192.168.1.0/255.255.255.0:/home/greg/Music".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
    default: /tmp/vagrant-puppet-9/manifests =>
/home/greg/vagrant/puppet/manifests
    default: /tmp/vagrant-puppet-9/modules-0 =>
/home/greg/vagrant/puppet/modules
==> default: Running provisioner: lsb_check...
==> default: Running provisioner: puppet...
Vagrant timed out while attempting to connect via SSH. This usually
means that the VM booted, but there are issues with the SSH configuration
or network connectivity issues. Please try to `vagrant reload` or
`vagrant up` again.
greg at greg-laptop:~/vagrant$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 => 8080 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions 4.3.20 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will
be required...
nfsd running
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check'
specified for export "192.168.1.0/255.255.255.0:/home/greg/Music".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
    default: /tmp/vagrant-puppet-5/manifests =>
/home/greg/vagrant/puppet/manifests
    default: /tmp/vagrant-puppet-5/modules-0 =>
/home/greg/vagrant/puppet/modules
==> default: Machine already provisioned. Run `vagrant provision` or use
the `--provision`
==> default: to force provisioning. Provisioners marked to run always will
still run.


Greg Rundlett
http://eQuality-Tech.com
http://freephile.org



More information about the Discuss mailing list