Skip to content

generic/debian boxes have fixed DNS servers when used in Vagrant with libvirt #282

Open
@ghost

Description

The Generic Debian boxes (all major releases 8 through 11) have fixed DNS resolvers instead of using DHCP to get the list of nameserver entries.

I'm using Vagrant 2.3.7 with the libvirt provider. The host machine is running Ubuntu 22.04 on amd64.

After vagrant up the file /etc/network/interfaces looks like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface

# The primary network interface
allow-hotplug eth0
auto lo
iface lo inet loopback
iface eth0 inet dhcp
dns-nameserver 4.2.2.1
dns-nameserver 4.2.2.2
dns-nameserver 208.67.220.220
pre-up sleep 2

and /etc/resolv.conf looks like this:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 4.2.2.1
nameserver 4.2.2.2
nameserver 208.67.220.220

This is the case for all generic/debian* boxes. The other boxes I'm currently using don't have this problem (generic/ubuntu20 and 22, and generic/centos7). With the other boxes the above IP addresses can still be found in the config files, but they seem to get overwritten before the bootstrap process.

Since external DNS servers are blocked in my place of work I can't use these boxes as-is at the moment. (Never mind the privacy implications of pushing third-party DNS resolvers on others.)

As a workaround I have put the following line into my bootstrap script. Replace the search domain and nameserver IP address as needed:

echo "search localdomain" > /etc/resolv.conf; echo "nameserver 192.168.1.1" >> /etc/resolv.conf

It would be nice if you could remove these fixed DNS server addresses.

That said, many thanks for providing all these boxes! They are very useful to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions