Xen – How to Create Bridged Network Interface on Ubuntu

bridgenetworkingUbuntuvirtualizationxen

I'm trying to use Xen on an Ubuntu server for the first time and have a really basic question.

I'm following the guide in the Ubuntu docs and under the Network Configuration->Using bridge-utils section it says:

In a bridged setup, it is required that we assign the IP address to the bridged interface. Configure network interfaces so that they persist after reboot:

sudo vi /etc/network/interfaces

auto lo eth0 xenbr0
iface lo inet loopback

iface xenbr0 inet dhcp
  bridge_ports eth0

iface eth0 inet manual

Restart networking to enable xenbr0 bridge:

sudo ifdown eth0 && sudo ifup xenbr0 && sudo ifup eth0

My /etc/network/interfaces file:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em2
iface em2 inet static
        address 68.65.120.34
        netmask 255.255.255.224
        network 68.65.120.32
        broadcast 68.65.120.63
        gateway 68.65.120.33
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 68.65.120.33 8.8.8.8 4.4.2.2
        dns-search web-hosting.com

This is my attempt, which caused me to lose SSH access when I tried it:

# The loopback network interface
auto lo em2 xenbr0
iface lo inet loopback

#xen
iface xenbr0 inet dhcp
bridge_ports em2

# The primary network interface
auto em2
iface em2 inet manual
        address 68.65.120.34
        netmask 255.255.255.224
        network 68.65.120.32
        broadcast 68.65.120.63
        gateway 68.65.120.33
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 68.65.120.33 8.8.8.8 4.4.2.2
        dns-search web-hosting.com

Then:

sudo ifdown em2 && sudo ifup xenbr0 && sudo ifup em2

How do I modify the contents of my configuration file to work with Xen?

Best Answer

  • In your first network config em2 is configured to use the static method. In your second one it's set to manual. Using manual, the options you set afterwards don't get applied, hence you lost access.
  • Your machine is connected physically to the network via em2. You want to create a bridge called xenbr0, so you need to set em2 to manual (what you did), set xenbr0 to static (like em2 was before, instead of dhcp) and move all the options from em2 to xenbr0.
  • So, try this:

    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    #xen
    auto xenbr0
    iface xenbr0 inet static
           address 68.65.120.34
           netmask 255.255.255.224
           network 68.65.120.32
           broadcast 68.65.120.63
           gateway 68.65.120.33
           # dns-* options are implemented by the resolvconf package, if installed
           dns-nameservers 68.65.120.33 8.8.8.8 4.4.2.2
           dns-search web-hosting.com
           bridge_ports em2
    
    # The primary network interface
    auto em2
    iface em2 inet manual
    
  • There are some more options you could set, especially in a virtualized environment:

           bridge_stp off       # disable Spanning Tree Protocol
           bridge_waitport 0    # no delay before a port becomes available
           bridge_fd 0          # no forwarding delay