diff options
-rwxr-xr-x | debvm-create | 30 | ||||
-rwxr-xr-x | debvm-run | 4 |
2 files changed, 33 insertions, 1 deletions
diff --git a/debvm-create b/debvm-create index b367b3d..8ea33fb 100755 --- a/debvm-create +++ b/debvm-create @@ -144,6 +144,27 @@ if test -n "$SSHKEY"; then INCLUDE_PACKAGES="$INCLUDE_PACKAGES,openssh-server" fi +# add a DNS resolver +case "$SUITE" in + jessie) + set -- '--customize-hook=chroot "$1" systemctl enable systemd-resolved.service' "$@" + set -- '--customize-hook=ln -fs ../run/systemd/resolve/resolv.conf "$1/etc/resolv.conf"' "$@" + ;; + stretch) + set -- '--customize-hook=chroot "$1" systemctl enable systemd-resolved.service' "$@" + set -- '--customize-hook=ln -fs ../run/systemd/resolve/resolv.conf "$1/etc/resolv.conf"' "$@" + INCLUDE_PACKAGES="$INCLUDE_PACKAGES,libnss-resolve" + ;; + buster|bullseye|stable) + set -- '--customize-hook=chroot "$1" systemctl enable systemd-resolved.service' "$@" + set -- '--customize-hook=ln -fs ../run/systemd/resolve/stub-resolv.conf "$1/etc/resolv.conf"' "$@" + INCLUDE_PACKAGES="$INCLUDE_PACKAGES,libnss-resolve" + ;; + *) + INCLUDE_PACKAGES="$INCLUDE_PACKAGES,libnss-resolve" + ;; +esac + # construct mmdebstrap options as $@: set -- \ --verbose \ @@ -165,9 +186,16 @@ set -- \ set -- '--customize-hook=chroot "$1" passwd --delete root' "$@" # dhcp on all network interfaces +SYSD_NET_MATCH='Name=en*\n' +test "$SUITE" = jessie && SYSD_NET_MATCH="${SYSD_NET_MATCH}Name=eth*\n" +SYSD_NET_NET='DHCP=yes\n' +# This anchor is included by default since bullseye. Fails DNSSEC validation when missing. +case "$SUITE" in jessie|stretch|buster) + SYSD_NET_NET="${SYSD_NET_NET}DNSSECNegativeTrustAnchors=home.arpa\n" +;; esac set -- \ '--customize-hook=chroot "$1" systemctl enable systemd-networkd.service' \ - "--customize-hook=printf '"'[Match]\nName=en*\nName=eth*\n[Network]\nDHCP=yes\n'"'"' > "$1/etc/systemd/network/20-wired.network"' \ + "--customize-hook=printf \"[Match]\\n${SYSD_NET_MATCH}\\n[Network]\\n$SYSD_NET_NET"'\n[DHCP]\nUseDomains=yes\n" > "$1/etc/systemd/network/20-wired.network"' \ "$@" # add ssh key for root @@ -158,6 +158,10 @@ fi if test -n "$SSHPORT"; then NETDEV="$NETDEV,hostfwd=tcp:127.0.0.1:$SSHPORT-:22" fi +DNSSEARCH=$(dnsdomainname) +if test -n "$DNSSEARCH"; then + NETDEV="$NETDEV,domainname=$DNSSEARCH" +fi set -- \ -append "$KERNEL_CMDLINE" \ -netdev "$NETDEV" \ |