LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   VirtualBox networking does not work with Host Interface (http://www.linuxquestions.org/questions/linux-networking-3/virtualbox-networking-does-not-work-with-host-interface-649265/)

bps7j 06-14-2008 12:00 PM

VirtualBox networking does not work with Host Interface
 
I've installed Ubuntu Hardy Heron 8.04 on my laptop, which uses a wireless network, and then installed VirtualBox. I want to set up a virtual machine for development, etc etc. So I set up CentOS 5.1. Installation went fine, but upon booting, it gives the error when trying to start the network:

Bringing up interface eth0: Error, some other host already uses address 192.168.1.99

Let me tell you how I created the networking for this machine. I followed the instructions given at https://help.ubuntu.com/community/VirtualBox to set up parprouted as per the "Wireless Networking" instructions:

Code:

apt-get install parprouted
cat > /etc/network/if-up.d/vbox_network << EOF
#!/bin/bash
sysctl net.ipv4.ip_forward=1
VBoxTunctl -b -u bps7j
ip link set tap0 up
ip addr add 192.168.1.99/24 dev tap0
parprouted wlan0 tap0
EOF
chmod 700 /etc/network/if-up.d/vbox_network
/etc/network/if-up.d/vbox_network

(The user I'm running the virtual machine as is 'bps7j').

This creates a network device called tap0, which I can ping from my laptop, etc etc. Then in the VirtualBox network settings, I selected Host Interface and typed in tap0.

I read around on some of the forums and in Google, and found http://www.linuxquestions.org/questi...xxxxxx-554768/ and http://www.linuxquestions.org/questi...xx.xxx-187162/ which seem to be addressing similar-but-different issues, and didn't give me any hints.

Anyway, I thought OK, what might be happening. I'm pretty much a networking novice. But I did an arping from within the virtual machine, to check whether the IP address was already in use:

Code:

arping -c 2 -w 3 -D -I eth0 192.168.1.99
ARPING 192.168.1.99 from 0.0.0.0 eth0
Unicast reply from 192.168.1.99 [00:FF:C8:8A:04:DB] 1.162ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

There is no other physical machine on my network with that IP address, by the way; my router's DHCP starts at 192.168.1.100. (This is a home network.)

Hmmm. OK, so what if I try to set the device up manually? My wireless router is 192.168.1.1.

Code:

ifconfig eth0 192.168.1.99 netmask 255.255.255.0 up
route add default gw 192.168.1.1
ping 192.168.1.1

It never gets a reply. I can't ping the outside world either (like a Google IP address.) I can't wget or otherwise communicate with the outside world. ifconfig shows what appears to be a correctly set up device -- it just never gets any reply from the outside.

I read a little more about all this, and added the following line to my network start script as suggested here http://home.nyc.rr.com/computertaiju...oxbridge.html:

Code:

route add -net 192.168.1.0 netmask 255.255.255.0 tap0
Still no dice. I tried rebooting my host machine. No luck.

Looks like for whatever reason, the little parprouted sleight-of-hand isn't working for this virtual machine the way it ought to be. Any ideas? Remember I don't know much about networking, so if you have any suggestions for me I would appreciate if you can help me understand all the steps I'll have to take.

aus9 06-15-2008 05:29 AM

I would suggest you download the pdf documentation off www.virtualbox.org

it goes into a number of scenarios including bridge

2) but why not think virtual?

pretend your vm is called centos
click on settings click on network

add a network card....its virtual intelpro is the easy one

what you get on boot up of the vm...is a virtual ethernet card that your host thinks is a real card so you can talk between the 2 machines host to vm

3) I have done something very similar on a diffent distro vm to get net access....it saves mucking about adding bridge tools etc

Clemente 06-15-2008 05:50 AM

Hi bps7j,

don't know, how to get your attempt finally working, but here is the way, I painlessly got my vbox working fine. But first: If you did not find until now, there is a nice manual for VirtualBox: get it here.

I'm writing out of my memory, so please excuse, if I miss a command parameter. Everything should be verifyable with the manual.

What I did was:

1) setting up a virtual bridge,
2) plugging my physical network adapter into this bridge
3) creating a virtual adapter for my vmachine and plug it into the bridge
4) making everything persistent

You need to have installed (synaptic or apt-get): bridge-utils

1) as root, run on console: brctl addbr br0
2) as root, run on console: brctl addif eth0
3) as root, run on console: VBoxAddIF vbox0 <user_name> br0
4) edit /etc/network/interfaces as follows:

leave your physical adapter (e.g. eth0) as it is! For your bridge, add:
Code:

auto br0 
iface br0 inet static
address <unused_ip> # e.g. 192.168.1.5
netmask 255.255.255.0
gateway <your_gateway> # e.g. 192.168.1.1
bridge_ports <your_physical_device> # e.g. eth0

Or, if you prefer DHCP:
Code:

auto br0 
iface br0 inet dhcp
bridge_ports <your_physical_device> # e.g. eth0

If I remember correctly, everything should be fine, now. You can use vbox0 as hostinterface for your virtual machine.

Some caveats:
- It is said, that you don't have to set an owning usr in step 3), but a group - as vboxusers. This did not work here. I did not spent much time to discover why.
- I am not 100% sure, but I strongly believe, that it is enough to do steps 3) and 4). If I am right, steps 1) and 2) are needed to get virtual networking up and running on a running systen. If booting up your host machint, step 4) makes your system to set up a new bridge and to plug the physical device into the bridge. As said, I am not 100% sure.


All times are GMT -5. The time now is 01:15 PM.