Page 1 of 1

step-by-step guide for HIF setup

Posted: 12. May 2008, 08:49
by fbusse
Being still a newbie to VB, I'm caught already. On a standard Ubuntu (gutsy), installing both the non-free VB from the repo on virtualbox.org, setting up, installing and running an XP guest worked like a charm. (Only getting rid of the missing USB support took me a while because the necessary information was split here and there.) - Thanks a lot to the team for this great piece of work!

But as you may imagine from the subject line the above still isn't the main aspect of my request... :wink:

I would like an XP guest to have a specific network IP - and I didn't manage to set up the system accordingly. Yes, I've read through the manual and I got an idea that it might work installing host interface networking (HIF). But I'm not sufficiently used to network configuration and concepts to get it to work.

However, this should be sort of an FAQ: Isn't there a step-by-step guide for setting up HIF, somewhere around? Or would anybody around be kind enough to advise on the steps to perform both on the (Ubuntu) host and on the (XP) guest in order to assign a specific network address to the guest?

Thx for your thoughts, Frank

Posted: 12. May 2008, 12:26
by bmwiedemann
Be sure to read section 6.5 and 6.7 of the UserManual.pdf - especially 6.7.1.1 for you.

There are several problems that would prevent a short answer.
a) it depends on the distribution where you put your permanent setup
b) this is not specific to VirtualBox but also to Xen, UML and even non-virtual machines attached to a real second ethernet port
c) there are such answers and guides already (e.g. http://tldp.org/HOWTO/BRIDGE-STP-HOWTO/index.html )
d) There are several ways to integrate your virtual network into the real network.
- bridging (that makes the VM look like attached to your switch)
- using routing (possibly with proxy ARP)
- NAT/port forwarding

Posted: 12. May 2008, 19:25
by fbusse
bmwiedemann:

Thx for caring!
bmwiedemann wrote:Be sure to read section 6.5 and 6.7 of the UserManual.pdf - especially 6.7.1.1 for you.
I may assume you are quoting to the manual for current VB v1.60: Unfortunately, I'm still sticking to VB v1.5.6, as offered for my system from the repo at virtualbox.org. But the quoted chapters at a first glance seem to be unchanged with respect to chapters "6.3. Introduction to Host Interface Networking (HIF)" and "6.5. Host Interface Networking and bridging on Linux hosts" from the integrated manual of v1.5.6., to which I will refer in the following.

In the meantime, I've tried the steps from "6.5. Host Interface Networking and bridging on Linux hosts", slightly adopted to my needs:
  • 1. sudo apt-get install bridge-utils
    2. sudo vim /etc/network/interfaces (where the static IP definitely was not in use in the network):

    Code: Select all

    auto br0
    iface br0 inet static
        address 192.168.120.252
        netmask 255.255.255.0
        gateway 192.168.120.210
        bridge_ports eth0
    3. sudo /etc/init.d/networking restart
    4. sudo VBoxAddIF vbox0 frank br0 (which took about 10 minutes to complete, but with no error or even problem indicating message)
    5. VBoxManage modifyvm "Test" -hostifdev1 vbox0 (failed)
After restart of the host, the boot process hung in configuring the network. Only after removing both br0 and vbox0, the host managed to connect to network, again. Most obviously, I have made some silly error, havn't I? I'm really sorry to state that this step-by-step guide is not for newbies.
bmwiedemann wrote:There are several problems that would prevent a short answer.
In fact, a short answer was not exactly what I had expected... :wink:
bmwiedemann wrote:a) it depends on the distribution where you put your permanent setup
Do I assume right that you refer to the host system? As previously mentioned I'm using Ubuntu (Gutsy). Problem (a) solved?
bmwiedemann wrote:b) this is not specific to VirtualBox but also to Xen, UML and even non-virtual machines attached to a real second ethernet port
Ah. But my question only referred to VB. Problem (b) solved?
bmwiedemann wrote:c) there are such answers and guides already (e.g. http://tldp.org/HOWTO/BRIDGE-STP-HOWTO/index.html )
This document definitely is not for newbies, either. (And the "STP" in the title does not mean "step-by-step", but refers to the "Spanning Tree Protocol".) Problem (c) solved? Or what exactly did you expect me to learn from it?
bmwiedemann wrote:d) There are several ways to integrate your virtual network into the real network.
- bridging (that makes the VM look like attached to your switch)
- using routing (possibly with proxy ARP)
- NAT/port forwarding
As previously mentioned, I would like some step-by-step guide for host interface networking, i.e. bridging. Problem (d) solved?

