Homepage

Creating OpenVZ in a Centos 6

This tutorial is running under a vps with the following :

The basic idea is to be able to create an OpenVZ VM inside a KVM VPS.
VM connection to the internet is using NAT trough the eth0 of the KVM VPS, so the OpenVZ VM have direct access to the internet.
Connection from the internet to the OpenVZ VM using port forwarding, which set by IPTABLES.
This tutorial is based from :

Installing basic webserver

 
Preparing OpenVZ Repository
Add the following repository from OpenVZ to Centos 6

 
Installing OpenVZ Kernel

 
Modifying sysctl.conf

Add the following line :

Activate the modification

 
Modifying the vz.conf

Find the following line, and change the value to “all”

 
Disable SELINUX in Centos

Find SELINUX line, and change the value to “disabled”

 
Installing OpenVZ Web Panel for managing the OpenVZ

Wait until installation complete, and you will see something like http://ip.address.of.vps:3000.
 
Setting iptables
Next, we make some modification to permit acl for port 3000 in the iptables

Add the following lines :

Restart the iptables :

 
Installing OS template for the OpenVZ

Download all the OS you need here

Example :

 
Restart your Centos server

Verify that the KVM VPS is using the new OpenVZ kernel

 
 
Managing trough OpenVZ Web Panel

Default username is admin, default password is admin.  By using OpenVZ Web Panel, we can add manage the VM, such creation, editing setting, deletion, etc.
Adding IP Pools to the VM
From the OpenVZ Web Panel, click on the left side, and add the IP Pools, since we only have 1 IPv4, we need to add the private IP to the VM, for example 192.168.1.1 – 192.168.1.255 or 10.10.10.1 – 10.10.10.255
Next, click on the left side, on the localhost, create your first VM, with the veid for example 101, choose the OS template, assign the private IP to the VM, set the disk space, memory, etc.
 
How to provide access for container to the internet
To give internet access for container to the internet, we need to set IPTABLES with SNAT to the VM. Here, our KVM VPS is using eth0 with the IP address for example 194.68.40.216.
We can set SNAT for each VM, but for the fastest way, lets set SNAT for each IP :

ip_address is the vps IP address, so it would be :

 
 

Exit mobile version