You are not logged in.

#1 2007-03-12 01:51:48

scrawler
Member
Registered: 2005-06-07
Posts: 318

bridge network with Virtualbox

howdy guys,

I've been playing with virtualbox a little bit, and found the blog of a guy who is using a virtualbox vm as a webserver.

he lists these steps:

tunctl -t tap0 -u user 
;(where user is the user who runs VirtualBox)

chmod 666 /dev/net/tun 
;(or add user running VirtualBox to the 'tun' group, on MDV)

brctl addbr br0

ifconfig eth0 0.0.0.0 promisc 
;(where eth0 is the interface to be bridged)

brctl addif br0 eth0

dhclient br0

brctl addif br0 tap0

ifconfig tap0 192.168.1.50 up 
;(where 192.168.1.50 is an arbitrary unused 
;IP in the same subnet as your local network)

echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp

route add -host 192.168.1.5 dev tap0
;(where 192.168.1.5 is the IP address of the host machine)

arp -Ds 192.168.1.5 eth0 pub
;(where 192.168.1.5 is the IP address of the host machine)

(from http://www.happyassassin.net/2007/02/06 … rtualbox/)

I got brctl from the package "bridge-utils,"
and tunctl from "uml_utilities."

these steps almost work, except I can't use dhclient on br0, and on
the host machine eth0 loses its address.

Can someone give me some hints about how do accomplish this in an arch
way, making use of /etc/conf.d/bridges, and rc.conf, or whatever?  thanks.

Offline

#2 2007-03-15 00:00:33

Tatey
Member
From: Brisbane, Australia
Registered: 2006-04-02
Posts: 66
Website

Re: bridge network with Virtualbox

I'm no bash scripter, but here is what I have in a file I called ".vbtun" in my home directory. I just execute that script when I want to use Virtual Box. It's not elegant, but it works well enough. It's only a solution for a static IP.

sudo tunctl -t tap0 -u <USERNAME>
sudo /usr/sbin/brctl addbr br0
sudo /sbin/ifconfig eth0 0.0.0.0 promisc
sudo /usr/sbin/brctl addif br0 eth0
sudo /sbin/ifconfig br0 <YOUR IP>
sudo /usr/sbin/brctl addif br0 tap0
sudo ifconfig tap0 <TAP IP *I increment +1 from my IP*> up
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
sudo route add -host <YOUR IP> dev tap0
sudo arp -Ds <YOUR IP> eth0 pub
sudo route add default gateway <GATEWAY IP>

In addition, you'll also need to create the appropriate permissions for the /dev/tun node using a udev rule.

/etc/udev/rules.d/00-dev.rules

KERNEL=="tun",          NAME="net/%k" GROUP="virtualbox"

Don't forget to place the tun and vboxdrv modules in your /etc/rc.conf.

Hope any of this helps smile


Check out my website, http://tatey.com

Offline

#3 2007-04-13 19:58:56

scottro
Member
From: NYC
Registered: 2002-10-11
Posts: 466
Website

Re: bridge network with Virtualbox

While this is a month after the original post, I suspect the problem with scrawler's is that you've already brought eth0 down before running dhcpcd on br0.  Unless the host is running dhcpd and acting as server, I don't know how br0 would get an address. (Untested though, for all I know, it works. 

My method is closer to Tatey's (whose script helped me figure it out.

ifconfig br0 192.168.1.79 netmask 255.255.255.0 up
ifconfig eth0 0.0.0.0 down
ifconfig eth0 0.0.0.0 up
route add default gw 192.168.1.1 br0
brctl addif br0 eth0
brctl addif br0 tap0
ifconfig tap0 up

This is giving br0 a static IP.  It seems to need the gateway.
As for bringing eth0 down and up and bringing up tap and bridge--sometimes none of that has been necessary, but it doesn't seem worth wasting the time to see if I'll have to do it or not.

Note that I don't give tap0 an IP address, nor do I do any of the forwarding rules that tatey uses.

This isn't saying my way is better--FWIW I have only gotten this to work on cabled ethernet, it doesn't seem to work on wireless.  At any rate, it's the way I do it, and then, when the virtual machine starts, it gets an address dynamically.

I would stay with Tatey's method of giving br0 an address on the subnet.  It just saves a headache.

Offline

#4 2007-06-09 08:06:01

caved
Member
From: Holland
Registered: 2006-11-14
Posts: 23

Re: bridge network with Virtualbox

Hi guys,
Here is my working startscript for Virtual box, you just have to specify :tap0 in the vbox settings for your vbox.
This is a setup for a STATIC arch setup.

#!/bin/sh

sudo modprobe vboxdrv

sudo tunctl -t tap0 -u <my username>
sudo /usr/sbin/brctl addbr br0
sudo /sbin/ifconfig eth0 0.0.0.0 promisc
sudo /usr/sbin/brctl addif br0 eth0
sudo /sbin/ifconfig br0 <mybox s ip>
sudo /usr/sbin/brctl addif br0 tap0
sudo ifconfig tap0 <NEW tap IP of choise e.g. 192.168.123.151 or something> up
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
sudo route add -host <mybox s ip> dev tap0
sudo arp -Ds <mybox s ip> eth0 pub
sudo route add default gateway <mybox gateway ip>
sudo chmod 0666 /dev/net/tun
exec VirtualBox &
exit

Anyway, hope it works for ya as well as it does for me.
Caved

Offline

#5 2007-06-11 16:35:04

kant1
Member
Registered: 2006-11-28
Posts: 57

Re: bridge network with Virtualbox

Or you can use your rc.conf to configure bridging.  I think this makes for a cleaner setup.

This Virtualbox bridging solution worked great for me:


http://mychael.gotdns.com/blog/2007/05/ … -bridging/

Offline

#6 2007-06-13 16:30:31

insane
Member
Registered: 2006-06-04
Posts: 106

Re: bridge network with Virtualbox

kant1, I tried your method and it worked great. However it introduced a nasty side effect. I could not run openoffice after the changes. I don't know how openoffice is related with network but when I switched back to the old network configuration, openoffice started normally. I switched again to your settings and again I could not run openoffice.

Did you had this problem?

Offline

#7 2007-06-13 19:39:06

kant1
Member
Registered: 2006-11-28
Posts: 57

Re: bridge network with Virtualbox

Hmm, that does sound strange.  I haven't hit that problem.  I'm using this setup on two machines, and it seems to be working great.

I was having some problems opening openoffice recently, but I believe that's because of SCIM, which I use for typing Chinese.  OpenOffice would open and then crash as soon as I tried to use a menu.  Really frustrating.  I was able to fix that by using:

GTK_IM_MODULE=xim soffice

Are you getting any error messages from openoffice?  Have you tried running "soffice" in a terminal and seeing if there's any output?

Offline

#8 2007-06-13 19:57:43

insane
Member
Registered: 2006-06-04
Posts: 106

Re: bridge network with Virtualbox

I don't see any error messages. When I try to run OO graphically it just displays the splash screen and then dies. Running from the terminal it displays again the splash screen but this time it just hangs there. I have to type Ctrl+C to get back the prompt. No error messages or anything. When I run

ps aux |grep office

I can see many processes running with ? (I can't give exact output right now because I reverted back to the old settings).
Also xine was affected too. It started and just froze there. Now that i switched back it works normally.

Maybe there is something in my system that is heavily depended on networking and doesn't like bridging. big_smile

Thank you for your answer smile

Last edited by insane (2007-06-13 19:58:20)

Offline

#9 2007-06-14 16:01:13

kant1
Member
Registered: 2006-11-28
Posts: 57

Re: bridge network with Virtualbox

Boy, I'm really scratching my head on this one.  I can't come up with any reasons that would be happening.  I thought that perhaps you weren't bringing back up your "lo" interface somehow, but I tested bringing it down and I was still able to open openoffice just fine.

Have you tried running "top" and then running openoffice/xine?  Maybe they are using some other program that is getting hung up on the network change?

Also, did you try rebooting after making these changes?

Are you using the same address for the bridge as you are for your regular connection?  Or using dhcp for both?  (The link I posted uses dhcp, but you may need to specify the address if that's what you do for your regular connection)

Does "ifconfig" show that eth0 (or whatever your regular ethernet connection is) does not have an ip address, but br0 does?  Does "brctl show" show that br0 has eth0 attached as an interface?


Sorry for all the questions.  I just really can't figure out why you would be having that problem.  Those are some of the things I would check just to see if I could find anything that looked suspicious.  If anything does look strange, please post; maybe someone with more insight that I will come to the rescue!

Offline

#10 2007-06-16 13:46:52

insane
Member
Registered: 2006-06-04
Posts: 106

Re: bridge network with Virtualbox

Hi kant1. First I want to thank you for taking the time to respond and second I apologize for not posting earlier. I have been away from my computer these 2 days.

Now,  to answer your questions:

Have you tried running "top" and then running openoffice/xine?  Maybe they are using some other program that is getting hung up on the network change?

I don't see anything strange.

Also, did you try rebooting after making these changes?

Yes, more than once

Are you using the same address for the bridge as you are for your regular connection?  Or using dhcp for both?  (The link I posted uses dhcp, but you may need to specify the address if that's what you do for your regular connection)

Does "ifconfig" show that eth0 (or whatever your regular ethernet connection is) does not have an ip address, but br0 does?  Does "brctl show" show that br0 has eth0 attached as an interface?

Here is my ifconfig output. I believe this is how it should be

$ ifconfig
br0       Link encap:Ethernet  HWaddr 00:17:31:83:C2:30
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1394 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1021200 (997.2 Kb)  TX bytes:195531 (190.9 Kb)

eth0      Link encap:Ethernet  HWaddr 00:17:31:83:C2:30
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:1307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1370 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1041405 (1016.9 Kb)  TX bytes:206215 (201.3 Kb)
          Interrupt:18

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:129 errors:0 dropped:0 overruns:0 frame:0
          TX packets:129 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8243 (8.0 Kb)  TX bytes:8243 (8.0 Kb)

and this is "brctl show"

$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.00173183c230       no              eth0

and this is my network section in /etc/rc.conf

lo="lo 127.0.0.1"
BRIDGE_INTERFACES=(br0)
bridge_br0=(eth0)
br0="br0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255" 
eth0="eth0 0.0.0.0 promisc"
#eth0="eth0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255"
INTERFACES=(lo br0 eth0)
#
# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.1.1"
ROUTES=(gateway)

I don't know if it has any relevance but I was trying to see what is happening with wireshark. When I try to run soffice I see DNS queries to my ISP about arch.localdomain. These queries have naturally response "not found". arch is my host name.

UPDATE: After posting this i added this line in /etc/hosts.

127.0.0.1        arch.localdomain    arch

and now openoffice works again big_smile.

But now I have 2 problems less significant

1. Still xine doesn't work. I see a query for eth0.localdomain
2. If I use the "Alt+F2" box in KDE and type i.e. calc it will still query my ISP for calc.localdomain.

Last edited by insane (2007-06-16 14:14:21)

Offline

#11 2007-06-18 15:18:33

kant1
Member
Registered: 2006-11-28
Posts: 57

Re: bridge network with Virtualbox

Good work adding that line to /etc/hosts.  And good wireshark work too.  If i were you, I would add "localhost" to the end of the line you added to /etc/hosts.

ie.

127.0.0.1    arch.localdomain arch localhost

A lot of applications connect to services running locally, and without those lines things start acting funny.

Let me know if that helps out with the xine problem.

Offline

#12 2007-06-18 17:52:35

insane
Member
Registered: 2006-06-04
Posts: 106

Re: bridge network with Virtualbox

My /etc/hosts file now is

127.0.0.1        localhost.localdomain    localhost
127.0.0.1        arch.localdomain         arch    localhost

Still xine doesn't work. Even if I comment the first line. And I still see queries to my ISP for local programs in localdomain. Maybe it is something KDE related.

Offline

#13 2007-06-18 19:32:17

kant1
Member
Registered: 2006-11-28
Posts: 57

Re: bridge network with Virtualbox

I think you should conflate those two lines into one.

Offline

#14 2007-06-19 10:47:39

n8schicht
Member
From: Südbaden
Registered: 2006-12-27
Posts: 138
Website

Re: bridge network with Virtualbox

Hi guys

Just for the record, this is how I set up a working  bridged network with VirtualBox:

1) Add vboxdrv and tun to the MODULES-line in /etc/rc.conf

2) Edit /etc/udev/rules.d/60-vboxdrv.rules and add:

KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
KERNEL=="tun", NAME="net/%k", GROUP="vboxusers", MODE="0660"

3) Create the file /etc/virtualbox-ifup and add the following content:

#!/bin/sh
VBoxTunctl -b -t $1 -u $2
/sbin/ifconfig $1 $3 up
/usr/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
/bin/chmod 666 /proc/sys/net/ipv4/ip_forward
/bin/echo "1" >/proc/sys/net/ipv4/ip_forward

Make it executable with chmod 777 /etc/virtualbox-ifup

4) Create the file /etc/virtualbox-ifdown and add the following content:

