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

Pass DNS addresses from en0 interface to guest instance #199

Merged
merged 1 commit into from
Sep 4, 2021

Conversation

jandubois
Copy link
Member

qemu user-mode networking is forwarding DNS to just a single DNS entry from the host. So if that entry does not resolve
the query, there is no fallback.

Fixes #150 (I hope)

Please review the code updating the DNS entries in the guest. The direct updates to /etc/resolv.conf are probably useless because the file will still be regenerated after cloud-init is done. I've included code to configure systemd-resolved, and udhcpc (used by Alpine). Any other mechanisms needing support?

The sysprof code is expected to be used to provide default proxy information as well (see #189 (comment))


import "github.com/lima-vm/lima/pkg/sysprof"

func DNSAddresses() ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QEMU seems using libresolv to get DNS addresses https://gitlab.freedesktop.org/slirp/libslirp/-/blob/v4.6.1/src/slirp.c#L151

Why isn’t this working for us?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it then only picks the first one it finds. It forwards DNS to that address instead of adding all the servers to the resolver inside the guest (probably because it isn't clear how it could do the latter).

So if the choosen server is not working, or is an IPv6 address in a broken IPv6 setup, then no names will resolve because there is no fallback.

@jandubois
Copy link
Member Author

Temporarily switched to Draft mode because I think the name servers should only be added to the QEMU slirp interface, and not the the vde interfaces. Will update once more.

@jandubois
Copy link
Member Author

Seems to be working fine now:

jan@lima-default:/Users/jan$ sudo cat /mnt/lima-cidata/network-config
version: 2
ethernets:
  eth0:
    match:
      macaddress: '52:55:55:e9:a1:b4'
    dhcp4: true
    set-name: eth0
    nameservers:
      addresses:
      - 192.168.123.53
      - 192.168.123.17
  vde0:
    match:
      macaddress: '52:55:55:be:2a:6a'
    dhcp4: true
    set-name: vde0
    
jan@lima-default:/Users/jan$ systemd-resolve --status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.123.53
       DNS Servers: 192.168.123.53 192.168.123.17 192.168.5.3

Link 3 (vde0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.105.1
       DNS Servers: 192.168.105.1 fe80::864:900c:7ae3:f83c%22011
        DNS Domain: home

@AkihiroSuda
Copy link
Member

LGTM after gofmt, thanks

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda added the status/merge-on-green Merge on CI green label Sep 4, 2021
@@ -6,4 +6,11 @@ ethernets:
macaddress: '{{$nw.MACAddress}}'
dhcp4: true
set-name: {{$nw.Name}}
{{- if eq $nw.Name $.SlirpNICName }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& DNSAddress is not empty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it, but I don't think it should make any difference. Setting a key to nil or not having the key at all should have the same effect. But having the check means we won't have to worry if there is a bug in dealing with this in cloud-init...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AkihiroSuda
Copy link
Member

ArchLinux CI is failing consistently after retrying several times

@jandubois
Copy link
Member Author

ArchLinux CI is failing consistently after retrying several times

Any idea what might be causing it? I can't repro it locally, even when I pass an empty Addresses list to the instance.

qemu user-mode networking is forwarding DNS to just a single
DNS entry from the host. So if that entry does not resolve
the query, there is no fallback.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
@jandubois
Copy link
Member Author

ArchLinux CI is failing consistently after retrying several times

Worked first time now, but Fedora had to be restarted. I don't think this is related to the len($.DNSAddresses) check, but anyways, all green now. 😄

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit f8f3659 into lima-vm:master Sep 4, 2021
@jandubois jandubois deleted the dns branch September 4, 2021 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request status/merge-on-green Merge on CI green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IPv6] DNS failure during install of either 0.5.0 or 0.6.0 results in sshfs not found or installed.
2 participants