net: forward guest DNS to the host's DNS server - #108
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.