Frank

Posted: 12. May 2008, 20:52
by bmwiedemann
Frank,

did you remove/uncomment the eth0 section in step 2? You should do so because eth0 is now part of the bridge br0

The real problem appears to be in step 4. you can try replacing it with
sudo VBoxTunctl -t vbox0 -u frank
sudo brctl addif br0 vbox0
and maybe
sudo ifconfig vbox0 up

(which will only be in effect until the next reboot of the system)
make sure that your linux username is indeed "frank" - e.g. by calling "whoami"

for further debugging, you might find errors in
sudo tail -20 /var/log/syslog


As for the other mentioned problems:
a) I am on openSUSE 10.3 and can not test on ubuntu.
d) the "host interface" method allows all three mentioned ways to integrate into your network, but we will talk about bridging the virtual ethernet to your real LAN here.


Ciao
Bernhard M.

Posted: 13. May 2008, 00:13
by fbusse
Bernhard:

Thx again!
bmwiedemann wrote:did you remove/uncomment the eth0 section in step 2? You should do so because eth0 is now part of the bridge br0
Beg your pardon? My current /etc/network/interfaces reads...

Code: Select all

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

iface eth0 inet static
address 192.168.120.212
netmask 255.255.255.0
gateway 192.168.120.210

auto eth0
What exactly should be commented out? And why?
bmwiedemann wrote:The real problem appears to be in step 4.
Thus the real problem appears to be in using VBoxAddIF, in your opinion? Why so? Has it previously proven to be source of error?

Frank

Posted: 13. May 2008, 12:16
by bmwiedemann
fbusse wrote:Bernhard:

Thx again!
bmwiedemann wrote:did you remove/uncomment the eth0 section in step 2? You should do so because eth0 is now part of the bridge br0
Beg your pardon? My current /etc/network/interfaces reads...

Code: Select all

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

iface eth0 inet static
address 192.168.120.212
netmask 255.255.255.0
gateway 192.168.120.210

auto eth0
What exactly should be commented out? And why?

bmwiedemann wrote:The real problem appears to be in step 4.
Thus the real problem appears to be in using VBoxAddIF, in your opinion? Why so? Has it previously proven to be source of error?

Frank
Frank,
I had assumed that the step 2 you quoted was already done. I read the code of VBoxAddIF and it looked OK to me.

for your setup you would edit your file "/etc/network/interfaces" in step 2.
if you dont know how to edit files with "vim" you can do
2. sudo nano /etc/network/interfaces

Code: Select all

iface lo inet loopback
    address 127.0.0.1
    netmask 255.0.0.0

auto br0
iface br0 inet static
    address 192.168.120.212
    netmask 255.255.255.0
    gateway 192.168.120.210
    bridge_ports eth0
Note the missing eth0 section in the above file as br0 replaces eth0 and note how br0 receives the IP that was assigned to eth0 before.

When you are done with that, you go through steps 3 to 5.
Testing network connectivity on the host (after step 3) is a good idea, too.
e.g. just ping 192.168.120.210

Ciao
Bernhard M.

Posted: 13. May 2008, 20:34
by fbusse
Bernhard:

Thx again!

Step 2 done, (heavily) deviating from the manual. /etc/network/interfaces now reads...

Code: Select all

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

# auto eth0
# iface eth0 inet static
# address 192.168.120.213
# netmask 255.255.255.0
# gateway 192.168.120.210

auto br0
iface br0 inet static
address 192.168.120.213
netmask 255.255.255.0
gateway 192.168.120.210
bridge_ports eth0
Step 3 (console: "sudo /etc/init.d/networking restart") done:

Code: Select all

* Reconfiguring network interfaces...
Ignoring unknown interface eth0=eth0.

Waiting for br0 to get ready (MAXWAIT is 32 seconds).
Seems like something's missing about eth0. Any problem with this?

Step 4 (console: "sudo VBoxAddIF vbox0 frank br0") done:

Code: Select all

VirtualBox host networking interface creation utility, version 1.5.6
(C) 2005-2007 innotek GmbH
All rights reserved.

Creating the permanent host networking interface "vbox0" for user frank.
Step 5 (console: "VBoxManage modifyvm "Temp" -hostifdev1 vbox0") done:

