Setup etc/resolv.conf from Distrobuilder

I’m creating Debian based VM image via Distrobuilder, based on lxc-ci example.

At the end, /etc/resolv.conf doesn’t exist at all and no domain is pingable.
Manually adding the file later within the VM fixes the issue.

ping works, ping not.

How to add the file during building via the yaml file?

In our YAML, we use systemd-resolved for DNS resolution, so /etc/resolv.conf becomes a symlink to a path in /run/systemd which is created at boot by systemd-resolved.

If you’re not using systemd-networkd and systemd-resolved in your image, then you’ll need a different solution, such as ifupdown + resolvconf or some other alternatives.

1 Like

I have following action within the yaml:

  name: debian-slim
  distribution: debian
  release: bullseye
  description: |-
    Debian {{ image.release }}
  architecture: x86_64


  - trigger: post-packages
    action: |-
      #!/usr/bin/env bash
      set -eux

      # Enable networkd
      systemctl enable systemd-networkd.socket
      systemctl enable systemd-networkd.service
      systemctl enable systemd-resolved.service
      - vm
      - default

But DNS still not working on a VM created based on the image.

In our YAML ( you’ll notice that we have logic to specifically create the symlink between /run/systemd/resolve/stub-resolv.conf and /etc/resolv.conf.

You’re also going to need some kind of network configuration in place for DHCP to run at boot time. In our YAML we do that by adding a /etc/systemd/network/ file.

1 Like