How to setup a bridge between a virtual machine with VirtualBox and a Fedora host
Hi everybody, I will try to show you how it's easy to configure your virtual machine to be visible on the network, like another machine.
First, you need to install the bridge-utils packageyum install bridge-utils
Go to /etc/sysconfig/network-scripts/ and create a new file (ifcfg-tap0 for example) :
vi /etc/sysconfig/network-script/ifcfg-tap0
IMPORTANT NOTE : NetworkManager load the scripts files in alphabetical order. If you set the name of your bridge with the first letter is before the first letter of your interface, it will not work ! (br0 connected to eth0 for example). Take care about that !
Put these lines :DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=static #or dhcp, and leave the next IPADDR=192.168.0.10 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 BROADCAST=192.168.0.255
PEERDNS=no TYPE=Ethernet USERCTL=yes IPV6INIT=yes BRIDGE=tap0
su -lc 'service network restart'
VBoxAddIf vbox0 {user} tap0With {user} your current user, br0 the name of your bridge, and vbox0, it's the name of the network you will need to specify in the preferences of VirtualBox, network section. Select Host Network Adaptater, and specify vbox0.
Voilà ! You can launch your virtual machine in bridge mode ! :)
(See : http://forums.fedora-fr.org/viewtopic.php?pid=200600 for more info (in french))
You can have some issues after a reboot, with your virtual machine that cannot connect to the web. If it happens, stop your vm, remove the interface and re-add it to virtualbox (in root mode) and start your vm.
# Command to remove an interface : VBoxDeleteIF vbox0 # And now, we add it: VBoxAddIF vbox0 tap0