Integrating virtual machine in network

Discussions related to using VirtualBox on Linux hosts.
Post Reply
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Integrating virtual machine in network

Post by LB06 »

Hello,

Currently I am trying to integrate my virtual machine(s) into my existing network. I will first outline my current setup:

- eth1 is directly connected to the internet using a public ip (using dhcp).
- eth0 has a static ip (192.168.1.1) and is connected to a switch/AP (actually, it's a wireless router-switch with router functionality disabled but that doesn't really matter)
- The switch connects devices like my iPod, notebook and XBox 360 to eth0
- All my devices get an ip assigned by dhcpd3.

So basically, my PC functions as a router with DHCP server:

inet <---> PC w/DHCP <--> Switch <---> My devices

Configuration wise, this translates into this:

/etc/network/interfaces:

Code: Select all

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet dhcp

auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
/etc/dhcp3/dhcpd.conf:

Code: Select all

# ...

# eth0 subnet configuration
subnet 192.168.1.0 netmask 255.255.255.0 {
	range 192.168.1.101 192.168.1.120;
	option routers 192.168.1.1;
	option broadcast-address 192.168.1.255;
}
I am running shorewall as a frontend for iptables, which takes care of the DNAT functionality, port forwarding and firewall stuff.

Pretty straightforward if you ask me.

My problem is as follows: I would like to properly integrate my virtual machines into my current network. In other words, every vm should get an ip from dhcp3-server instead of the built-in dhcp server in vbox. Right now, I am forced to use both dhcp servers and subnets (192.168.1.x and 10.x.x.x or whatever vbox uses by default). This is highly inconvenient, because I have to maintain two separate subnets.

If I select Host Interface my guest OS'es do not get an IP at all, which I think is correct. After all, if I bridge the guest networks over eth1, my ISP will probably receive the DHCP request, which will of course be denied, since I'm only granted one public IP. If I bridge the network over eth0 my iPod probably receives the DHCP request. Since I have not jailbroken my iPod, I don't have a dhcp server running there either ;).

Hopefully you get my problem. Any help would be appreciated!

Host: Ubuntu Ibex Intrepid 8.10 all updates
Guest: Windows XP SP3 all updates
Virtualbox: 2.1 using the "deb http://download.virtualbox.org/virtualbox/debian intrepid non-free" repo
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

With 2.1 VBox implements the HIF essentially the same way as VMware. The guest just does a promiscuous multicast DHCP request and this should be picked up and honoured by your DHCP server in your host. I do this (albeit the DHCP request is served by my router).
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

TerryE wrote:With 2.1 VBox implements the HIF essentially the same way as VMware. The guest just does a promiscuous multicast DHCP request and this should be picked up and honoured by your DHCP server in your host. I do this (albeit the DHCP request is served by my router).
Maybe, but if so the built-in dhcp server always answers first.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

If you aren't using the DHCP function in the router, why don't you just disable it? You don't seem to be using it. Then there will be no conflict.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

TerryE wrote:If you aren't using the DHCP function in the router, why don't you just disable it? You don't seem to be using it. Then there will be no conflict.
I did. I'm not using my WAN port and I have disabled the DHCP server on my router/switch. So basically it's just a switch. My PC is my router and DHCP server.

If there's a conflict that conflict must be between the DHCP server on my PC and the DHCP server in vbox.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

Now that one does have me confused, if it was between VBox and your DHCP then more people would be hitting this. Not sure that I can help with this one. Sorry
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

TerryE wrote:Now that one does have me confused, if it was between VBox and your DHCP then more people would be hitting this. Not sure that I can help with this one. Sorry
NP, but I don't think that many people run vbox on their dhcp server :).

I think the 'problem' is that I'm running my DHCP on my host instead of on a separate machine. If I bridge vbox with my LAN interface it does not actually ask the host itself for a DHCP offer, it only asks the devices that are connected to the interface. Normally that would not be a problem, because there would be a router or separate server with DHCP functionality that would answer.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

I do have to wonder why you need to run DHCP on your PC. This creates an "always-on" requirement on your N/W. I have 2 routers and small NAS which are already "always-on" and offer DHCP so I just use one of those. This means that I don't need to have any specific PC on for the LAN to function.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

TerryE wrote:I do have to wonder why you need to run DHCP on your PC. This creates an "always-on" requirement on your N/W. I have 2 routers and small NAS which are already "always-on" and offer DHCP so I just use one of those. This means that I don't need to have any specific PC on for the LAN to function.
Oh yes, you are correct. The most obvious choice would indeed be to let my router handle everything and connect my PC to my router, like my iPod and Xbox. The problem is that my router is not nearly fast enough to keep up with my internet connection. The NAT-throughput of my router is roughly 45-50mbit, while my internet connection is 100Mbps up & down (FttH). This is not as big as a problem as it used to be, because I believe most 802.11n routers are able to achieve a 100Mbps NAT-throughput. These routers are relatively expensive but still affordable. But it was the initial reason I decided not to buy a fast and then very expensive router, but use my PC as a router, so I would have full access to my bandwidth.

