VirtualBox - guest Ubuntu loses DNS when host connects to VPN

This worked for some reason

C:\...\VirtualBox\VBoxManage modifyvm "VM name" --natdnshostresolver1 on

I suspect it's because when the VPN is active, the host is doing something special for DNS lookups besides just forwarding requests to the specified DNS servers that VirtualBox picked up from the Windows config.


I had a very similar situation with Lubuntu 16.04 (should be identical in other Ubuntus) but this fix did not improve the situation. At least with 16.04, the problem appears to be that NetworkManager uses a local DNS proxy (dnsmasq), and this doesn't play nice with VPN connections, at least in the default configuration.

Commenting/deleting dns=dnsmasq in /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile,ofono
# dns=dnsmasq

There is probably a way to configure dnsmasq but this gives (me) equivalent access to the host (dns, etc.), so I haven't investigated. YMMV.