Results 1 to 7 of 7

Thread: Howto virtualbox network bridging with single nic

  1. #1
    Join Date
    Jun 2008
    Location
    Moorsel - Belgium
    Posts
    40

    Post Howto virtualbox network bridging with single nic

    The opensuse wiki has a little tutorial on how to configure network bridging with virtualbox


    Virtualbox Network Bridging


    However, the scenario used in the tutorial is based on a machine with 2 nics.
    - One used for the normal network connection of the machine
    - the other used for the bridging configuration
    This is the best setup because your virtual machine networking does not interfere with you normal network traffic.

    For people that are using only a single nic (most laptop users) this is my scenario.

    before config:
    eth0 with static ip 128.1.5.55/16

    after config
    eth0 with static ip 0.0.0.0 (to enable bridging)
    br0 with static ip 128.1.5.55/16 (the bridge is used for normal traffic also)
    vbox0 for vbox bridging

    this is my eth0 config
    Code:
    cat /etc/sysconfig/network/ifcfg-eth0
    BOOTPROTO='static'
    BROADCAST=''
    ETHTOOL_OPTIONS=''
    IFPLUGD_PRIORITY='20'
    #IPADDR='128.1.5.55/16'
    IPADDR='0.0.0.0'
    MTU=''
    NAME='NetXtreme BCM5755M Gigabit Ethernet PCI Express'
    NETWORK=''
    REMOTE_IPADDR=''
    STARTMODE='ifplugd'
    USERCONTROL='no'
    PREFIXLEN=''
    So you can see i commented out the normal ip and changed it to 0.0.0.0

    The I created the br0 interface and gave it my fixed IP
    Code:
    #ifcfg-br0
    STARTMODE='auto'
    BOOTPROTO='static'
    IPADDR='128.1.5.55/16'
    USERCONTROL='no'
    BRIDGE='yes'
    BRIDGE_PORTS='eth0'
    BRIDGE_AGEINGTIME='20'
    BRIDGE_FORWARDDELAY='0'
    BRIDGE_HELLOTIME='2'
    BRIDGE_MAXAGE='20'
    BRIDGE_PATHCOSTS='3'
    BRIDGE_PORTPRIORITIES=
    BRIDGE_PRIORITY=
    BRIDGE_STP='on'
    Then you must restart your network stack

    Code:
    /etc/rc.d/network restart
    if you run ifconfig you will see the new br0 interface with the static ip.

    Code:
    br0       Link encap:Ethernet  HWaddr 00:1C:23:1B:15:91  
              inet addr:128.1.5.55  Bcast:128.1.255.255  Mask:255.255.0.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:63031 errors:0 dropped:0 overruns:0 frame:0
              TX packets:5755 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:24480648 (23.3 Mb)  TX bytes:730056 (712.9 Kb)
    
    eth0      Link encap:Ethernet  HWaddr 00:1C:23:1B:15:91  
              UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
              RX packets:225996 errors:0 dropped:0 overruns:0 frame:0
              TX packets:5763 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:122868191 (117.1 Mb)  TX bytes:759601 (741.7 Kb)
              Interrupt:17
    And finally you have to create the vbox-interface

    Code:
    VBoxAddIF vbox0 localuser br0
    That's It.

  2. #2
    Join Date
    Jun 2008
    Location
    Moorsel - Belgium
    Posts
    40

    Default Re: Howto virtualbox network bridging with single nic

    Also wanted to add that I do not use Networkmanager but ifup

  3. #3
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Howto virtualbox network bridging with single nic

    Sorry I know I'm not supposed to post a question here, but I think the answer is useful to everybody interested in bridging to Virtualbox. If not, tell me and I will repost in Networking. Bridging to Virtualbox is something I want to do.

    Essentially as I understand it you give the external address of your machine to br0 and eth0 gets 0.0.0.0. What happens to packets for your machine's address, do they all end up going to the guest machine?

    Let's make the question concrete: You run apache on the host and also on the guest. Which apache gets the incoming packets? Host? Guest? Both (huh?)?

  4. #4
    Join Date
    Jun 2008
    Location
    Moorsel - Belgium
    Posts
    40

    Default Re: Howto virtualbox network bridging with single nic

    Coming from the Virtualbox manual

    Network bridging is one of the simplest ways to use Host Interface Networking.
    Bridging allows you to connect several network devices together in software, so that
    data sent to one of the devices will be sent to all of them. For our purposes, this means
    that virtual machines can send packages through the hosts network card, using their
    own network hardware address, and receive packages sent to it. Other computers on
    your network will see your guests as though they were physically connected to the
    network. You will need wired (Ethernet) network hardware on the host for this as
    most current wireless network devices do not support bridging.
    What i understand from this is that data is sent to all devices (like a hub) but each device has a different ip so only the destination ip will respond...
    For the scenario i describe in the howto this means that
    eth is 0.0.0.0 because the ip is transferred to the bridge br0
    br0 is 128.1.5.55
    vbox0 is 128.1.20.15

    If apache is running on both of them it should not be a problem, even when running on the same port.

  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Howto virtualbox network bridging with single nic

    Ah ok that makes sense, vbox0 has a different MAC address and a different IP address. Thanks, that makes life easier for me.

  6. #6

    Default Re: Howto virtualbox network bridging with single nic

    Is it possible to assign the Bridge to receive a DHCP address instead?

  7. #7
    nowell29 NNTP User

    Default Re: Howto virtualbox network bridging with single nic

    I would like to make this easier for those who are having any other difficulties with this. I have been using my computer on a univeristy campus. We register our computer MAC addresses and get assigned an IP to that. Though I have a static registration, meaning I will always get the same IP, my computer is set to DHCP so that route, resolv.conf, hostname, and IP are all setup automatically.
    In all the examples everybody would statically set their IP. So I did the same. It took me a couple of hours to remember that if I statically assign my IP I will not have everything else I need. So I could either manually set these, or what I did, changed ifcfg-br0 to BOOTPROTO='DHCP' and everything worked! Everything else exactly as is in this post except that one thing worked for me. Thanks for the post.

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
  •