Code: Select all

VirtualBox Command Line Management Interface Version 1.5.6
(C) 2005-2008 innotek GmbH
All rights reserved.
No visible effect for network settings of "Temp" in the VB main window: Ethernet card 0 remains connected to NAT, ethernet card 1 to an internal network.

After changing (via VB main window) to connection to host interface and name of the interface "vbox0" and manually setting (in the XP network settings) the IP of the guest to 192.168.120.252 (being the desired IP for the guest, as mentioned above), the same gets connected to the network. Wow! The guest is even ping'able at this IP. However, it seems not to be recognized at this IP by our firewall: The firewall settings seem to be the same as for the IP set for br0 (192.168.120.213).

Furthermore, this local modification seems to have severe influence on performance throughout our network: The other machines fail to get any connection until I revert to the original /etc/network/interfaces.

I'm really sorry, but this method of system level network configuration may be perfect for geeks, but is merely unusable for simple users. (Network configuration in VMware might serve as an example for a usable - yet maybe not as flexible - tool.)

a propos "simple user": I have been used to vi/vim for about 15 years. But thx for caring... :wink:

Posted: 13. May 2008, 22:38
by bmwiedemann
Frank,

I think we are getting close to the solution.
Please note that the file /etc/network/interfaces is specific to Debian and Ubuntu, so (as mentioned earlier) I'm not an expert on it.

Meanwhile I took my Debian-based router at home to try the bridge setup. Can you try this little change (un-comment the iface eth0 line)

Code: Select all

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

# auto eth0
iface eth0 inet static
# address 192.168.120.213
# netmask 255.255.255.0
# gateway 192.168.120.210

auto br0
iface br0 inet static
address 192.168.120.213
netmask 255.255.255.0
gateway 192.168.120.210
bridge_ports eth0
and re-do step 3 afterwards


About your firewall I dont really know. Might be that the above already helps with your problems. Is it the linux firewall? (check with 'iptables -L -n') or an external firewall machine? You could try to temporarily disable the firewall to test if that helps.

Another thing that I keep forgetting in such setups is to turn your machine into a router.
try
cat /proc/sys/net/ipv4/ip_forward
if that outputs a "0" you might need to
echo 1 > /proc/sys/net/ipv4/ip_forward


Another possible source of problems might be the delays caused by bridge mode. I used brctl setfd br0 2 to set the timeout to two seconds (from 15 or 30 seconds default value)


I agree to your assessment that this kind of setup is not simple to do. First step in development is always to make it possible, second one to make it stable... and only the next one to make it easy. Bridge setup should be part of the operating system. I read in this forum that openSUSE 11.0 will integrate it nicely, so maybe a later ubuntu release will do that as well.


Ciao
Bernhard M.

Posted: 14. May 2008, 01:21
by alskor
I want to add my comment -
step-by-step tutorial for Host interface networking REALLY needs improvement.
I need to use static IP addresses for both Host OS (Ubuntu server) and several guest OS (Ubuntu as well) and I spent several days trying all possible variants described on internet.

the tutorial only shows the simplest variant with DHCP and does not say a word about using static IP for linux guests.

I finally managed to hardcode IP-addresses right inside guest OS-es themselves (in their /etc/network/interfaces files), but it's not a good solution as I can't easily duplicate images now.

But what is worse - after upgrading VirtualBox 1.5.6 OSE to VirtualBox 1.6 the network does not work at all for all guet OS-es.

I'm about to give up on VirtualBox :cry:

Posted: 14. May 2008, 06:18
by scottro
I have my own page on it--rather Fedora centric and is mostly geared towards doing it on a case by case basis.

On the other hand, some folks have found it helpful--I put my own commands into a script and do it that way.

http://home.nyc.rr.com/computertaijutsu/vboxbridge.html

I put it up because I felt the docs made it a bit harder to understand than it should be, like far too much Linux documentation. The users guide is quite good--but makes certain assumptions.

For example, were I writing the Fedora section, I would make sure to comment that doing an su to root, or using sudo, won't get /sbin and /usr/sbin in your path. Granted, one could argue that the implication is that you are root, but as I see the problem all the time on Fedora forums, I figure it's worth mentioning. (I even have a page up just explaining how the $PATH variable in Fedora and other RH based distros is different than BSD, Ubuntu and some others. So, when I see the question, now I just post a link to the page.)

