Create a bridge interface in the host to use it in VirtualBox

To have a host ip inside your VirtualBox guest OS, you must create it a tap interface in the HOST OS, i wrote two scripts
to create the needed interface, and to remove it (tapstart.ksh/tapstop.ksh)
These scripts are made for Slackware 12(the host os), since it has no config files for tap/tun/bridge interfaces
in /etc afaik.
TAPSTART.KSH:
#!/bin/ksh
## The real interface, this should already have an ip, in this case it is
## a static ip
REAL=eth1
REALIP=172.16.1.88
NETMASK=255.255.0.0
GATEWAY=172.16.0.1
## The bridge interface, this will have the REALIP once all is setup
BRIDGE=br0
## The tap interface, we’ll use this device inside VirtualBox
TAP=tap0
mkdir /dev/net
mknod /dev/net/tun c 10 200
groupadd umlnetwork
chgrp umlnetwork /dev/net/tun
chmod g+rw /dev/net/tun
modprobe tun
brctl addbr $BRIDGE
ifconfig $REAL 0.0.0.0 promisc up
brctl addif $BRIDGE $REAL
tunctl -t $TAP -u root
brctl addif $BRIDGE $TAP
ifconfig $TAP up
ifconfig $BRIDGE inet $REALIP netmask $NETMASK
route add default gw $GATEWAY $BRIDGE
chmod 0666 /dev/net/tun
TAPSTOP.KSH:
#!/bin/ksh
## the tap,bridge and real interface as configured in tapstart.ksh
TAP=tap0
BRIDGE=br0
REAL=eth1
REALIP=172.16.1.88
NETMASK=255.255.0.0
ifconfig $TAP down
101/433
tunctl -d $TAP
ifconfig $BRIDGE down
brctl delbr $BRIDGE
ifconfig eth1 inet $REALIP netmask $NETMASK up
Now all we have to do in virtual box is select “host” networking, use “tap0″ as the interface and use
‘tapstart.ksh” and “tapstop.ksh” as the networking start/stop scripts.
Your Guest OS’s nic can be configured to use dhcp, for instance, and will get an address from your LAN’s
dhcp server.
102/433

Leave a Reply

Your email address will not be published. Required fields are marked *