1

Is it possible to explicitly tell the VirtualBox NAT connection to use the host's WLAN to provide internet to the guest system?

Question background/ my specific problem right now:

My VirtualBox guest system (Ubuntu 20.04) no longer has internet access since the host's LAN connection broke (the host still has internet via WLAN). I can ping 8.8.8.8 from the guest just fine, so there is some connection to the internet, but browsers or software updates don't work.

I've tried changing the NAT connection a bit as suggested for similar problems (is at desktop adapter, cable is connected), but nothing changed. Setting up a bridged network (with or without promiscuous mode) for the WLAN also had no affect. Looking at the adapters from the host (Win10) side, I noticed that my only VirtualBox network adapter is a host-only ethernet adapter (does this mean it only considers ethernet?). Unfortunately I've no real idea how any of this works. In my head I just need to tell the NAT connection to use WLAN for now, but for NAT I can't select the name of the used host network. But it may also be a DNS problem or something I've never heard of...

Any pointers to potential solutions are very much appreciated, especially if they help me understand why my current configuration is faulty.

2 Answers 2

1

If you can still reach IPs (e.g. ping 1.1.1.1) but connection to internet with domain name doesn't work (e.g. ping one.one.one.one) the problem mostlikely comes from DNS configuration.

Have a look to /etc/resolv.conf, it should contains nameserver <ip> for instance : nameserver 1.1.1.1

If the ip address is a local ip 192.168.*.*, there is a high chance that the router/server configured is not configured to be a DNS. Nevertheless you can keep it and add after nameserver 1.1.1.1 for clouflare or nameserver 8.8.8.8 for google. So if the first fails, the second should work.

You may also have a look to the firewall configuration if there is one active. The firewall could be configured to block DNS requests (port 53)

11
  • It does mention a nameserver and even claims to have an uplink DNS server currently in use (when checking 'resolvectl status'). So I think guest-side this looks OK. And host-side there is a regular IP-address and this seems to fall into case 2 of John's answer, so that should be fine too, right?
    – Setririon
    Jan 23 at 15:44
  • Do you have an error when pinging google.com ? If yes, please publish it, that'll help
    – vinalti
    Jan 23 at 15:48
  • 1
    yeah, pinging google.com fails with a 'Temporary failure in name resolution'. which does sound like an DNS issue
    – Setririon
    Jan 23 at 15:55
  • Sure, try to add a line in /etc/resolv.conf with nameserver 1.1.1.1, tell me if it helps ?
    – vinalti
    Jan 23 at 16:10
  • 1
    I would, sadly the different stackExchange Sub-Things have different accounts and this one is new, so I don't have the necessary exp-things to upvote
    – Setririon
    Jan 23 at 19:47
1

Is it possible to explicitly tell the VirtualBox NAT connection to use the host's WLAN to provide internet to the guest system?

Virtual Box defaults to NAT networking which provide an internal DHCP server and network connection to the Guest so it has Internet.

You can also use Bridged Networking. This form of networking connects the Guest Ethernet to the Host Router that the host machine uses.

Both NAT and Bridged connections use the Guest Ethernet Setup.

If by WLAN, you mean a cellular wireless connection like a phone hotspot, neither NAT nor Bridged connections will connect to such a hotspot directly.

Three options:

  1. Connect your cellular wirless to a Router that includes an Ethernet Switch that your Host machine and also Guest Bridged Network connection can connect to. This will provide correct DNS.

  2. If the Router is only standard wireless for the Host Machine, then NAT networking should work. I use that here on my wireless host machine. The host should have a TCP/IP connection such as 192.168.x.y. This will provide correct DNS.

  3. Obtain a wireless USB card and set up USB Passthrough to the Guest machine. Install the drivers for the wireless USB card in the guest and then connect that to the wireless hotspot.

Don't forget to restart both Guest and Host after making changes.

4
  • I'm not sure I understand this correctly. How does the DHCP server decide which physical network to connect to if there are different choices? Is that fixed, or does it depend on what network the host is using primarily? The way I think about VMs, they just virtualize everything, so I feel like any type of network connection of the host should be turned into a virtualized network connection for the guest, or is this intuition wrong? The wireless network is the "standard" WLAN from the main router in this house, so I don't think that classifies as cellular wireless, does it?
    – Setririon
    Jan 23 at 14:28
  • The VBOX internal DHCP server is confined to the NAT setup for the guest. It is not related to Bridged at all. In NAT, the guest needs an IP address and cannot get that directly from the Host so a DHCP server is provided for that function. Generally it is not possible / bad practice to assign a NAT address as Static. Bridged connections (host router) can be Static. USB Passthrough for the WLAN card is a different connection again. If your WLAN connection is at a Router, then Bridged Connection (Option 1) should work. There is not "one size fits all"
    – John
    Jan 23 at 14:32
  • I amended my answer to include the NAT option for a standard host wireless connection.
    – John
    Jan 23 at 14:37
  • I also made note abut DNS (should be pretty much automatic) and also about restarting machines.
    – John
    Jan 23 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.