robox generic/ubuntu1604 can't find internal apt mirror due to hardcoded dns

27 views
Skip to first unread message

David Reagan

unread,
Aug 20, 2019, 3:40:10 PM8/20/19
to Vagrant
There is a known issue with the robox generic boxes where the hardcoded dns servers prevent internal dns from resolve. In my case, I have an Ubuntu mirror that I need to be able to talk to. (I'm testing Ansible configuration against vagrant vms.)

I was able to fix my Bionic vm with help from this comment: https://github.com/lavabit/robox/issues/11#issuecomment-443289393 I just write and apply the proper netplan config via a shell script provision.

I haven't been able to get my Xenial vm to work. 

xenial.vm.provision "shell", inline: "sed 's/4\.2\.2\.1/10\.16\.0\.25/' /etc/network/interfaces ; ifdown --exclude=lo -a && ifup --exclude=lo -a "

Causes the vm to stall when running `vagrant up xenial`. Likely because the ifdown command stops both network interfaces...

After manually editing /etc/network/interfaces, restarting networking services doesn't help. networking, systemd-resolvconf, etc. I thought the ifdown and ifup commands would work, but testing just now shows they don't.

So, how can I add an internal dns server to a generic/ubuntu1604 based vm during the initial `vagrant up` process?

As a side note, I'm not sure what it says that I've not had to restart networking on Xenial very much when I've been running a few of them in production for years.... Or that I haven't been able to find a solid answer on how to modify dns servers on Ubuntu 16.04 just in general... Hrm... 

Any help is appreciated.

Dennis Chang

unread,
Aug 20, 2019, 4:01:00 PM8/20/19
to Vagrant

David Reagan

unread,
Aug 20, 2019, 4:01:09 PM8/20/19
to Vagrant
Ok, after more testing, I'm a little closer.

If I edit /etc/network/interfaces to combine all dns-nameserver lines into one line.

dns-nameservers <ip1> <ip2> etc.

Then run `systemctl restart networking.service`, the ssh session breaks, and `vagrant ssh xenial` shows the `The provider for ... is not ready ...` message.

If I log into the vm via virt-manager, and run `ifup eth0`, I can vagrant ssh into it again, and my new dns settings will be applied.

So, how can I automate all of that? Provisioning will break as soon as I run the `systemctl restart networking.service` and eth0 goes down.

- David

David Reagan

unread,
Aug 20, 2019, 4:04:52 PM8/20/19
to Vagrant
The resolv.conf file says "DO NOT EDIT THIS FILE BY HAND".

Interestingly, it does list my internal dns server after I add it to interfaces and ifup/down eth0.

- David

On Tuesday, August 20, 2019 at 1:01:00 PM UTC-7, Dennis Chang wrote:

Dennis Chang

unread,
Aug 20, 2019, 4:08:31 PM8/20/19
to Vagrant
The link I sent (assuming resolvconf package is installed) references a directory, /etc/resolvconf/resolv.conf.d

does Xenial have this directory by  default? I'm not sure, that's why I thought maybe you could check.


David Reagan

unread,
Aug 20, 2019, 4:22:29 PM8/20/19
to Vagrant
Just tried editing things in /etc/resolvconf/resolv.conf.d and my changes were overwritten as soon as I tried restarting networking to apply any changes. One file changed from not having the "DO NOT EDIT" message, to having it after I added my custom nameserver to it.

I also tried /etc/resolvconf/resolv.conf.d/{original,tail} as some of that askubuntu topic answers mentioned. Both files did not get overwritten, but nslookup couldn't find the internal hostname.

I'm 90% certain that editing /etc/network/interfaces is the official method. That is how I'd update my old 14.04 vms before they EOL'd.

- David

Dennis Chang

unread,
Aug 23, 2019, 6:40:02 AM8/23/19
to Vagrant
Hi Dave,

Did you try, adding your dns server to /etc/resolvconf/resolv.conf.d/head

and run the command "sudo resolvconf -u"

as suggested in the link I sent?

Does it not add your dns server to /etc/resolv.conf?

Note: by following the instructions from the link, it appears you do not need to restart networking.
It's worth a shot.


David Reagan

unread,
Aug 26, 2019, 4:24:23 PM8/26/19
to Vagrant
I figured out how to make the /etc/network/interfaces method work. You manually edit /etc/network/interfaces, make sure there is only one dns-nameservers line with my internal dns ip in the list, then do a full reboot.

I think some of my issues with the /etc/resolvconf/resolv.conf.d/* files were that I forgot to add "nameserver" in front of the ip address...

Once I remembered that key bit of info, adding the ip to /etc/resolvconf/resolv.conf.d/head did start working after a `systemctl restart resolvconf.service`. (Thanks Dennis Chang for prompting me to try again.)

Oddly, using /etc/resolvconf/resolv.conf.d/tail, /etc/resolvconf/resolv.conf.d/base, and /etc/resolvconf/resolv.conf.d/original did not work. Even though they are listed as options in the man page. http://manpages.ubuntu.com/manpages/xenial/man8/resolvconf.8.html

Hopefully using the 'head' file will work well enough for my testing, even if it has that "do not edit" message in it. Wait, now that I think about it, is that comment just in /etc/resolvconf/resolv.conf.d/head so that it appears at the top of /etc/resolv.conf?

For reference, I added the following provision line to my vagrant vm config:


xenial.vm.provision "shell", inline: "echo 'nameserver <internal ip>' >> /etc/resolvconf/resolv.conf.d/head; systemctl restart resolvconf.service"



Thanks for the help!

- David

Dennis Chang

unread,
Aug 26, 2019, 4:51:36 PM8/26/19
to Vagrant
Happy to hear it's now working for you!
Reply all
Reply to author
Forward
0 new messages