Introduction:
This HowTo assumes that the Internet access from VMs via DOM0 and the private LAN are done using the Bridge method. In the previous versions of Xen installation the bridges were dynamically built via the Xen scripts, in this version the bridges are built permanently as the DOM0 boots up.
DOM0:xenbr0(eth0) ---bridging==>> DOMUs:eth0
DOM0:pdummy0(dummy0) ---bridging==>> DOMUs:eth1
IMPORTANT: If you are installing Xen in a Hetzner(Germany) dedicated server and use only the available(max 3) IPs for the DOMUs, then you need to make sure you are generating a MAC address for each DOMU IP in the Hetzner robot site of your server, then use this MAC address in your DOMU Xen configuration. If you are using a subnet of 8 IP or more in Hetzner server for DOMUs, this bridging method would not work. Follow the instructions shown here instead: https://wp.me/pKZRY-F9
Install Xen Hypervisor and some useful tools
apt-get install xen-hypervisor-4.4-amd64 xen-utils-4.4 bridge-utils ethtool iptables
Some extra preparations
Since every virtual disk needs to be mounted using a loop device, we need to make sure there are enough of them available in the system.
Edit the file /etc/modules and add:
loop max_loop=64
dummy
We also need to turn on the IPv4 forwarding in the kernel.
Edit the file /etc/sysctl.conf (around line 44) activate the line by removing the ‘#’ as follows:
net.ipv4.ip_forward=1
The run the following command to activate it:
sysctl -p /etc/sysctl.conf
CONFIGURING THE NETWORK in DOM0
Based on the IP assumptions above, here is the content of the file /etc/network/interfaces.
# Internet Access nterface
auto xenbr0
iface xenbr0 inet static
address 85.114.145.5
netmask 255.255.255.0
network 85.114.145.0
broadcast 85.114.145.255
gateway 85.114.145.1
bridge_ports eth0
#
auto eth0
iface eth0 inet manual
#
# Internal LAN between VMs and DOM0
auto pdummy0
iface pdummy0 inet static
address 192.168.100.1
netmask 255.255.255.0
bridge_ports dummy0
#
auto dummy0
iface dummy0 inet manual
In order to make sure Xen scripts don’t create the normal bridges when a DOMu is started, we need to hinder this process by:
editing the file /etc/xen/xend-config.sxp and change the line:(around line 176)
FROM:
(network-script network-bridge)
TO:
(network-script none)
reboot
Configuring the DOMUs
DOMUs Configuration
PyGRUB
If your DOMUs configurations are set to use pygrub as boot loader,
then make sure the path to pygrub in the DOMU configuration file is correct as follows:
bootloader = '/usr/lib/xen-4.4/bin/pygrub'
In the same DOMU configuration file, make sure you are using a non duplicated MAC addresses with the network interfaces assignment as well as define the bridge that will be used by this DOMu, for example:
vif = [ 'ip=46.7.178.112,mac=00:16:34:D7:9C:12,bridge=xenbr0', 'ip=192.168.100.112,mac=00:16:3E:D7:1C:12,bridge=pdummy0' ]
NOTE:If you are not using the PyGRUb and want to use it as boot loader for each individual DOMUs, which makes the DOMUs kernel independent from the DOM0, see the following article. Please notice that in Ubuntu 14.04 the path to pygrub is different than in the article. Each new version of Xen has a different path to PyGRUB th rest of the article is fully accurate for Ubuntu as well.
http://tipstricks.itmatrix.eu/?s=pygrub&x=0&y=0
DOMus Network Configuration
Each DOMu will get an interface lo and eth0 with the following configuration:
I’m using the first IP of our subnet for this DOMU and will therefore be configured as follows:
Note: This configuration not really standard as it uses each IP with the netmask /32 (255.255.255.255).
This setting allows each IP of the subnet to be usable by each DOMu.
File: /etc/network/interfaces
Content:
# The loopback network interface
auto lo
iface lo inet loopback
#
# The primary network interface
auto eth0
iface eth0 inet static
address 46.7.178.112
netmask 255.255.255.255
gateway 46.7.178.1
#
# The internale LAN interface(will be connected to pdummy0 on DOM0)
auto eth1
iface eth1 inet static
address 192.168.100.112
netmask 255.255.255.0