So I needed a way of running a couple test servers. Each needed to accept connections from the network including the host operating system. The connections needed to also be static for server testing. As a reminder to myself, here is a brief rundown on how to do it.
I am using VirtualBox 1.5.2 with Windows Vista (XP will work with this method as well). For the Guest I am using Ubuntu 6.06 Server. This will work with other Debian based flavors.
Host Setup
1. Create a new virtual machine.
2. Click on Network to configfure network settings for your VM
3. Add a new host interface by click the add button next to the Host Interfaces select box. Name it anything you like.
4. Change the Attached to option to Host Interface. Choose your new host interface in the Interface name option.
5. This will create a virtual interface TAP adapter in the Windows Network Connections.
6. Go to the Windows Network Connections. Highlight your main connection and the new virtual interface, right click and choose Bridge Connections.
Now all packets sent to or from the virtual interface will be routed through your main network connection. Now to set up the client.
Client Setup
1. Start the virtual machine with Ubuntu Installed
2. Set up your network interface
sudo nano /etc/network/interfaces
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.266
gateway 192.168.0.1
3. Set up your nameservers
sudo nano /etc/resolv.conf
nameserver xx.xx.xx.xx
nameserver xx.xx.xx.xx
4. Restart the network
sudo /etc/init.d/networking restart
5. Test
ifconfig - should see the address set in the /etc/network/interfaces
ping -c3 192.168.0.1
Alright that's it. I will show you how to bridge your connection on Linux next time.
December 2nd, 2007 at 10:05 am
Great guide, once I got my wireless connection bridged, it all worked out, awesome! If you’re trying to bridge your wireless connection with the virtualbox connection, check http://support.microsoft.com/kb/302348
January 17th, 2008 at 11:47 pm
I wanted to set up two virtual machines and have them talk to one another via their TAP interfaces. So I configure two TAPs, TAP1 and TAP2 (creative huh?) install two virtual XP machines, set them up and run the. Both VMs can ’see’ the LAN. I assign them to the same workgroup and share one folder on one of the VMs. Trouble is neither of them see the workgroup. When you browse the network places, all MS networks, you see nothing. Any ideas why?
January 17th, 2008 at 11:48 pm
Small correction to that last item, you DO see the workgroup name in the network places, but you see no network resources.
January 23rd, 2008 at 3:29 pm
great howto. exactly what i needed to test some linux servers.
February 19th, 2008 at 7:17 pm
Thanks for the tip. Defenely I will use VirtualBox to continue the tests with Linux.
March 27th, 2008 at 5:03 pm
Great tips, just a couple of corrections:
Broadcast should be x.x.x.255 and not x.x.x.266 (obviously)
also, the current Ubuntu (7.10) needs only the bridging part on the windows and just restart the network services… everything works!
Thanks for the tips again.
April 14th, 2008 at 1:00 pm
George, I need to do the same setup on Vista and am facing difficulty in doing the same.
You seem to have made some assumptions.
Can you please confirm a few things:
1) Why did you set the static IP of eth0 in Linux guest as 192.168.0.2. Was this because your windows host was behind a router, and had an IP in the subnet 192.168.x.x?
2) Was the default gateway of your windows host 192.168.0.1?
3) Was internet working in your linux host with this configuration?
4) Did you not have to enable promiscuous mode for the Virtualbox TAP Adapter using netsh bridge set adapter 1 forcecompatmode=enable?
Thanks
April 14th, 2008 at 1:01 pm
Also, did you copy your nameservers from windows wireless network adapter (got them from ipconfig /all?)
April 21st, 2008 at 10:08 am
Thanks for this. It’s not working for me, though, and I really wish it would, as it’s the ONLY problem I’m having with VirtualBox, but a complete showstopper. I’m trying to avoid having to switch to VMWare. I’m using version 1.5.6 of VB running on a Vista host, with an Ubuntu 7.10 client. I’ve followed your instructions to the letter, but when I restart the network and do an ifconfig, I see that eth0 has no IP address. I then rebooted the VM and now ifconfig shows no entry for eth0, but instead an entry for eth1, with the same IP address as the host. Does this make any sense to you? I’m at my wit’s end with this. I wish Innotek would make this easier - VMWare just works in this respect.
April 21st, 2008 at 10:20 am
Hallelujah! Moments after posting, I tried using the graphical network configuration in KDE’s systemsettings and I now have a working network setup - the client can see the outside world and vice versa. If it helps anyone, here is the content of my /etc/network/interfaces file:
# The loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0
# The primary network interface
iface eth1 inet static
address 192.168.0.31
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
auto eth1
April 21st, 2008 at 10:44 am
Further delights! I have determined that it is possible to do the same with a second VM and have both running. You create another host interface for your second VM, select it, and then in Windows add it to the bridge by right-clicking. Obviously you need a different static IP address.
June 27th, 2008 at 7:46 am
Thanx dude, youre post help me =)
July 20th, 2008 at 11:49 pm
Great article. Works like a charm.
July 23rd, 2008 at 11:52 pm
Finally… a guide that actually helped. Thank you very much!
July 30th, 2008 at 9:28 pm
Thank you a lot! that was really helpful!
One thing I would add is that you can double click the bridge connection once created to know the correct gateway IP, because I was under a DHCP and the server gave me one free in the moment.
August 13th, 2008 at 3:19 am
Thanks. Thats what I was looking for.
September 23rd, 2008 at 2:50 pm
John thanks a lot man, ur comment helped me
October 29th, 2008 at 12:36 pm
When I do the bridge, then my wifi connection is lost,
and can not be repaired..nor can the bridge be repaired..and will no longer connect to the wifi network..
when I remove the bridge, the wifi connection resumes..
maybe I don’t understand command 4
4. Change the Attached to option to Host Interface. Choose your new host interface in the Interface name option.
could be more explicit on this…
I don’t see where this is done..?
I am running vb 2.04
thanks for any help..
Kent
December 5th, 2008 at 10:25 pm
Another thank you. This should be @ the top when googling “virtualbox connect host to guest” it would save a lot of time.
January 11th, 2009 at 11:30 pm
VirtualBox networking is much easier to setup if you are using version 2.1. The only thing I have needed to do to get networking support was to set my guest systems to use a Host Interface. No bridge (manual) required.