Host Networking on VirtualBox

This is how I got host networking for VirtualBox and have it setup to use bridging on FedoraCore 6 host. This allows for two way traffic between the host and the guest. You will need bridge-utils and uml-utilities.

The first step is to configure the host with a bridge and a tap device. With this only the bridge will get an IP address and not the ethX nor the tapX device.

I am using dhcp to assign the IP addresses so the basic commands on the host are as below and can be put in the rc.local file for it to come up on boot:

# VirtualBox Bridging

# load the tun module
modprobe tun

# Create a tap device with permission for the user running vbox
tunctl -t tap0 -u {user}
chmod 666 /dev/net/tun

# Bring up ethX and tapX in promiscuous mode
ifconfig eth0 0.0.0.0 promisc
ifconfig tap0 0.0.0.0 promisc

# Create a new bridge and add the interfaces to the bridge.
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 tap0

# Give the bridge a dhcp address.
dhclient br0

You should now be able to use host networking in VirtualBox, just change "attached to" to "host interface" and add the interface name of "tap0" in your networking settings for the guest.

Notes:

If you're using a firewall on your host, make sure to turn it off when testing network setup.
I have had success with using APF as firewall which seems compatible with bridging.

References:

  1. VirtualBox
  2. Bridge
  3. uml-utilities
  4. 2.6.6 UML setup

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

May I say thanks

Because of this same issue I stopped using VBox a couple of years ago, now that I need it again I found the same problem but also got your answer working

Thanks!!!

Exactly what I needed

Thanks sandip, I pasted your instructions into a script and it worked perfectly. I wouldn't have figured that out for myself in anything less than a few weeks. I don't have an account here or I'd give you a point. Maybe someone else can do it for me.

Wireless virtualbox networking

I got wireless virtualbox networking on my Ubuntu box using parprouted.

  1. Install paraprouted via.
    # sudo aptitude install parprouted

  2. I then ran the below script to configure my connection on the host:
    #/bin/bash
    #wifibridge.sh
    chown root:vboxusers /dev/net/tun
    tunctl -t tap1 -u <vboxuser>
    ip link set tap1 up
    ip addr add 192.168.2.30 dev tap1
    echo 1 > /proc/sys/net/ipv4/ip_forward
    parprouted eth1 tap1

Note: DHCP is not supported by parprouted. So use static IPs instead on the guest, that is different from the IP of the host.

References:

Comment