Small Tip: How to set up two interface Xen machine
14 Jan2008

This will be one of those posts I’d like to publish primarily to be able to coma back later and check it out instead of reading docs again 🙂

So, we have a server with two (or more) network interfaces are we need to be able to use more than one interface in our VDS machines. How do we set it up?

First of all, I’d like to say that this method was tested and works for bridged configurations where host and guest machines’ interfaces are connected to bridges and you assign IPs on your guest machines w/o routing.

So, we need to create two bridges in our host environment. In Debian it is simple – here is my /etc/network/interfaces file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual

auto xenbr0
iface xenbr0 inet static
        bridge_ports eth0
        bridge_maxwait 1
        bridge_stp no
        address XXX.XXX.150.235
        netmask 255.255.255.248
        gateway XXX.XXX.150.233

# The backbone interface
auto eth1
iface eth1 inet manual

auto xenbr1
iface xenbr1 inet static
        bridge_ports eth1
        bridge_maxwait 1
        bridge_stp no
        address 192.168.0.40
        netmask 255.255.255.0

With this configuration we have two bridges and each of them has physical interface connected to it. Next our step is guest machine setup. In /etx/xen/our-machine.cfg we add:

1
2
3
4
#
#  Networking
#
vif  = [ 'bridge=xenbr0', 'bridge=xenbr1' ]

And in /etc/xen/xend-config.sxp we need to comment out all “(network-script *)” lines and use “(vif-script vif-bridge)” for virtual interfaces initialization.

And our last step is to configure guest machine’s network. Again, Debian’s config file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        up route add -host XXX.XXX.150.233 dev eth0
        up route add default gw XXX.XXX.150.233
        address XXX.XXX.152.127
        netmask 255.255.255.255

auto eth1
iface eth1 inet static
        address 192.168.0.126
        netmask 255.255.255.0

That is it – pretty simple and straightforward configuration.