Page 1 of 2

HIF Networking - no internet from guests on vbox0, 1

Posted: 19. Jun 2008, 06:45
by prickly
I feel that I am getting somewhere having read the manual more closely and found some helpful forum threads - I still have a problem with my first guest VM.

Host: Ubuntu Hardy Desktop
Guest: Ubuntu JeOS (Converted from VMWare using vditool)

I followed this guide to setup HIF: http://forums.virtualbox.org/viewtopic. ... st+network

Code: Select all

sudo apt-get install bridge-utils
/etc/network/interfaces

Code: Select all

auto lo 
iface lo inet loopback 

auto eth0 
iface eth0 inet manual 
    up ifconfig $IFACE 0.0.0.0 up 
    down ifconfig $IFACE down 

auto br0 
iface br0 inet dhcp 
    bridge_ports eth0
Restarted networking:

Code: Select all

sudo /etc/init.d/networking restart
Added myself to the vbox0 and bro vbox interfaces:

Code: Select all

sudo VBoxAddIF vbox0 <user> br0
Set vbox0 as the interface for my Virtual Machine:

Code: Select all

VBoxManage modifyvm "My VM" -hostifdev1 vbox0
At this point my virtual machine boots without error (for the first time) :)

The problem is that I am not sure how to configure /etc/network/interfaces on the guest as I have messed around with the settings alot already.

I can tell you what is not working, which is what I have right now:

Code: Select all

auto lo
iface lo inet loopback

autho eth0
iface eth0 inet dhcp
When i restart the networking it says:

Code: Select all

eth0: ERROR while getting interface flags: No such device
Bind socket to interface: No such device
Failed to bring up eth0
I also tried vbox0 instead of eth0 above.

Any help is very much appreciated!

Thanks.

Posted: 20. Jun 2008, 04:39
by prickly
I created a new Ubuntu Jeos virtual machine from scratch after creating a new virtual network interface vbox1. I then attached vbox1 to my new virtual machine and booted / installed the operating system and set a static IP address during install as the installer said that DHCP had failed.

IP: 192.168.0.95
Gateway: 192.168.0.1
Subnet 255.255.255.0

Here is the ifconfig for my host:

Code: Select all

br0       Link encap:Ethernet  HWaddr 00:19:66:36:58:86  
          inet addr:192.168.0.106  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::219:66ff:fe36:5886/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:189 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:22592 (22.0 KB)  TX bytes:5001 (4.8 KB)

eth0      Link encap:Ethernet  HWaddr 00:19:66:36:58:86  
          inet6 addr: fe80::219:66ff:fe36:5886/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:634 errors:0 dropped:0 overruns:0 frame:0
          TX packets:257 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:89514 (87.4 KB)  TX bytes:35951 (35.1 KB)
          Interrupt:220 Base address:0xa000 

eth1      Link encap:Ethernet  HWaddr 00:07:e9:0d:64:2d  
          inet addr:192.168.0.35  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::207:e9ff:fe0d:642d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:296915 errors:0 dropped:0 overruns:0 frame:0
          TX packets:286380 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:251576507 (239.9 MB)  TX bytes:171666969 (163.7 MB)
          Base address:0xec00 Memory:dffe0000-e0000000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3042 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3042 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:153020 (149.4 KB)  TX bytes:153020 (149.4 KB)

vbox0     Link encap:Ethernet  HWaddr 00:ff:5e:33:e1:b9  
          inet6 addr: fe80::2ff:5eff:fe33:e1b9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:194 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

vbox1     Link encap:Ethernet  HWaddr 00:ff:6e:e5:df:a2  
          inet6 addr: fe80::2ff:6eff:fee5:dfa2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:180 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:8 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:8892 (8.6 KB)  TX bytes:0 (0.0 B)
On my guest i have lo and eth0 but I cannot ping the default gateway / access the internet.

The setup process is described in the above post - I have just added vbox1 and created a new virtual machine to test the networking.

What additional steps do I need to get this to work?

Many thanks.

Posted: 20. Jun 2008, 04:48
by prickly
This is my sudo /etc/init.d/networking restart if it helps?

Code: Select all

Listening on LPF/br0/00:19:66:36:58:86
Sending on   LPF/br0/00:19:66:36:58:86
Sending on   Socket/fallback
DHCPRELEASE on br0 to 192.168.0.1 port 67

Waiting for br0 to get ready (MAXWAIT is 32 seconds).
There is already a pid file /var/run/dhclient.br0.pid with pid 134519072
Internet Systems Consortium DHCP Client V3.0.6
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/br0/00:19:66:36:58:86
Sending on   LPF/br0/00:19:66:36:58:86
Sending on   Socket/fallback
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 8
DHCPOFFER of 192.168.0.106 from 192.168.0.1
DHCPREQUEST of 192.168.0.106 on br0 to 255.255.255.255 port 67
DHCPACK of 192.168.0.106 from 192.168.0.1
bound to 192.168.0.106 -- renewal in 537949 seconds.
And the output of the route command:

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
192.168.0.0     *               255.255.255.0   U     0      0        0 br0
link-local      *               255.255.0.0     U     1000   0        0 br0
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth1
default         192.168.0.1     0.0.0.0         UG    100    0        0 br0

Posted: 20. Jun 2008, 06:52
by kcnnc
On the guest after bootup issue

ifconfig -a