And I am glad I didn't.The biggest problem with this setup is not the router throughput (anymore). It's the loss of flexibility of a router when compared to a full-blown PC. My PC not only runs DHCP. It's also hosting SSH, Samba, Apache, a torrent client, mpd, icecast, etc etc. Many of these services do not run well on a router, if at all. Besides, if I used my router as a router, I also would have to buy new and probably rather expensive NAS solutions, since I want my data to be available anywhere and they're just built-in HDD's right now.

But thanks for your input anyway :)
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

What I want is not a bridge from eth0 to wherever the cable is physically going (usually a router), but exactly the other way around. I want VirtualBox to act as if it were physically connected to my switch and establish a virtual connection to eth0 on my PC.
phos
Posts: 2
Joined: 30. Jan 2009, 15:24

Post by phos »

Hi, wouldn't it work if you change the network-settings, in VB, from NAT to Host Interface Networking? This way your host would see it as if it was directly connected to the host itself... although not to your router.
I haven't tried this myself so I can't say it would work - just a guess.
metodk
Posts: 12
Joined: 28. Jan 2009, 09:48

Post by metodk »

LB06 wrote:
TerryE wrote:I do have to wonder why you need to run DHCP on your PC. This creates an "always-on" requirement on your N/W. I have 2 routers and small NAS which are already "always-on" and offer DHCP so I just use one of those. This means that I don't need to have any specific PC on for the LAN to function.
Oh yes, you are correct. The most obvious choice would indeed be to let my router handle everything and connect my PC to my router, like my iPod and Xbox. The problem is that my router is not nearly fast enough to keep up with my internet connection.
I don't think you need to put your router as GW to internet. You can simply use it as you do now, just enable DHCP functionality. Disable DHCP server on your GW host. You can then either
  • * allow your router DNS also handle IP for eth0 of your GW host (if your router has decent DHCP implementation, you can enter MAC address of eth0 of your GW host and assign static IP and also set that IP as default GW in DHCP responses)
    * keep static configuration of eth0 and tell router's DHCP not to offer it to other hosts
To get back to VirtualBox issue: my experience is that if you choose that virtual network interface is attached to Host Interface (eth0 in your case), then VB will not act as DHCP server for virtual interface. It'll pass all packets (including DHCP reqs) directly to host interface.
My experience goes that communication between guest and host OS doesn't work very well this way (at least when host OS is linux).
I guess that host OS' virtual bridge sends out ethernet packet both to host OS' network stack as well as out to the wire. When switch (router in your case) receives such an etherent frame, it sends it back down the same wire. Host OS' virtual bridge gets it and pushes it to both host and virtual interfaces. Hence host network stack gets ethernet frames twice while it is ignored by virtual OS.

It may be that this creates enough trouble in your case (DHCP server running on your host OS) that virtual OS doesn't get IP config back.
It may be that my guess above is utterly wrong though. :roll:

Using your router as DHCP server would definitely help in this case.
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

metodk wrote:I don't think you need to put your router as GW to internet. You can simply use it as you do now, just enable DHCP functionality...
I think I know what you're aiming at. Do you mean I should use my router as DHCP server but not as GW? That would indeed solve my problem I suppose.

I'm trying to get it to work, but I can't get my internet to work on my iPod or Xbox, so my vhost is probably a no-go either. I do however get assigned an IP address.

eth0: static 192.168.1.1
router: static 192.168.1.2
iPod: dhcp 192.168.1.10

http://stuwww.uvt.nl/~s178024/dhcpserver.png
http://stuwww.uvt.nl/~s178024/dhcpleases.png

edit: I think this solution doesn't work because of a bug in my router. All my devices get assiged an IP address, but the gateway is 192.168.1.2 (my router), but not 192.168.1.1 (my PC/gateway) as I have configured. I sent a bugreport to sitecom. Hopefully they'll fix it.
Last edited by LB06 on 31. Jan 2009, 00:00, edited 2 times in total.
LB06
Posts: 8
Joined: 10. Jan 2009, 17:24

Post by LB06 »

Uhm, somehow it seems to work right now using HIF networking on eth0, using my PC's dhcp server. I don't know why it suddenly started working. Ubuntu had a VB upgrade and some kernel upgrades yesterday, which resulted in me having to run /etc/init.d/vboxdrv setup. Maybe that did the trick.

Anyway, TerryE and metodk thanks very much!
Post Reply