Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS fails #22

Open
muelli opened this issue Aug 28, 2018 · 0 comments
Open

DNS fails #22

muelli opened this issue Aug 28, 2018 · 0 comments

Comments

@muelli
Copy link

muelli commented Aug 28, 2018

The DNS logic in virtme-init uses test -f /etc/resolv.conf for checking whether a resolv.conf exists and, if so, replace it with a writeable file supposedly s.t. the udhcp can write it s.t. name resolution works.

On my Ubuntu 18.04, however, /etc/resolv.conf is a symlink:

lrwxrwxrwx 1 root root 39 Oct 13  2017 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

and that target directory does not exist (does systemd-tmpfiles not create it..?).

On top of that, it seems, that bind-mounting over a symlink doesn't work:
https://serverfault.com/questions/322906/how-do-i-do-a-bind-mount-over-a-symlink :(

This dirty patch makes it work for me:

diff --git a/virtme/guest/virtme-init b/virtme/guest/virtme-init
index 44a018a..82f6c89 100755
--- a/virtme/guest/virtme-init
+++ b/virtme/guest/virtme-initdiff --git a/virtme/guest/virtme-init b/virtme/guest/virtme-init
index 44a018a..d080aae 100755
--- a/virtme/guest/virtme-init
+++ b/virtme/guest/virtme-init
@@ -146,16 +146,18 @@ fi
 ip link set dev lo up
 
 if cat /proc/cmdline |grep -q -E '(^| )virtme.dhcp($| )'; then
-    if [[ -f /etc/resolv.conf ]]; then
+    #if [[ test -f /etc/resolv.conf || test -h /etc/resolv.conf || test -e /etc/resolv.conf ]]; then
        tmpfile="`mktemp --tmpdir=/tmp`"
        chmod 644 "$tmpfile"
        mount --bind "$tmpfile" /etc/resolv.conf
        rm "$tmpfile"
-    fi
+    #fi
 
     # udev is liable to rename the interface out from under us.
     virtme_net=`ls "$(ls -d /sys/bus/virtio/drivers/virtio_net/virtio* |sort -g |head -n1)"/net`
     busybox udhcpc -i "$virtme_net" -t 1 -n -q -f -s "$(dirname $0)/virtme-udhcpc-script"
+    mkdir /run/systemd/resolve/
+    echo nameserver 10.0.2.3 | tee /run/systemd/resolve/stub-resolv.conf
 fi
 
 if [[ -x /run/virtme/data/script ]]; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant