Networking bridge for Virtualbox
FedoraForum.org - Fedora Support Forums and Community
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Sep 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Networking bridge for Virtualbox

    Can someone please advise step by step how to set up Bridging between two Windows guests and a Fedora 7 host. Fedora 7 is running as is the two windows guests.
    I need both guests to be able to connect to the local LAN only. All other networking, internet etc is to be done via Fedora's OS. I also need to be able to connunicated Fedora to the two windows OS guests and the other way.

    The virtualbox manual has a procedure but I can not find the files.
    I found the Bridge-Utils package and loaded it but whenI wen to look for the the file /etc/sysconfig/network-scripts/ifcfg-bro it was not there.

    Some other information on the web, not specific for Fedora 7 suggests another file or two is required uml-utilities. Other suggested files in an other article are tunctl utility, brctl utility nad libsysfs libary.

    Can any one provide a definitive step by step, with what files are required to get the bridge networking going.

    Thanks

  2. #2
    trentonknight Guest

    Lightbulb bridge-utils setup for fedora 8

    Here is a script I use on my Fedora 8 host. The trick is /sbin/ip route which I found on an ubuntu tutorial. You might notice most of it is straight from the Virtualbox tutorial. After running this script all you have to do is setup any guest (including windows) as...

    ip address 10.0.1.2
    subnet mask 255.255.255.0

    here is my script, insure you change "YourUserNameHere" to your username, I recieve some errors after script runs but it still works great, It needs a little cleaning up but if it works I'm happy...


    #!/bin/bash

    # Create an new TAP interface for the user 'vbox' and remember its name.
    interface=`VBoxTunctl -b -u YourUserNameHere`

    # If for some reason the interface could not be created, return 1 to
    # tell this to VirtualBox.
    if [ -z "$interface" ]; then
    exit 1
    fi

    # Write the name of the interface to the standard output.
    echo $interface

    # Bring up the interface.
    /sbin/ifconfig $interface up

    # And add it to the bridge.
    /usr/sbin/brctl addif br0 $interface

    sudo /sbin/ip addr add 10.1.1.1/24 dev br0
    sudo /sbin/ip route add 10.1.1.0/24 dev br0
    sudo /sbin/ifconfig tap0 10.0.1.1 netmask 255.255.255.0

    echo "run /sbin/ifconfig br0 verify bridge exists"
    echo "run /sbin/ifconfig tap0 and verify it is assigned an ip address"

  3. #3
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh funny you should ask this. I'm going to be putting a page up on it tonight because I felt the manual wasn't clear to the newcomer.
    Point 1. It will NOT work with wireless. (If the manual had put that in, it would have saved me a lot of doublechecking.)
    Point 2. The commands that they say are specific to Fedora won't work unless you either edit your $PATH, do su - (with the dash) or edit the script called by VBoxAddIF (or whatever it's called.)

    I'm going to give you an even simpler version than trentonknight's (although his should certainly work, as near as I see.)
    Also note. You will be disconnected from the network at one point here, so don't do this remotely.

    If you use sudo fine, I'm going to assume you use su

    PATH=$PATH:/sbin:/usr/sbin

    That will shorten your typing.

    su
    First let's make the bridge.
    We're assuming you've installed bridge-utils. If not, first
    yum -y install bridge-utils

    brctl addbr br0
    Now, you're going to disconnect from your network for a minute. If you get your address through DHCP, say, from a Linksys router, you'll do it this
    way. If you have static addressing, first get your information.

    ifconfig eth0
    write down the result. We'll assume (again, typical Linksys router layout)
    that you see
    192.168.1.102

    as your ethernet address. It will also give the subnet mask, and some other info.
    If this is the case, you can figure out your network and route as well, we'll cover that shortly.

    ifconfig eth0 0.0.0.0
    brctl addif br0 eth0

    You've brought down your ethernet card, and told the bridge that it will use that interface, eth0. Now we give the br0 interface an address. Again, if you use DHCP, then it's simply

    dhclient br0

    It will get an address. If you get a message like dhclient already running, kill it and do it again.
    pkill dhclient
    Then
    dhclient br0.
    But hopefully, that won't be an issue.

    If it was a static address then you would do this instead. Again, assuming your address was 192.168.1.102
    ifconfig br0 192.168.1.102 netmask 255.255.255.0 up
    route add -net 192.168.10 netmask 255.255.255.0 br0
    route add default gw 192.168.1.1 br0

    Basically, if you have 24 bit netmask, that is, 255.255.255.0 your route add -net will be the first three numbers, and 0, unless you're doing something rather unique.
    Now the bridge has the address and we're more or less going to use trentonkinght's script. Say your username is nls

    VBoxTunctl -b -u nls

    You will see that it's created tap0 unless you've already done this, in which case it might be tap1. For the rest of this, assume it's tap0

    ifconfig tap0 up
    brtctl addif br0 tap0

    In my case, where these get their addresses from DHCP, I've been able to simply start the host and get an address from the LAN's DHCP server. I'm not sure if trentonknight's method of giving tap0 an address is best, or if you're better off starting the guest system and giving it an address then, as I haven't tested it. If your network has DCHP, it's a moot point anyway.

    I would think that either way would work, but I note that he gives the virtual machine a different address than tap0. In my case, I simply didnt' give tap0 an address. trentonknight, have you tried it that way (not giving tap0 an address and just giving one to the guest O/S, and found it to not work?)

  4. #4
    trentonknight Guest

    Lightbulb Uncertain

    I am fairly uncertain all methods I have tried. I have been working on it for over a week to no avail. I do not see my wireless card but I can connect to the internet and my host. Perhaps I am connecting to the internet through my host.

    I have put my script in

    /etc/rc.local

    so it will bridge and then create a tap0 for a single guest

    Oh, also I'm uncertain but I have br0 as a host interface under Adapter 2 in VirtualBox settings for network. This is an important part of the setup I forgot to include.

    My next concern is allowing Spanning Tree protocol so I may network multiple guests. Can you connect multiple guests with your network setup?

    Respectfully
    TrentonKnight

  5. #5
    trentonknight Guest

    Exclamation wireless connection

    Im not certain if I was clear with the point about wireless. I am not using my eth0 or my wlan0. It doesn't matter if my guest sees eth0 or wlan0 as it appears to connect directly to tap0 for both internet and connection to my host as well. I can google search on windows xp ,ssh into windows and windows can ssh into Fedora 8 no problem.

  6. #6
    trentonknight Guest
    One last item, I'm using wireless with no issues. Both host and guest are connected to internet and each other. Like I said before I don't think it matters how the host connects to the network.

  7. #7
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, some quick checking indicates that my way will work. You have to play with iptables though--in my case, as I was just testing, I simply temporarily disabled them.

  8. #8
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, you're way ahead of me then. I can't get wireless to work, but I'm going to try this evening with something closer to your method.

    If I use NAT, then wireless works without problem, however having it as a separate host on my LAN, with wireless, isn't working for me.

    From all the googling I'd seen, wireless isn't expected to work with bridged networking, so I'm impressed.

  9. #9
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    trentonknight a quick question here. You have your setup as described. For adapter0 do you have tap0? Do you have anything for adapter1? If I were guessing, it sounds as if you have tap0 for adapter0 and then br0 for adapter2 with nothing for adapter1 in the VirtualBox settings. I've simply given an address to br0, nothing to tap0 then assigning an address, different than the one on br0, to the guest machine. As mentioned, my way works with wired ethernet, where br0 has eth0 as a member, and wireless if I use NAT. I'm assuming your home network is something like 10.0.x.x/24?

    Seriously, if you have wireless working with bridged networking, then you should probably submit a howto to VirtualBox, since AFAIK, it's considered to simply not work.

    Anyway, I've got to run out now, I'm going to have to play with this tonight, if I have a chance.
    Thanks

  10. #10
    trentonknight Guest
    OK, you were right I do not need to use tap0 with an ip address. Here is the cleaned up script. Also here is my ifcfg-br0 from /etc/sysconfig/network-scripts/ifcfg-br0 that is setup for static ip on boot.

    first the ifcfg-br0

    DEVICE=br0
    TYPE=Bridge
    BOOTPROTO=static
    ONBOOT=yes
    IPADDR=10.1.1.1
    NETMASK=255.255.255.0
    DELAY=0
    STP=off

    STP can probably be on but I'm not playing with multiple guests just yet.

    OK and here is my revised script and like I said I do not claim any of this as most of it is from other forums and the Virtualbox tutorial.

    #!/bin/bash

    # Create an new TAP interface for the user 'YourUserNameHere' and remember its name.
    interface=`VBoxTunctl -b -u YourUserNameHere`

    # If for some reason the interface could not be created, return 1 to
    # tell this to VirtualBox.
    if [ -z "$interface" ]; then
    exit 1
    fi

    # Write the name of the interface to the standard output.
    echo $interface

    # Bring up the interface.
    /sbin/ifconfig $interface up

    # And add it to the bridge.
    /usr/sbin/brctl addif br0 $interface

    sudo /sbin/ip addr add 10.1.1.1/24 dev br0
    sudo /sbin/ip route add 10.1.1.0/24 dev br0

    Now you can ping the host (fedora 8)10.1.1.1 from windows, you can ping the guest (windows xp)10.1.1.2. I can ssh from windows into Fedora 8. I have not tried vnc yet from Fedora to windows but I'm sure it will work.

    I have a HP Pavilion dv6500 with a broacom onboard wireless card that works with ndiswrapper. It is funtional on both host and guest with this configuration. The guest has no issues with connecting to internet at any point and after the script is run it connects to host great.

  11. #11
    trentonknight Guest
    Oh, yah adapter 1 is tap0, adapter 0 is nat of course.

  12. #12
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, a few more questions. Firstly, thank you for sharing and although you're not taking credit, as I said, wireless bridged networking is considered to not work in VB.

    I'm wondering if this is possibly using NAT?
    So, let me ask a few more questions and again, many thanks for your time and trouble.

    The host is Fedora 8. How many nics does it have? If more than one, (I'm guessing eth0 is the regular wired NIC and eth1 the wireless) is the bridge attached to eth1? Is your home network, in general, a 10.1.1.0/24 network?

    Is the Windows box definitely set to use Attached Interface rather than NAT?
    (I'm not doubting you, I'm just a bit confused here.) Or do you leave your ethernet card as is, say, with an address on a completely different subnet, and then give the bridge its address?

    In my case, with the wireless, I could connect between guest and host, and host and everything else, but the guest couldn't connect to anything outside of the host.

    So, Ok, my questions in more organized form.
    What is your network setup--that is, is it a 10.1.1.0/24 network?
    What is the address of the wireless card, and do you make it 0.0.0.0 before bringing up the bridge?

    In the VB settings for the Windows machine, which adapter is it using and is it configured to be attached to tap0?

    (I suspect your answers will raise other questions, and if this too much of a nuisance, I really do understand.)

  13. #13
    trentonknight Guest
    I understand your confusion. I never use my Ethernet connection except for building fedora of course. My wireless on my Fedora 8 host system I have configured as ifcfg-wlan0 running from ndiswrapper. So eth0 of course fails on boot as it is not attached in any way. I only connect my Host computer via wireless...

    # Broadcom Corporation BCM94311MCG wlan mini-PCI
    DEVICE=wlan0
    BOOTPROTO=dhcp
    ONBOOT=yes
    HWADDR=00:1a:73:b1:3d:b8

    after boot it shows as...

    wlan0 Link encap:Ethernet HWaddr 00:1A:73:B1:3D:B8
    inet addr:192.168.7.14 Bcast:192.168.7.255 Mask:255.255.255.0

    I configured br0 to create a static connection as...

    DEVICE=br0
    TYPE=Bridge
    BOOTPROTO=static
    ONBOOT=yes
    IPADDR=10.1.1.1
    NETMASK=255.255.255.0
    DELAY=0
    STP=off

    and then the script creates tap0 in which I bridge my windows xp guest to (or suse, gentoo, bsd, etc)

    I have full internet access from my guest, HOWEVER I cannot ping my wlan0 card at 192.168.7.14 or whatever dhclient puts wlan0 at on boot 192.168.7.*.

    the subnet mask is 255.255.255.0 for all connections mentioned.

    My home network is not a 10.1.1.0/24 network at any time just the host and guest in order for them to communicate. wlan0 remains at its dhclient assigned ip at all times, I do not bring down or try to attach to it or eth0 at any time.

    there is a second eth card in windows xp called loacl area connection 2. I set it up as...
    IP 10.1.1.2
    mask 255.255.255.0
    default gateway 192.168.7.7 although I don't think it matters what the DG is.

    No worries!
    TrentonKnight

  14. #14
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok trentonknight, you're off the hook. I've found a method that works quite well for me, thanks to http://www.hazard.maks.net/

    In a nutshell, one can actually ignore the bridge.
    So say my eth1 is my wireless.

    First I create a tap interface. There's no tunctl for Fedora, so one can actually use the VirtualBox VBoxTunctl.

    VBoxTunctl -b -u scottro

    I get tap0.

    Bring it up and give it an address with ifconfig or ip. With ip, (going by that page, again, working with my 192.168.1.0 network)
    ip link set tap0 up
    ip addr add 192.168.1.107/24 dev tap0

    Now I start VirtualBox, manually give the host an address, say 192.168.1.108 and I'm in business.

    I've put up a page about it at
    http://www.scottro.net/vboxbridge.html

  15. #15
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way, once again, thank you for your patience. I think I'm going to stick with the parprouted as it seems to be working out of the box. (Oh, I neglected to add in the post above that I also have to turn on ip forwarding with the sysctl variable, but I have it on the page I put up tonight.)

    Now, as for your STP question, I haven't even looked into that yet. I tend to run Fedora, at present, on relatively old machines, so I will just have one VM running at a time. Usually, I just start it up to do whatever I have to do, then shut it right back down again.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. VirtualBox and Networking
    By Hlingler in forum Using Fedora
    Replies: 13
    Last Post: 17th July 2009, 02:37 AM
  2. bridge networking KVM
    By Bluefish001 in forum Servers & Networking
    Replies: 3
    Last Post: 8th March 2009, 10:45 PM
  3. virtualbox bridge+iptables?
    By weeblewobble in forum Servers & Networking
    Replies: 9
    Last Post: 28th April 2008, 10:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •