Creating new xen bridges on Ubuntu 8.04 (or other)

When Xen is installed, there is only one bridge by default. If you have multiple network cards, you can assign a physical card to a specific DomU or use as many as you want on the same DomU.

Create the file /etc/xen/scripts/my-network-script :

vi /etc/xen/scripts/my-network-script

And make it look like this :

#!/bin/sh
dir=$(dirname "$0")
"$dir/network-bridge" "$@" vifnum=0 netdev=eth0 bridge=eth0
"$dir/network-bridge" "$@" vifnum=1 netdev=eth1 bridge=eth1

And make it executable :

chmod u+x /etc/xen/scripts/my-network-script

Now we must start this script at startup by replacing the following line in /etc/xen/xend-config.sxp :

(network-script network-bridge)

with :

#(network-script network-bridge)
(network-script my-network-script)

Now restart xend :

/etc/init.d/xend restart

Once this is done, we need to assign the different bridge to domains. In these examples, I will use dom1 and dom2 as domU. The code will be found under /etc/xen/dom1.cfg and dom2.cfg :

Example 1 : Each Dom has its own network card

dom1.cfg :

...
# use eth0 for this DomU
vif = [ 'ip=10.XX.XX.230,mac=00:17:de:ad:fa:ce,bridge=eth0' ]
...

dom2.cfg :

...
# use eth0 for this DomU
vif = [ 'ip=10.XX.XX.241,mac=00:16:de:ad:fa:ef,bridge=eth1' ]
...

Example 2 : Each Dom has two network card

dom1.cfg :

...
# use eth0 for this DomU
vif = [ 'ip=10.XX.XX.230,mac=00:17:de:ad:fa:ce,bridge=eth0', 'ip=10.XX.XX.231,mac=00:18:de:ad:fa:dc,bridge=eth1' ]
...

dom2.cfg :

...
# use eth0 for this DomU
vif = ['ip=10.XX.XX.241,mac=00:16:de:ad:fa:ef,bridge=eth0', 'ip=10.XX.XX.242,mac=00:15:de:ad:fa:ec,bridge=eth1' ]
...

Now login your Dom1 or Dom2 and modify the /etc/network/interfaces with the new eth1 :

example with Dom2:

...
auto eth0
iface eth0 inet static
 address 10.XX.XX.241
 gateway 10.XX.XX.1
 netmask 255.255.255.0
 
auto eth1
iface eth1 inet static
 address 10.XX.XX.242
 gateway 10.XX.XX.1
 netmask 255.255.255.0
...

Reboot and it should work