#!/bin/sh
/sbin/ifconfig $1 down
VBoxTunctl -d $1 -u $2

Make it executable with chmod 777 /etc/virtualbox-ifdown

5) Add your user with visudo to be allowed to execute those files without prompting for password:

username       ALL=(ALL)       NOPASSWD: /etc/virtualbox-ifup
username       ALL=(ALL)       NOPASSWD: /etc/virtualbox-ifdown

6) Set up your guest OS in Virtual Box with the following network-settings:

Type: Host Interface
Interface-Name: leave it empty
Setup: sudo /etc/virtualbox-ifup tap0 your_vbox_username 10.0.0.1
Terminate: sudo /etc/virtualbox-ifdown tap0 your_vbox_username

7) Boot your OS (Probably Windows) and edit it's network settings:

IP: 10.0.0.2
Subnetz: 255.0.0.0
Gateway: 10.0.0.1
DNS1: 192.168.3.1
DNS2: 10.0.0.1

And if you want to be able to easily share files with Windows XP, remeber to disable "use simple file sharing" in explorer under "extras -> options" 2nd tab (don't know the real name for this setting, in german it's "Einfache Dateifreigabe verwenden").

Thats it! Since then bridged networking works great for me! Hope this helps...

Last edited by n8schicht (2007-06-19 12:47:24)

Offline

#15 2007-06-20 04:06:44

soup
Member
Registered: 2006-09-01
Posts: 4
Website

Re: bridge network with Virtualbox

Edit:

Alright, so I've figure most of it out. I've managed to use seamless and remote desktop to combine my desktops (awesome), but I still can't use the network inside the windows XP guest environment. Donno what the story is.

Last edited by soup (2007-06-20 06:57:03)

Offline

#16 2007-09-16 08:59:29

Cotton
Member
From: Cornwall, UK
Registered: 2004-09-17
Posts: 568

Re: bridge network with Virtualbox

FWIW, hamachi/ghamachi/qamachi provide a method of linking 2 networks in a private LAN.  It often used to bypass firewalls without port forwarding when gaming.

I've used it successfully to access a web server under winxp running in Virtualbox from the Archlinux host machine.

Offline

Board footer

Powered by FluxBB