VirtualBox guest cannot connect to internet but VB set to bridged adapter, guest has ip address

I set the guest os (ubuntu) to have a static ip address via /etc/network/interfaces :

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.127
netmask 255.255.255.0
network 192.168.1.255
gateway 192.168.1.1

And the route appears correct:

route -n

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

And it’s able to reach the router (when I type 192.168.1.1 in firefox, it shows the router’s info page) but the router doesn’t show the guestos’ ip address among its clients!

And in VirtualBox settings, I have “Attached to: Bridged Adapter” and “wlan0” (it’s a laptop).

Despite all that, I cannot connect to the internet from the guest. I also cannot view the webserver running on the guest from the host. What could be wrong?

Is network option OK?


network 192.168.1.255


yes, I finally got it tto work. I set to promiscuous mode and turned off cable plugged and added a second adapter as NAT and suddenly it started working!

Recommend you post the full result of the following run on your Host

ip addr

That should identify your transparent bridging device.

Although I don’t run Virtualbox, other technologies should create and run virtual networks in a similar way (Have learned a lot recently extending generally available documentation). Typically <all> virtualization Guests on Linux should be configured to connect to the transparent bridge device and not the physical device as you’ve done (wlan0). Exactly what the name of the device should be would be revealed by above.

From <within> the Guest, I’ve had mixed results configuring both a physical network device (typically eth0) and another bridging device (typically br0, but note that a bridge device <inside> a Guest is not the same as the bridge outside on the Host).

HTH,
TSU

I believe you’re misunderstanding what that bridging does, but I ran “ip addr” and it lists three things:

  1. lo
  2. eth0
  3. wlan0

The “lo” is just loopback and eth0 is not connected on the laptop (I’m using wireless), so “wlan0” is the device the laptop uses to connect to the local network and the internet. So in Virtualbox, I set the guest to also connect through that. In the guest, it’s “eth0” (as you’ll notice in my first post where I show the settings in /etc/network/interfaces on the guest) so it’s not the same device name guest vs host, but the bridging enables guest’s “eth0” to be a wired view of a wireless device.

On 05/21/2013 01:26 PM, 6tr6tr wrote:
>
> I believe you’re misunderstanding what that bridging does, but I ran
> “ip addr” and it lists three things:
>
> 1. lo
> 2. eth0
> 3. wlan0
>
> The “lo” is just loopback and eth0 is not connected on the laptop (I’m
> using wireless), so “wlan0” is the device the laptop uses to connect to
> the local network and the internet. So in Virtualbox, I set the guest to
> also connect through that. In the guest, it’s “eth0” (as you’ll notice
> in my first post where I show the settings in /etc/network/interfaces on
> the guest) so it’s not the same device name guest vs host, but the
> bridging enables guest’s “eth0” to be a wired view of a wireless device.

You are failing to understand the concept of “virtual”. It doesn’t matter what
hardware the host is using for its connection. What is important is the virtual
device that the guest sees. The VirtualBox software provides a virtual wired
device that it calls “eth0”. That is the one you need to bridge. It does not
provide any virtual wireless. Just set up the VB network adapter as a bridged
device. VB will handle the rest.

If you want the guest to have wlan0, you will need to provide it with access to
a real wireless device that the host is not using, but it will not use the
host networking at all. I have done this with USB passthrough. If my hardware
supported PCI passthrough, then I could connect to a PCI device.

The “wlan0” is what’s only in VirtualBox Manager. The Guest doesn’t even know that exists. I’m not sure what you’re getting at or what you think I’m referring to but the “wlan0” is definitely the host’s interface. And in that VirtualBox Manager, it describes that Adapter setting (where I choose “wlan0”) as:

Selects the network adapter on the host system that traffic to and from this network card will go through.

So that means I HAVE to choose “wlan0” if I want to get any internet connection.

I can believe that.
But after selecting the wlan0 interface and proceeding to creating your VM, Virtualbox <should> have created a transparent/virtual bridging device which should have then shown up when you did “ip addr”

Although I think you said you’re working fine now, did you say you "added a second adapter as NAT"set in promiscuous mode and things started working? So, your “second adapter” is likely a virtual adapter (not physical) or is it a real physical adapter? Ordinarily, if a virtual bridging device was created, it would be set to promiscuous automatically so you may have custom created a solution similar but not exactly what should have been done for you automatically…

Just curious… Although things may be working for you, unless it’s understood exactly what you did and why it’s working you might find it difficult to repeat the process… and/or if you’re setup not consistent with how Virtualbox intended you might find yourself on your own without supporting documentation.

IMO,
TSU