to see what are the interface available. It is probably that the interface is not configured.
Go to /etc/network/interfaces and add the interface and restart networking

Posted: 20. Jun 2008, 07:38
by prickly
ifconfig -a shows eth0 and lo

/etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.94
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
This configuration looks good to me for a static IP?

Posted: 20. Jun 2008, 08:32
by kcnnc
I assume you also have set /dev/net/tun to the vboxusers group and is writable.

Posted: 20. Jun 2008, 10:35
by Sasquatch
What bothers me is that you have two network interfaces on your Host that have the same IP range and gateway. Why is that? Do you have both NICs connected to the router? Also, check your VM settings in the GUI to see if you set it all correctly and that the 'cable' is connected. DHCP should go through the bridge to your VM, as I have the same setup with Ubuntu Server.

Host Config:

Code: Select all

auto brdg
iface brdg inet dhcp
	bridge_maxwait 0
	bridge_ports lan vbox0 vbox1
	#I set the virtual interfaces here too, but it does not matter
	#because VB adds the vbox iface automatically upon VM start.
There is no need for the eth0 commands, just set it to 'iface eth0 inet manual' like this:

Code: Select all

#auto lan < this is on purpose,
	#no need to auto start it as the bridge does that.
iface lan inet manual
On the Guest, all you need is this:

Code: Select all

auto eth0
iface eth0 inet dhcp
That's it. It should just work now. Just make sure that you disconnect eth1 on the host too, as I have no idea why it is connected to the router too. Unless you use it for load balancing or higher throughput, then you need to add it to the bridge too.

Posted: 21. Jun 2008, 19:24
by prickly
Thanks Sasquatch I will try what you recommend.

As for the two network cards that was just a result of trying to set up my original ubuntu install while extremely tired, the onboard lan did not work because i forgot to enable it in the bios and so I added a spare NIC that I had lying around - only the onboard NIC is connected to the router now. I should probably just removed eth1 as it is not doing anything anyway.

I will let you know how I get on.

Posted: 21. Jun 2008, 19:41
by prickly
kcnnc wrote:I assume you also have set /dev/net/tun to the vboxusers group and is writable.
I don't think that I have done this - since you have mentioned this I have found this on page 75 of the manual:
In order to use Host Interface Networking in VirtualBox, you must have access to the device /dev/net/tun. Check which group this device belongs to and make sure that any users who need access to VirtualBox
Host Networking are members of this group. In most cases, this device will belong to the vboxusers group.
How do I check the permissions for this device and add myself as a user?

Would it be something like this?

Code: Select all

sudo chmod 777 /dev/net/tun

sudo usermod -a -G vboxusers $user

sudo useradd $user vboxusers

Posted: 21. Jun 2008, 20:21
by Sasquatch
First check the permissions with 'ls -l /dev/net' (note, it's a lowercase L). You will see who is the owner and group. It should be root:vboxusers. If you created the vbox interface using the VBoxAddIF command, the permissions should be right. Changing owner/group can be done with chown. Read the man-page or use --help for more info.

Posted: 21. Jun 2008, 20:26
by prickly
Sasquatch wrote:First check the permissions with 'ls -l /dev/net' (note, it's a lowercase L). You will see who is the owner and group. It should be root:vboxusers. If you created the vbox interface using the VBoxAddIF command, the permissions should be right. Changing owner/group can be done with chown. Read the man-page or use --help for more info.
Thanks Sasquatch my permissions look fine:

Code: Select all

crw-rw---- 1 root vboxusers 10, 200 2008-04-22 10:49 tun

Posted: 23. Jun 2008, 07:01
by prickly
Sasquatch, I tried what you suggested and it is not working for me.

Code: Select all

auto lo 
iface lo inet loopback 

auto br0
iface br0 inet dhcp 
   bridge_maxwait 0 
   bridge_ports lan vbox0 vbox1

iface lan inet manual
This is the error that I get:

Code: Select all

lan: ERROR while getting interface flags: No such device
interface lan does not exist!
I tried changing lan to eth0 and that also did not work.

Posted: 23. Jun 2008, 10:53
by Sasquatch
Right, forgot to mention that I change the names of my interfaces. You should change them accordingly to your interface names.
You stated that changing lan to eth0 did not work, do you get the same error?

Posted: 24. Jun 2008, 07:50
by prickly
When i change what you suggested to eth0 this is the response:

Code: Select all

Listening on LPF/br0/00:19:66:36:58:86
Sending on   LPF/br0/00:19:66:36:58:86
Sending on   Socket/fallback
DHCPRELEASE on br0 to 192.168.0.1 port 67
device vbox0 is not a slave of br0
device vbox1 is not a slave of br0
There is already a pid file /var/run/dhclient.br0.pid with pid 134519072
btw I have removed eth1 from the system now also ...

Posted: 24. Jun 2008, 11:58
by Sasquatch
There is nothing wrong with that. It only says that the virtual interfaces are not part of the bridge, probably because they aren't up (not listed in the interfaces file). It should work now, as you don't get any other errors. Eth0 is now part of the bridge, when you start your VM, vbox0/1 (whichever you select for the VM). You can check it using 'brctl show'. It should look something like this:

Code: Select all

sasquatch@Patrick-Laptop:~$ brctl show
bridge name	bridge id		STP enabled	interfaces
brdg		8000.00030d447f69	no		eth0
							vbox0
							vbox1