1

What I want:

I want a virtual machine guest running Ubuntu (on VirtualBox) for various web development test servers (running on different ports, e.g. Grunt.js is running on port 9000).

  • I want to test web applications running on these servers a) from within the guest b) from within the host (running Windows 7, btw), c) from other devices in the same network, connected via WiFi (e.g., mobile devices)
    • I want to be able to access the Internet from within the guest

I was first running a solution where I had both a NAT and a Host-only adapter configured in VirtualBox, which was fine for accessing the guest from the host and for accessing the Internet from within the guest.

Now that I want other devices to be able to access the virtual machine, this solution doesn't work anymore. I was able to do this years ago with a bridged network adapter, but that doesn't seem to work here.

What I did:

I set up bridged networking as the only network adapter in VirtualBox and left the default settings. When I boot up the guest, the WiFi symbol in the upper right keeps flashing, i.e., the arrows don't show up. After a while it says: "Disconnected - you are now offline". This is the output of ifconfig:

eth0      Link encap:Ethernet  HWaddr 08:00:27:71:92:9c  
          inet6 addr: fe80::a00:27ff:fe71:929c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:233 errors:0 dropped:0 overruns:0 frame:0
          TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:16083 (16.0 KB)  TX bytes:22280 (22.2 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2624 (2.6 KB)  TX bytes:2624 (2.6 KB)

As you can see, no inet4 address. I thus cannot ping the host from within the guest and vice versa.

I also tried this, i.e. I changed the MAC address and ran

sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules

sudo reboot

Didn't change anything at all.

What else can I do to debug this? I suspect it's a DHCP problem. I can easily get an IP on my host and other machines in the network, but not on the guest.

  • What version of ubuntu are you using, and have you made changes to services? This has worked for me with no issues for years on with multiple different types of guests (ubuntu8-12,windows) on an osx host over wifi. There is a setting to enter the MAC address of the guest in virtbox settings, is it the same as your host maybe? – fightermagethief Apr 5 '14 at 23:59
  • also, what do the network settings for the guest look like under the virtbox manager? This is where I can choose my wifi device, bridged adapter, mac of guest, etc. – fightermagethief Apr 6 '14 at 0:06
  • What does you syslog in /var/log say for dhclient:? Have you tried setting up a static ip configuration? – David Apr 6 '14 at 14:18
  • I am sure you would have checked this, but just in case you didn't. did you create the Virtual network adapter on right link. i.e your host is connected to router on wlan and you created the adapter on wlan, if not you will not get the IP. If the above is fine, then we can debug as below > Can you run tcpdump and see if any packet is going out or coming in > What does dmesg logs > Is there any other VMs on the same machine which is working fine? – Chandrasekar Apr 6 '14 at 14:22
4
+50

It is doable with VirtualBox, I got the same config running recently, Windows 7 host, Arch Linux guest, on a laptop with wifi. As you said, that's when giving a bridged networking to the guest. I also chose virtio driver for the virtual card, but I doubt that's related with the topic at hand.

The guest gets an IP from any router the host happens to connect to, it's working seamlessly, and come to think of it it's very impressive. I tried to achieve the same on Xen host and haven't been able to. So it's coming from some magic from VirtualBox drivers, the only public description being here: http://www.virtualbox.org/manual/ch06.html#network_bridged.

Bridging to a wireless interface is done differently from bridging to a wired interface, because most wireless adapters do not support promiscuous mode. All traffic has to use the MAC address of the host's wireless adapter, and therefore VirtualBox needs to replace the source MAC address in the Ethernet header of an outgoing packet to make sure the reply will be sent to the host interface. [...] VirtualBox examines ARP and DHCP packets in order to learn the IP addresses of virtual machines.

This driver extension should be open source since it's not mentioned in the "Oracle VM VirtualBox Extension Pack", but it's pretty hard to find documentation about it. Unfortunately I don't know how to troubleshoot it, but I would try to:

  1. Look at the properties of the host wireless card, check if you see the virtualbox stuff there (I reinstalled the machine since, so I can't check what are the additional items exactly)
  2. Uninstall and reinstall the wireless card. It's likely to remove the additional items, so I would assume that deactivating / reactivating bridged networking in the VM properties would reinstall that part.

Also if the router is yours, you can have a look at its log, see if at least it gets some tentative connections from the guest.


Edit: You commented that it's working with another router/access point? In this case it's possible that some routers refuse to allocate more than one IP to the same MAC address. It's a shame I don't have the machine anymore, to see if the MACs for each IP in the router are the same, but that should be the case.

  • 1
    Regarding your edit: DHCP servers are supposed to give the same IP address lease back to a client that asks again from the same Client ID, and the Client ID defaults to the MAC address. If this what he's running into, he should try manually setting a different Client ID (it can be any string) in the guest OS. //cc @wnstnsmth – Spiff Apr 4 '14 at 19:27
  • Thansk for the exhaustive answer. I accept this one. In the meantime, the problem solved itself. I suspect that the router ran out of IP addresses in the period I tried establishing a connection. I don't really know. But if the problem happens again, I will use this answer and the above comment for debugging. – wnstnsmth Apr 7 '14 at 6:43
1

The IEEE 802.11 standard requires APs to reject packets from unknown MAC addresses; the client must do an 802.11 Authentication and Association first, before the AP can accept data packets from it. So if "bridged mode" means your VM or guest OS is trying to use a second MAC address over the same radio card, it must make sure the second MAC address is getting 802.11 authenticated and associated, otherwise the AP has to ignore the packets from the second MAC address.

Is there documentation for how VirtualBox deals with this issue? This has to be a well-known problem that's either been solved (and there should be documentation of how it was addressed), or it should be well documented that "bridged mode over Wi-Fi is not supported".

  • It must be supported as I successfully tested it with another AP. Could it be that the AP rejects further MACs? This is not plausible, though, because I can still connect with other devices, so there must still be "room" for more. – wnstnsmth Apr 3 '14 at 8:04

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.