# [Solved]VirtualBox - Looking for howto on host Network

## lyallp

My VirtualBox works fine with NAT, but I would prefer it to use the Host interface.

Can someone point me to a howto on

1. Creating the device that VirtualBox uses

2. The commands I put in the VirtualBox config panel.

I am using virtualbox-ose version 2.0.6

I have found http://en.gentoo-wiki.com/wiki/VirtualBox#Bridged and was wondering if anyone else has used this or has any experiences with using Host based networking in VirtaualBox?

Thanks in advance

----------

## cwr

I added a bridge device named br0, and gave it the original address of eth0.

Then adding eth0 and vbox0 to the bridge gave me host addressing.  (The

actual device VirtualBox sees is vbox0).

eth0 is set up in net.eth0, without an address, and in the default runlevel,

but br0 is just set up in /etc/conf.d/net (you need to emerge bridge-utils)

and configured in the conf.d/net/postup function, with

  if [ ${IFACE} ] == "br0" ]

  then

  VBoxAddIF vbox0 cwr br0

  fi

Will

----------

## DeadMonkey

I had this working well when I was using versions previous to 2.1.2.  Now that I'm running 2.1.2 I simply need to select "eth0" as the host interface and make sure that "vboxnetflt" is running.  May wan to consider upgrading for ease of use!

But if not, as mentioned earlier you need to have bridge-utils installed, and follow the gentoo-wiki guide you mentioned earlier.

Here's a copy of my net conf that worked for me.  It will create the adapters on boot or restart as needed:

```

### for every VM created in virtualbox a new interface

### needs to be created (ie vboxX).  This will be bridged

### to eth0 through br0

config_eth0=( "null" )

tuntap_vbox0="tap"

tuntap_vbox1="tap"

tunctl_vbox0="-u <your username>"

tunctl_vbox1="-u <your username>"

config_vbox0=( "null" )

config_vbox1=( "null" )

config_br0=( "<ipaddress> netmask <netmask>" )

routes_br0=( "default via <gatewayrouter>" )

dns_servers_br0=( "<dnsserver>" )

bridge_br0="eth0 vbox0 vbox1"

depend_br0()

{

       need net.eth0

       need net.vbox0

       need net.vbox1

}

brctl_br0=( "setfd 0" )

```

As you can see, everything will run through br0.  

When you set up your VBox guest, you will put either "vbox0" or "vbox1", etc. as your host interface.

You will need to do:

```

ln -s /etc/init.d/net.lo /etc/init.d/net.br0

ln -s /etc/init.d/net.lo /etc/init.d/net.vbox1

...etc for all vboxX instances, and

rc-update add net.br0 default

rc-update del net.eth0 default (as br0 will bring it up for you)

```

For Vbox, I think you only need to put in the Network section of your guest:

```

adpater type: whatever, some don't care but some work better with the intel interface?

attached to: Host Interface

MAC Address: something unique

Host Interfaces: vboxX where "X" is your adapter you created.

```

Make sure all your virtualbox modules are loaded as well, plus all modules needed for bridging mentioned in the guide you looked at.

Hope that helps.

J.R.Last edited by DeadMonkey on Sun Feb 15, 2009 5:16 am; edited 1 time in total

----------

## lyallp

Ok, so if I use VirtualBox 2.1.2, I have much less configuration to do. That sounds good.

Problem is, VB 2.1.2 is not in portage, I am using the latest ~x86 Virtualbox-ose, of 2.0.6

I prefer to build my own from source, rather than going with the Closed source version, I feel that the CPU optimisations that occur in my system make a difference - whether they do or not, is another question.  :Smile: 

I think I will wait, rather than go through the pain of the network configuration - using the Host interface is only a nice to have, not a requirement.

Thanks for your help.

----------

## DeadMonkey

Looks harder than it really is... 

And as far as being in portage, if you use the Gentoo overlays at all, just add "jokey" and the ebuilds are there.

I also kept a small section commented out in /etc/conf.d/net that had my regular eth0 setting so I could go back if needed. 

Give it a try!   :Very Happy: 

JR

----------

## lyallp

It's harder than it looks.

The Virtualbox-modules 2.1.2 fails to build with a very similar message to svgalib, which I am also having problems building.

I am betting if I resolve this issue, I will resolve my outstanding issue with svgalib.

```
make KBUILD_VERBOSE= -C /usr/src/linux SUBDIRS=/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv SRCROOT=/tmp/portage/a

pp-emulation/virtualbox-modules-2.1.2/work/vboxdrv modules

make[2]: Entering directory `/usr/local/src/linux-2.6.27-gentoo-r8'

  CC [M]  /tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/linux/SUPDrv-linux.o

  CC [M]  /tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/SUPDrv.o

