Debian 10/9/8 DNS configuration bug

Bug #1850310 reported by Dmitry Shemin
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

I use cloud-init with NoCloud data source for configuring my VM's and got strange bug with DNS configuration on official Debian images like https://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-amd64.qcow2.

My network config:

```
version: 2
ethernets:
  eth0:
    set-name: eth0
    match:
      macaddress: <MAC address>
    addresses: [ <IP address> ]
    gateway4: <GATEWAY ADDRESS>
    nameservers:
      addresses: [8.8.8.8,8.8.4.4]
```

After creating new VM I got next configuration in /etc/network/interfaces.d/50-cloud-init.cfg which is seems ok:

```
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 10.52.240.11/16
    dns-nameservers 8.8.8.8 8.8.4.4
    gateway 10.52.1.1
```

But /etc/resolv.conf contains:

```
nameserver 127.0.0.1
```

Which leads to the fact that I can’t resolve any domain name, for example:
```
# ping google.com
ping: google.com: Temporary failure in name resolution
```

Revision history for this message
Dmitry Shemin (dshemin) wrote :
Dmitry Shemin (dshemin)
description: updated
Revision history for this message
Ryan Harper (raharper) wrote :

Thanks for filing the bug.

Cloud-init itself does not render /etc/resolv.conf on Ubuntu/Debian; In Ubuntu, the resolvconf package is installed which handles maintain /etc/resolv.conf.

Looking at:

https://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-amd64-packages.list

resolvconf package is not present, hence the bug. I would suggest that the images include this package.

That said, cloud-init could detect if resolvconf is not present and render resolv.conf directly.

Changed in cloud-init:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Adam Conrad (adconrad) wrote :

> In Ubuntu, the resolvconf package is installed which handles maintain /etc/resolv.conf.

This hasn't been true for years. That said, it's still handled "magically" today, just that now we do it with systemd-resolved.

Revision history for this message
Ryan Harper (raharper) wrote :

@Adam,

In the context of Ubuntu images which still use ifupdown by default (Xenial); they also include resolvconf which is what manages resolv.conf.

As you note, newer Ubuntu uses systemd-resolved as replacement for resolvconf; cloud-init on Ubuntu does not directly render contents into /etc/resolv.conf for these reasons.

Revision history for this message
Dmitry Shemin (dshemin) wrote :

The documentation says that the 'resolvconf' package is optional for Debian. https://wiki.debian.org/NetworkConfiguration#Defining_the_.28DNS.29_Nameservers
So temporarily I used 'systemd-resolved' for DNS configuration by adding this line to my user data:

```
runcmd:
 - |
   cat << EOL > /etc/systemd/resolved.conf
   [Resolve]
   DNS=8.8.8.8
   EOL
 - |
   cat << EOL > /etc/resolv.conf
   nameserver 127.0.0.53
   EOL
 - systemctl enable systemd-resolved
 - systemctl start systemd-resolved
```

But I think it's worth doing something about it.

Revision history for this message
Brian King (inflatador) wrote :

I'm affected as well. Running an Openstack cloud with the config-drive and static IP information. The DNS servers are in the network-data.json file, but cloud-init on Debian 10 does not set the DNS servers unless the resolvconf package is present.

Revision history for this message
TJ (zimmertr) wrote :

I'm affected as well. Got around this like so:

write_files:
  - path: /etc/resolvconf/resolv.conf.d/base
    content: nameserver 192.168.1.100
runcmd:
  - [ systemctl, restart, resolvconf ]

Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.