Re: [vagrant-up] Custom DNS Server for vagrant box?

10,821 views
Skip to first unread message

Adam Feuer

unread,
Apr 27, 2013, 11:20:51 PM4/27/13
to vagrant-up
Chad,

In the past, I've solved this by configuring Virtualbox to intercept DNS requests and use the host's DNS resolver:


Here's the command to run:
VBoxManage modifyvm "VM name" --natdnshostresolver1 on

-adam


On Sat, Apr 27, 2013 at 10:50 AM, Chad Cunningham <cha...@gmail.com> wrote:
I'm nearly there on getting my vagrant box set up, however I've run into an issue with DNS. I have configured my box with host only networking (as I need to access a SSL apache server and I prefer to be able to alias box.dev rather than using a port forward) and this is working great, except that my box needs to be able to access resources over a VPN. Now through host only networking, this works fine when my machine is connected to the VPN, however, DNS is not working. I fixed this by adding the VPN's DNS server to /etc/resolv.conf and adding the vpn search domain there as well. Perfect. Except, every time I reboot the vagrant box it rewrites the resolv.conf and undoes this.

I'm not quite sure how I'm supposed to handle this (and it may be an obscure situation) but is there anyway I can either specify an additional nameserver to go in the resolv.conf or alternately somehow configure the vagrant box to use the nameservers the host is using?

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Adam Feuer <ad...@pobox.com>

Chad Cunningham

unread,
Apr 29, 2013, 3:50:02 PM4/29/13
to vagra...@googlegroups.com
I ended up adding that to the Vagrantfile and that indeed does the trick, thanks!

Jamie Alessio

unread,
Apr 29, 2013, 4:33:12 PM4/29/13
to vagra...@googlegroups.com
Chad,
You could also just use a Vagrant Provisioner to make the necessary changes to /etc/resolv.conf on the guest OS. This would put the change in place after every "vagrant up" and "vagrant provision" command.  You have the full power of Chef/Puppet/Ansible, but for this tiny task you can probably just use the shell provider.

- Jamie

Eric Hanchrow

unread,
Sep 19, 2013, 6:02:38 PM9/19/13
to vagra...@googlegroups.com
Note that some operating systems -- Ubuntu 12.04 in particular -- will indeed overwrite /etc/resolv.conf.  The workaround on that system is to add your name server entries to /etc/networking/interfaces instead, like this:

auto eth0
iface eth0 inet static
        address          ...
        netmask          ...
        network          ...
        broadcast        ...
        gateway          ...
        dns-nameservers  10.0.10.10 8.8.8.8
Reply all
Reply to author
Forward
0 new messages