/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/linux/SUPDrv-linux.c:1: error: code model 'kernel' not supported in t

he 32 bit mode

/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/linux/SUPDrv-linux.c:1: sorry, unimplemented: 64-bit mode not compile

d in

  CC [M]  /tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/r0drv/alloc-r0drv.o

make[3]: *** [/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/linux/SUPDrv-linux.o] Error 1

make[3]: *** Waiting for unfinished jobs....

/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/r0drv/alloc-r0drv.c:1: error: code model 'kernel' not supported in th

e 32 bit mode

/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/r0drv/alloc-r0drv.c:1: sorry, unimplemented: 64-bit mode not compiled

 in

/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/SUPDrv.c:1: error: code model 'kernel' not supported in the 32 bit mo

de

/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/SUPDrv.c:1: sorry, unimplemented: 64-bit mode not compiled in

make[3]: *** [/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/SUPDrv.o] Error 1

make[3]: *** [/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv/r0drv/alloc-r0drv.o] Error 1

make[2]: *** [_module_/tmp/portage/app-emulation/virtualbox-modules-2.1.2/work/vboxdrv] Error 2

```

----------

## cwr

I use VirtualBox 0SE 2.06, and bridging works fine; it's pretty easy to set up.

Will

----------

## Balancer

For quite some time now at me it has ceased to be started VirtualBox with the following error. 

```

Failed to open/create the internal network 'HostInterfaceNetworking-vbox0' (VERR_SUPDRV_COMPONENT_NOT_FOUND).

Unknown error creating VM (VERR_SUPDRV_COMPONENT_NOT_FOUND).

Код ошибки: 

NS_ERROR_FAILURE (0x80004005)

Компонент: 

Console

Интерфейс: 

IConsole {e3c6d4a1-a935-47ca-b16d-f9e9c496e53e}

```

My configuration:

/etc/conf.d/net:

```

config_eth2=( "null" )

tuntap_vbox0="tap"

config_vbox0=( "null")

tunctl_vbox0="-u balancer"

config_br0=("192.168.1.73/24")

routes_br0=( "default via 192.168.1.1" )

bridge_br0="eth2 vbox0"

depend_br0()

{

         need net.eth2

         need net.vbox0

}

brctl_br0=( "setfd 0")

```

ifconfig

```

# ifconfig

br0       Link encap:Ethernet  HWaddr 00:21:85:15:42:95  

          inet addr:192.168.1.73  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:699689 errors:0 dropped:0 overruns:0 frame:0

          TX packets:656514 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:351939070 (335.6 MiB)  TX bytes:139748833 (133.2 MiB)

eth2      Link encap:Ethernet  HWaddr 00:21:85:15:42:95  

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:708006 errors:0 dropped:0 overruns:0 frame:0

          TX packets:656514 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:362233736 (345.4 MiB)  TX bytes:139768575 (133.2 MiB)

          Interrupt:17 Base address:0xc000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:2302 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2302 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:143008 (139.6 KiB)  TX bytes:143008 (139.6 KiB)

vbox0     Link encap:Ethernet  HWaddr ea:81:c1:6e:df:a9  

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:9670 overruns:0 carrier:0

          collisions:0 txqueuelen:500 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

```

Earlier all worked perfectly.

Somebody will prompt where to search for an error?

----------

## DeadMonkey

 *Quote:*   

> 
> 
> It's harder than it looks. 
> 
> 

 

Damn, I guess so!  Sorry can't help with the errors, but can you get host interface working with the current version yet?

Balancer,

Does this help at all?   http://forums.virtualbox.org/viewtopic.php?p=52549&highlight=&sid=9524a2e0692223f4c7962bf46ae627db

----------

## cwr

On VirtualBox-OSE 2.06 I added the following lines to /etc/conf.d/net,

after emerging bridge utils:

config_eth0=( "null" )

bridge_add_eth0="br0"

config_br0=( "192.168.0.2" )

RC_NEED_br0="net.eth0"

brctl_br0=( "setfd 0" "sethello 0" "stp off" )

And in function postup()

if [ ${IFACE} == "br0" ]

then

VBoxAddIF vbox0 cwr br0

fi

This was on top of an otherwise standard configuration, which used

a static address for eth0.  The system works in exactly the same way,

whether VirtualBox is running or not; the VirtualBox clients can see

both Samba shares  and printers on other machines, including the host.

Hope this helps - Will

----------

## lyallp

I have sorted VirtualBox 2.0.6 to use Host based networking.

My Cisco VPN Client, inside my Windows XP Pro VM,

 now connects successfully to the outside world!

My /etc/conf.d/net file contains

```
config_eth2=( "null" )

