Posts Tagged ‘Xen’

Using vif-route with multiple IPs for a Xen domU

Saturday, April 25th, 2009

Just a little tip for those of you using vif-route for your networking in Xen. I needed to do this recently for a server at OVH as bridging cannot be used.

Set up multiple IPs by separating them with a space like follows in the domU config:

vif = [ 'ip=78.129.140.250 78.129.140.251' ]

You can also add more IPs to the domU without having to restart it using the following syntax replacing 78.129.140.1 with your gateway and vif101.0 with the interface name associated with the domU in your dom0:

ip route add 78.129.140.251 dev vif101.0 src 78.129.140.1

Your domU should now be able to use the extra IP!

In my case, I was trying to forward the IP to an OpenVZ VE within a domU -- this works perfectly fine with the above and no further configuration is required within the domU (other than obviously adding the IP to the OpenVZ container).

Installing and Running OpenVZ VEs inside a Xen domU

Friday, April 24th, 2009

One of my more favourite virtualisation topics. OpenVZ in combination with Xen.

Since it is possible to split a Xen DomU into further OpenVZ containers I will get straight down to the nitty gritty of how to do so!

Stay with me…

First of all, Install wget and nano if not already installed:

yum -y install nano wget

Insert the following using: nano /etc/modprobe.conf

alias eth0 xennet
alias scsi_hostadapter xenblk

Insert the following to disable selinux: nano /etc/sysconfig/selinux

SELINUX=disabled

The following values should be set. On our systems, the top two were edited and the bottom rest inserted: nano /etc/sysctl.conf

net.ipv4.ip_forward = 1
kernel.sysrq = 1

net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

Now install some required packages:

yum -y install mkinitrd ed rsync

Download kernel:

wget http://download.openvz.org/kernel/branches/rhel5-2.6.18/028stab060.8/ovzkernel-xen-2.6.18-92.1.18.el5.028stab060.8.x86_64.rpm

Download the following utils:

wget http://download.openvz.org/utils/vzctl/current/vzctl-3.0.23-1.x86_64.rpm
wget http://download.openvz.org/utils/vzctl/current/vzctl-lib-3.0.23-1.x86_64.rpm
wget http://download.openvz.org/utils/vzquota/current/vzquota-3.0.12-1.x86_64.rpm

Install the above:

rpm -ivh ovzkernel-xen-2.6.18-92.1.18.el5.028stab060.8.x86_64.rpm
rpm -ivh vzquota-* vzctl-*

Download an OS template:

wget http://www.modernadmin.com/downloads/ostemplates/openvz/centos-5.3-x86_64-modernadmin.tar.gz -O /vz/template/cache/centos-5.3-x86_64-modernadmin.tar.gz

You may also need to copy the following from /boot to your Xen dom0:

/boot/initrd-2.6.18-92.1.18.el5.028stab060.8xen.img
/boot/vmlinuz-2.6.18-92.1.18.el5.028stab060.8xen

Reboot! You should now be able to create an OpenVZ VE!

vzctl create 777 --ostemplate centos-5.3-x86_64-modernadmin --ipadd 78.129.140.250 --hostname template.modernadmin.com