Ticket #4544 (closed enhancement: duplicate)
Built-in DNS server
|Reported by:||nicoatsun||Owned by:|
In NAT networking mode, VBox's built-in DHCP server hands out the DNS configuration of the host to the guest. If the host's DNS configuration then changes (e.g., you change locations, start VPN, stop VPN, whatever), the guest will continue to use the now-incorrect DNS resolver configuration. This then causes timeouts in the guest, such that logging into the guest via ssh, for example, can take a long time to complete.
It'd be nice if VBox could run a very simple DNS relay such that the address that guests see as the DHCP server address is also the DNS server. Many home and small office routers nowadays have a similar feature. The "router" (in this case, VBox) can just forward the DNS messages, with NAT, to a nameserver listed in the host's resolver configuration.
If there's more than one nameserver listed in the host's resolver config, then round-robining is an obvious way forward, though it may not work very well in practice (people tend to mix nameservers for disjoint namespaces in their resolver configs!). A fake server on the NATted network for each nameserver in the host's config and straightforward, NATted forwarding for each will do. More complex implementations are possible, such as forwarding the guests' DNS messages to all nameservers in the host's config and forwarding back the first reply, but this would require parsing DNS messages.
There is a workaround for the lack of this feature. Restarting the network services in the guest causes the guest's resolver configuration to be updated, IFF one first restarts VirtualBox. That means that one must first close the VM, saving its current state, then one must restart VirtualBox, then resume the stopped VM, then restart the network in the guest. This is a fairly heavy-duty workaround though.