Setup A Bridge For VirtualBox

First You just need to load the “vboxnetflt” modules if it isn’t loaded yet, and adjust the networking type in the VirtualBox Guest Network Settings to Attach to “Host Interface”.

sudo modprobe vboxnetflt


And then install bridge-utils to be able to create network bridges:


sudo apt-get install bridge-utils


Before you begin, back up the current interfaces file with a copy that has the current date in its name:


sudo cp /etc/network/interfaces /etc/network/interfaces.`date +%F~%T`


You have to edit /etc/network/interfaces on the hostmachine to declare the bridge, this procedure is slightly different if your host use static or dynamic IP. If you have dynamic IP, on the host machine:


sudo vim /etc/network/interfaces


and then fill with this entry:

auto br0
iface br0 inet dhcp
bridge_ports eth0

# The loopback network interface
auto lo
iface lo inet loopback

note:
“eth0″ is the name of your interface, it can be different depending on your machine.
“br0″ is an arbitrary name for the bridge.
If you are using static IP addresses modify the interfaces like this:

sudo vim /etc/network/interfaces

and then fill this entry:

auto br0
iface br0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
bridge_ports eth0

# The loopback network interface
auto lo
iface lo inet loopback

note:

Replace 192.168.0.100 with your IP, 255.255.255.0 with your netmask and 192.168.0.1 with your gateway. If you are using static IP addresses for eth0, eth1, etc; you will need to configure the br0 interface using the same settings! Otherwise your system will request an IP address via DHCP. You may add as many vbox# interfaces as you wish as long as they are also declared in /etc/vbox/interfaces; keep reading for details.

And then used this command :

sudo brctl addif br0 eth0


When you type command “brctl show” it must shown like this :


sudo brctl show

bridge name             bridge id                STP enabled    interfaces

br0                    8000.0016d4db8cb9          no                       eth0

pan0                8000.000000000000           no

Restart your network :


sudo /etc/init.d/networking restart


And the last see your network configuration with “ifconfig” if you see your network configuration like this:


sudo ifconfig

br0    Link encap:Ethernet  HWaddr 00:16:d4:db:8c:b9

inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0

inet6 addr: fe80::216:d4ff:fedb:8cb9/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

collisions:0 txqueuelen:0

RX bytes:1730 (1.7 KB)  TX bytes:4568 (4.5 KB)
eth0      Link encap:Ethernet  HWaddr 00:16:d4:db:8c:b9

inet6 addr: fe80::216:d4ff:fedb:8cb9/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

collisions:0 txqueuelen:1000

RX bytes:2181 (2.1 KB)  TX bytes:4744 (4.7 KB)

Interrupt:17
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:80 errors:0 dropped:0 overruns:0 frame:0

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

collisions:0 txqueuelen:0

RX bytes:6537 (6.5 KB)  TX bytes:6537 (6.5 KB)
it mean that you did it. Now unpluged your network try to ping to your IP Virtual server from your host, it should be reply.

6 Responses to “Setup A Bridge For VirtualBox”

  1. bizmari Says:

    I want to quote your post in my blog. It can?
    And you et an account on Twitter?

  2. admin Says:

    sure you can….

  3. Dionna Tauteoli Says:

    This is a nice blog, Going On.

  4. Thu Mcelhattan Says:

    In searching for sites related to web hosting and specifically comparison hosting linux plan web, your site came up.

  5. Seasons Says:

    You you should make changes to the webpage name title Setup A Bridge For VirtualBox | harddian.com to something more catching for your subject you make. I loved the post withal.

  6. Eyelet Curtains Says:

    :`: I am very thankful to this topic because it really gives useful information ;::

Leave a Reply

Security Code:

This entry was posted on Monday, August 31st, 2009 at 11:00 am and is filed under Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.