TL;DR:
What do I need to configure so I can resolve a .local
hostname on my VM guest as if I was resolving it on my VM host.
Long version:
I'm running a VM with Ubuntu 21.04 on my Windows 10 using VMware Workstation (16.1.1 build-17801498). Ubuntu itself is almost vanilla, I've changed next to nothing about the OS/env itself (actually nothing comes to mind right now). Maybe it's noteworthy I upgraded from a previous version of Ubuntu, I believe it was 20.04.
On the host, I can resolve foo.bar.local
just fine using nslookup:
> nslookup foo.bar.local
Server: <...>
Address: 10.73.1.9
Name: <...>
Address: 10.132.0.30
Aliases: foo.bar.local
On the guest, the same attempt to resolve fails by default
> host foo.bar.local
Host foo.bar.local not found: 2(SERVFAIL)
but I can resolve the name if I tell host to use the same DNS server which responded earlier on the (VM) host:
> host ordermanagement-migration.comventure.local 10.73.1.9
Using domain server:
Name: 10.73.1.9
Address: 10.73.1.9#53
Aliases:
foo.bar.local is an alias for hello.world.local.
hello.world.local has address 10.132.0.30
So I was thinking "why not just use that server always?" and tried to configure it via the network manager GUI: open network settings, go to IPv4 tab, disable "automatic" and enter the IP in the field. Since my VM has two interfaces configured (host-only network & normal NAT for public inet access) and just to be safe, I did this for both interfaces. To my surprise no amount of waiting time after confirming those changes actually led to an observable change in the output of systemd-resolve --status
: For both interfaces, it just kept the respective a.b.c.1
address as DNS server. Instead, I had to first dis- then enable the interfaces, after which the server IP is showing up:
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (ens33)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 10.73.1.9
DNS Servers: 10.73.1.9
Link 3 (ens38)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 4 (docker0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
I didn't understand why for ens38
(public inet access), no DNS server was shown anymore at all. At this point things got even more confusing because enabling an interface (in network manager) on which I had previously disabled "automatic" for DNS suddenly showed "automatic" as enabled but also listed the manual DNS IP and systemd-resolve --status
yet I still could not resolve foo.bar.local
.
I've also tried to set 10.73.1.9
as the primary DNS server directly in the NAT/DNS settings of VMware workstation but to no avail.
So how can I get foo.bar.local
to be resolvable on my (VM) guest by default, in other words without having to specify 10.73.1.9
as nameserver to use - which I cannot do in the application context where I need foo.bar.local
resolvable.
addendum: There is a VPN involved on my VM host in case that might be relevant. I keep it enabled & connected at all times when using the (VM) host.