Skip to content

net: forward guest DNS to the host's DNS server - #108

Merged
techomancer merged 1 commit into
techomancer:mainfrom
iblowmymind:mac-vpn-dns
Sep 17, 2026
Merged

techomancer merged 1 commit into
techomancer:mainfrom
iblowmymind:mac-vpn-dns

Conversation

@iblowmymind

Copy link
Copy Markdown
Contributor

Guest DNS queries were always forwarded to a hard-coded 8.8.8.8. A VPN such as Mullvad blocks DNS to anything but its own resolver while still allowing direct IP traffic, so guest TCP to public addresses worked but hostnames did not resolve.

NAT now forwards guest UDP DNS queries to the host's configured DNS server: the first IPv4 nameserver in /etc/resolv.conf on macOS and Linux, or the IPv4 DNS server of the connected adapter with the lowest metric on Windows (GetAdaptersAddresses). The address is re-read every 5 s, so connecting or disconnecting a VPN needs no restart. If none is found, 8.8.8.8 is used as before.

GatewayConfig::dns_upstream becomes an Option: None (the default) follows the host, Some pins a fixed server.

DHCP still advertises 8.8.8.8 rather than the host's server, which is often a loopback address (a VPN's local resolver, systemd-resolved) that the guest would take as its own. The NAT forwards port-53 UDP whatever the destination address, so guest lookups still reach the host's server.

Guest DNS queries were always forwarded to a hard-coded 8.8.8.8. A VPN
such as Mullvad blocks DNS to anything but its own resolver while still
allowing direct IP traffic, so guest TCP to public addresses worked but
hostnames did not resolve.

NAT now forwards guest UDP DNS queries to the host's configured DNS
server: the first IPv4 nameserver in /etc/resolv.conf on macOS and
Linux, or the IPv4 DNS server of the connected adapter with the lowest
metric on Windows (GetAdaptersAddresses). The address is re-read every
5 s, so connecting or disconnecting a VPN needs no restart. If none is
found, 8.8.8.8 is used as before.

GatewayConfig::dns_upstream becomes an Option: None (the default)
follows the host, Some pins a fixed server.

DHCP still advertises 8.8.8.8 rather than the host's server, which is
often a loopback address (a VPN's local resolver, systemd-resolved) that
the guest would take as its own. The NAT forwards port-53 UDP whatever
the destination address, so guest lookups still reach the host's server.
@techomancer
techomancer merged commit 9ea63c1 into techomancer:main Sep 17, 2026
1 check passed
@iblowmymind
iblowmymind deleted the mac-vpn-dns branch September 17, 2026 07:09
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

Successfully merging this pull request may close these issues.

2 participants