Anyway, for what it's worth, I've gotten a few emails from people who found the page helpful, so <shrug>

Posted: 14. May 2008, 07:47
by bmwiedemann
alskor wrote:I want to add my comment -
step-by-step tutorial for Host interface networking REALLY needs improvement.
I need to use static IP addresses for both Host OS (Ubuntu server) and several guest OS (Ubuntu as well) and I spent several days trying all possible variants described on internet.

the tutorial only shows the simplest variant with DHCP and does not say a word about using static IP for linux guests.

I finally managed to hardcode IP-addresses right inside guest OS-es themselves (in their /etc/network/interfaces files), but it's not a good solution as I can't easily duplicate images now.
I think, the alternative to using static IPs is just DHCP. Or you go for IPv6 and install radvd in the network. Or you integrate scripts into your guest that make the IPv4 addr depend on the last byte of your MAC-adresses, so that you can have multiple copies of a VM and assign the IP through the VirtualBox GUI.

e.g. using

Code: Select all

num=`perl -ne 'm/:(..)$/; print hex($1)' /sys/class/net/eth0/address`

Ciao
Bernhard M.

Posted: 15. May 2008, 06:01
by gagarobu
fbusse wrote:
After changing (via VB main window) to connection to host interface and name of the interface "vbox0" and manually setting (in the XP network settings) the IP of the guest to 192.168.120.252 (being the desired IP for the guest, as mentioned above), the same gets connected to the network. Wow! The guest is even ping'able at this IP. However, it seems not to be recognized at this IP by our firewall: The firewall settings seem to be the same as for the IP set for br0 (192.168.120.213).
Here's my VB on laptop (host Ubuntu 8.04)...
firestarter as firewall modifier

ppp0 connected to internet (dial up bluetooth)
eth0 not connected to anything
vbox0 for VB01(guest Ubuntu 7.10)
vbox1 for VB02(guest WindowsXP)
vbox2 for VB03(guest Xubuntu 8.04)

Step1

/etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback
address 127.0.0.1

auto br0
iface br0 inet static
address 192.168.0.2
bridge_ports eth0
Step 2

(console: "sudo /etc/init.d/networking restart") done:

Step 3
(console: "sudo VBoxAddIF vbox0 gagarobu br0") done:
(console: "sudo VBoxAddIF vbox1 gagarobu br0") done:
(console: "sudo VBoxAddIF vbox2 gagarobu br0") done:


Step 4
(console: "VBoxManage modifyvm "VB01" -hostifdev1 vbox0") done:
(console: "VBoxManage modifyvm "VB02" -hostifdev1 vbox1") done:
(console: "VBoxManage modifyvm "VB03" -hostifdev1 vbox2") done:

Step 5
(put 192.168.0.3 on eth0 in VB01") done:
(put 192.168.0.4 on eth0 in VB02") done:
(put 192.168.0.5 on eth0 in VB03") done:

Step 6
(put nameserver 192.168.0.2 on /etc/resolv.conf in VB01") done:
(put nameserver 192.168.0.2 on /etc/resolv.conf in VB02") done:
(put nameserver 192.168.0.2 on /etc/resolv.conf in VB03") done:

Step 7
HOST:
edit file /proc/sys/net/ipv4/ip_forward (sudo nano /proc/sys/net/ipv4/ip_forward), change 0 to 1.

console: "sudo iptables -t nat -A POSTROUTING -j MASQUERADE"
console: "dnsmasq dan ipmasq: sudo apt-get install dnsmasq ipmasq"
console: "/etc/init.d/dnsmasq restart"
console: "dpkg-reconfigure ipmasq"
put net.ipv4.ip_forward = 1 to /etc/sysctl.conf

Step 8
HOST:
(console: "sudo apt-get firestarter") (for firewall setting)

Step 9
HOST:
(firestarter: "internet connected device = dialup device (ppp0)")
(firestarter: "local network connected device = unknown device (br0)")
(firestarter: "allow connection from 192.168.0.3/4/5")


All VB (01 to 03) are able to connect to Internet

Posted: 18. May 2008, 02:59
by thomasjohansen
@gagarobu

Thx for your howto guide on setting up HIF on ubuntu.

Though could you specify step 5 to 7.

let me explain:

step 5, is this done in the guest system?

step 6. dont understand what you are doing here, is this step done in the guest system?

step 7. it wont allow me to edit in ip_forward, and it is empthy?


thx in advange
Thomas