XenNetworking/Examples
This page is here because I found it difficult to find information on what I felt was a relatively simple networking case. However it should not be limited by that case - it could become a good reference point for most common networking layouts.
Single Physical Public - Single Virtual Backend
Justification
At Hetzner (a German hosting company - also available in SA) their root servers typically have a single ethernet connection, allowing multiple addresses. I also wanted to have a private network to allow home directory sharing and other such things between various functional Xen domains (www/mail...).
Network Layout
My IP and most of my /29 subnet are avaiable directly on the single ethernet interface provided. The first subnet address is the subnet gateway and is provided by my hosting provider.
Hosting Switch | | | peth0 | xenbr0 xenbr1 | - PubIP - dom0 - RFC1918 - | | - PubIP - domU - RFC1918 - | ...
dom0 (xend)
I run debian as a dom0, and chose to use 172.16.16.0/24 as my RFC1918 range, so I did the following (as root):
modprobe dummy echo dummy >> /etc/modules cat <<EOF >> /etc/network/interfaces # Xen Backend auto dummy0 iface dummy0 inet static address 172.16.16.1 broadcast 172.16.16.255 netmask 255.255.255.0 EOF ifup dummy0 cat <<EOF > /etc/xen/scripts/my_network_script #!/bin/sh dir=$(dirname "$0") "$dir/network-bridge" "$@" vifnum=0 netdev=eth0 bridge=xenbr0 "$dir/network-bridge" "$@" vifnum=1 netdev=dummy0 bridge=xenbr1 EOF chmod +x /etc/xen/scripts/my_network_script
Don't forget to make the new script executable
Then edit /etc/xen/xend-config.sxp to have the following two lines of config:
(network-script my_network_script) (vif-script vif-bridge)
And restart xend
/etc/init.d/xend restart
- lo
- eth0 (Your public IP address)
- dummy0 (172.16.16.1 - or other RFC1918 address)
- xenbr0
- xenbr1
domU
Configure your domU as normal - but edit the cfg file to have the following entry (substitute your public IP and an available private IP):
vif = [ 'ip=<PublicIP>,bridge=xenbr0','ip=172.16.16.2,bridge=xenbr1' ]
When you boot it up - set the two interfaces up in /etc/network/interfaces:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address x.y.z.2 gateway x.y.z.1 netmask 255.255.255.248 auto eth1 iface eth1 inet static address 172.16.16.2 netmask 255.255.255.0