DHCP with bridged networking not working with second host if

This is for discussing general topics about how to use VirtualBox.
Post Reply
ManfredU
Posts: 7
Joined: 5. Jul 2012, 17:12

DHCP with bridged networking not working with second host if

Post by ManfredU »

My configuration:
---------------------

VirtualBox: 4.1.18

Host: Ubuntu 12.4 64-bit
Guest: Windows 2003 and Windows 2008

Host network interfaces: eth0 cable, eth1 WLAN.

Guest network interface: Bridged to provide access from the whole network to a web server inside the VMs.

Issue:
-------

Wenn the host is using eth0 (cable is plugged in) and I attach the guest to eth0, automatic IP assignment is working fine, the DHCP server on the network is used. When no cable is plugged in at the host and the host is using a wireless connection (eth1) to connect to the network, the automatic IP assignment via DHCP does not work (an arbitrary IP address is assigned via auto configuration), although I switch the interface from eth0 to eth1 in the Virtualbox GUI. If I manually assign a free IP address to the network interface of the guest, it is used and the guest is reachable on the network. So why is DHCP working via eth0 but not via eth1? Is this a bug?

Thanks,
Manfred
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: DHCP with bridged networking not working with second hos

Post by Perryg »

Was the guest running or in a saved state when you switched the adapters?
More than likely you just need to renew you lease, or run them both at the same time.

Note: running them both at the same time works for me in Linux, but am not sure Windows allows this, so YMMV.
ManfredU
Posts: 7
Joined: 5. Jul 2012, 17:12

Re: DHCP with bridged networking not working with second hos

Post by ManfredU »

Perryg wrote:Was the guest running or in a saved state when you switched the adapters?
I tried both with guest running and powered down. Made no difference. It's not possible to switch to a different interface when the vm is in saved state. At least via the GUI.
Perryg wrote:More than likely you just need to renew you lease.
Yes, I did try 'ipconfig /release', 'ipconfig /renew'. Renewing the lease is what did not work, when the guest network card is connected to eth1. It looks like the DHCP server is not visible in this case. The question is why does it work with eth0 and not with eth1?
Perryg wrote:or run them both at the same time.
Note: running them both at the same time works for me in Linux, but am not sure Windows allows this, so YMMV.
Mmh, when I configure two network interfaces for the guest, one connected to eth0 and one to eth1, indeed both get an IP address by DHCP. Even if one of the host connections is not active?! But only the IP addresse of the interface connected to an active host interface is visible on the network.

Why can't I have just one guest interface which I connect to the active host interface?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: DHCP with bridged networking not working with second hos

Post by Perryg »

Because you have two separate interfaces in the host.
The guest works just like a real PC and can only hook one adapter to one NIC per guest.
The only way I can get it to work seamlessly is to have both active on the host and let the guest deal with it.
If you wait it out I imagine the guest would eventually change the lease by itself but that could take a while depending on the TTL of the lease.
ManfredU
Posts: 7
Joined: 5. Jul 2012, 17:12

Re: DHCP with bridged networking not working with second hos

Post by ManfredU »

Maybe I did not explain it good enough. It's not a problem of waiting until the lease gets changed. Even if release and renew the interface manually (inside the guest) it does not work with eth1. If I switch back to eth0, then the guest interface does get an IP address from the DHCP server again.

Case 1:
Host eth0 - connected to guest adapter 1 bridged LAN connection --> release/renew -->  valid IP address assigned / DHCP server found
Host eth1 - not connected
Case 2:
Host eth0 - not connected
Host eth1 - connected to guest adapter 1 bridged LAN connection --> release/renew -->  no valid IP address assigned / DHCP server not found
When switching between case 1 and case 2 I always get the same result.

Case 3:
Host eth0 - connected to guest adapter 1 bridged LAN connection --> release/renew --> first valid IP address assigned / DHCP server found
Host eth1 - connected to guest adapter 2 bridged LAN connection --> release/renew --> second valid IP address assigned / DHCP server found
Case 3 does even work if eth0 is not active on the host. It looks like in this case the DHCP server is found via eth1 and used for both vbox adapters. And vice versa.
Martin
Volunteer
Posts: 2561
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: DHCP with bridged networking not working with second hos

Post by Martin »

My guess would be some kind of problem with your WLAN router which doesn't like to give out a second IP address to your WLAN adapter (first address used on the host?)
ejmv
Posts: 1
Joined: 13. Jul 2012, 19:21

Re: DHCP with bridged networking not working with second hos

Post by ejmv »

Another option:

I saw this on Windows and xNix where network is managed through NetworkManager (linux) or the like.
This also includes standard windows behaviour.

The symptoms:
- You may have 1+ ethernet card, which IP is assigned through a service (may be any lease, router, etc)
- When there's no cable attached, that card doesn't acquire any address.
- While not assigned, other apps relying on that value dont't behave as expected

Unless (my solution).
- Assign the card a fixed address.

This works for windows and linux boxes as well.
There may be issues related to DNS, name resolution of external services, etc.

Good luck.
Post Reply