tuntap_vbox0="tap"

tuntap_vbox1="tap"

tunctl_vbox0="-u root"

tunctl_vbox1="-u root"

config_vbox0=( "null" )

config_vbox1=( "null" )

config_br0=( "dhcp" )

routes_br0=( "default via 192.168.1.254" )

dns_servers_br0=( "192.168.1.254" )

bridge_br0="eth2 vbox0 vbox1"

depend_br0()

{

       need net.eth2

       need net.vbox0

       need net.vbox1

}

brctl_br0=( "setfd 0" ) 

```

I installed  net-misc/bridge-utils version 1.4

I have configured the kernel 2.6.27-gentoo-8, as described in http://en.gentoo-wiki.com/wiki/VirtualBox#Bridged baselayout-1

I added the br0 device to the default runlevel.

I removed eth2 (my old network device) from default runlevel.

udev does not seem to work, but I don't care about that.

Rebooted, just to be totally sure, I could have simply stopped and started the network devices.

VirtualBox VM configuration only required setting to HOST and pointing at the /dev/vbox0 device, no up/down applications.

Works great! Thanks!

Edit.

I have noticed that netstat -i shows packets being dropped.

```
$ netstat -nai

Kernel Interface table

Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg

br0    1500 0    867563      0      0 0       1012733      0      0      0 BMRU

eth2   1500 0    983241      0      0 0       1092479      0      0      0 BMPRU

lo    16436 0     48864      0      0 0         48864      0      0      0 LRU

vbox0  1500 0     70293      0      0 0        110566      0    215      0 BMPRU

vbox1  1500 0         0      0      0 0             0      0   9619      0 BMPRU

```

```
$ ifconfig   

br0       Link encap:Ethernet  HWaddr 00:50:ba:38:9b:bd  

          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::250:baff:fe38:9bbd/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:872930 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1019032 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:110927424 (105.7 MiB)  TX bytes:622785709 (593.9 MiB)

eth2      Link encap:Ethernet  HWaddr 00:50:ba:38:9b:bd  

          inet6 addr: fe80::250:baff:fe38:9bbd/64 Scope:Link

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:988608 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1098781 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:193768006 (184.7 MiB)  TX bytes:635794093 (606.3 MiB)

          Interrupt:21 Base address:0xa000 

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:48865 errors:0 dropped:0 overruns:0 frame:0

          TX packets:48865 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:11295260 (10.7 MiB)  TX bytes:11295260 (10.7 MiB)

vbox0     Link encap:Ethernet  HWaddr ce:e0:5f:76:54:98  

          inet6 addr: fe80::cce0:5fff:fe76:5498/64 Scope:Link

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:70296 errors:0 dropped:0 overruns:0 frame:0

          TX packets:110621 errors:0 dropped:215 overruns:0 carrier:0

          collisions:0 txqueuelen:500 

          RX bytes:11031328 (10.5 MiB)  TX bytes:59001363 (56.2 MiB)

vbox1     Link encap:Ethernet  HWaddr 12:77:6f:9b:88:03  

          inet6 addr: fe80::1077:6fff:fe9b:8803/64 Scope:Link

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:9674 overruns:0 carrier:0

          collisions:0 txqueuelen:500 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

```

```
$ route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     0.0.0.0         255.255.255.0   U     1000   0        0 br0

127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

0.0.0.0         192.168.1.254   0.0.0.0         UG    1000   0        0 br0

```

I was wondering if anyone had any ideas on what these dropped packets are?

----------

## Joseph_sys

Does this guide apply to current: "virtualbox-bin-1.6.6"?

I'm running binary as I need to utilize windows RDP

----------

## lyallp

I am using VirtualBox-ose 2.0.6

I am pretty sure it would also apply to earlier  versions.

Later versions, apparently, don't require this guide - it works from the VirtualBox UI

----------

## Joseph_sys

 *lyallp wrote:*   

> I am using VirtualBox-ose 2.0.6
> 
> I am pretty sure it would also apply to earlier  versions.
> 
> Later versions, apparently, don't require this guide - it works from the VirtualBox UI

 

Do you have VRDP in ose-2.0.6 or RDP protocol is only part of binary?

----------

## lyallp

VRDP is not in OSE version, or at least, not in my build, I will check the use flags.

However, if you have Windows as the Client OS, you can remote desktop into it.

You only really need VRDP if the guest OS does not support some form of remote desktop capability.

----------

