<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Avagin</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Avagin"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Avagin"/>
	<updated>2026-05-15T16:23:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Checkpointing_and_live_migration&amp;diff=22879</id>
		<title>Checkpointing and live migration</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Checkpointing_and_live_migration&amp;diff=22879"/>
		<updated>2018-01-29T17:34:55Z</updated>

		<summary type="html">&lt;p&gt;Avagin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
CPT is an extension to the OpenVZ kernel which can save the full state of a running VE and to restore it later on the same or on a different host in a way transparent to running applications and network connections. This technique has several applications, the most important being live (zero-downtime) migration of VEs and taking an instant snapshot of a running VE for later resume, i.e. CheckPointing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
Before CPT, it was only possible to migrate a VE through a shutdown and subsequent reboot. The procedure not only introduces quite a long downtime for network services, it is not transparent for clients using the VE, making migration impossible when clients run some tasks which are not tolerant to shutdowns.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
Compared with this old scheme, CPT allows migration of a VE in a way which is essentially invisible both for users of this VE and for external clients using network services located inside the VE. It still introduces a short delay in service, required for actual checkpoint/restore of the processes, but this delay is indistinguishable from a short interruption of network connectivity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
{{Note|In OpenVZ 7, CPT is replaced by our sub-project [http://criu.org CRIU]}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Online migration == &amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
There is a special utility vzmigrate in the OpenVZ distribution intended to support VE migration. With its help one can perform live (a.k.a. online) migration, i.e. during migration the VE “freezes” for some time, and after migration it continues to work as though nothing had happened. Online migration can be performed with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzmigrate --online &amp;lt;host&amp;gt; VEID&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
During online migration all VE private data saved to an image file, which is transferred to the target host.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
In order for vzmigrate to work without asking for a password, ssh public keys from the source host should be placed in the destination host's &amp;lt;code&amp;gt;/root/.ssh/authorized_keys&amp;lt;/code&amp;gt; file. In other words, command &amp;lt;code&amp;gt;ssh root@host&amp;lt;/code&amp;gt; should not ask you for a password. See [[ssh keys]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Manual Checkpoint and Restore Functions == &amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vzmigrate&amp;lt;/code&amp;gt; is not strictly required to perform online migration. The &amp;lt;code&amp;gt;vzctl&amp;lt;/code&amp;gt; utility, accompanied with some file system backup tools, provides enough power to do all the tasks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
A VE can be checkpointed with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl chkpnt VEID --dumpfile &amp;lt;path&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This command saves all the state of a running VE to the dump file and stops the VE. If the option &amp;lt;code&amp;gt;--dumpfile&amp;lt;/code&amp;gt; is not set, &amp;lt;code&amp;gt;vzctl&amp;lt;/code&amp;gt; uses a default path &amp;lt;code&amp;gt;/vz/dump/Dump.VEID&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
After this it is possible to restore the VE to the same state executing:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl restore VEID --dumpfile &amp;lt;path&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the dump file and file system is transferred to another HW node, the same command can restore the VE there with the same success.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
It is a critical requirement that file system at the moment of restore must be identical to the file system at the moment of checkpointing. If this requirement is not met, depending on the severity of changes, the process of restoration can be aborted or the processes inside a VE can see this as an external corruption of open files. When a VE is restored on the same node where it was checkpointed, it is enough to not touch the file system accessible by the VE. When a VE is transferred to another node it is necessary to synchronize the VE file system before restore. &amp;lt;code&amp;gt;vzctl&amp;lt;/code&amp;gt; does not provide this functionality and external tools (i.e. &amp;lt;code&amp;gt;rsync&amp;lt;/code&amp;gt;) are required.&lt;br /&gt;
&lt;br /&gt;
== Step-by-step Checkpoint and Restore == &amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
The process of checkpointing can be performed in stages. It consists of three steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
First step – suspend the VE. At this stage CPT moves all the processes to a special beforehand known state and stops VE network interfaces. This stage can be done with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl chkpnt VEID --suspend&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
Second step – dumping VE. At this stage CPT saves the state of processes and global state of VE to an image file. All the process private data needs to be saved: address space, register set, opened files/pipes/sockets, System V IPC structures, current working directory, signal handlers, timers, terminal settings, user identities (uid, gid, etc), process identities (pid, pgrp, sid, etc), rlimit and other data. This stage can be done with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl chkpnt VEID --dump --dumpfile &amp;lt;path&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
Third step – killing or resuming processes. If the migration succeeds the VE can be stopped with the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl chkpnt VEID --kill&amp;lt;/pre&amp;gt;&lt;br /&gt;
If migration failed for some reason or if the goal was taking a snapshot of the VE state for later restore, CPT can resume the VE with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl chkpnt VEID --resume&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
The process of restoring consists of two steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
The first step is to restore processes and to leave them in a special frozen state. After this step processes are ready to continue execution, however, in some cases CPT has to do some operations after a process is woken up, therefore CPT sets process return point to function in our module. This stage can be done with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl restore VEID --undump --dumpfile &amp;lt;path&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
Second step – waking up processes or killing them if the restore process failed. After CPT wakes up process, it performs necessary operations in our function and continues execution. This stage can be done with:&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl restore VEID --resume&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;vzctl restore VEID --kill&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also == &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
* http://criu.org/&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: Technology]]&lt;br /&gt;
[[Category: Concepts]]&lt;/div&gt;</summary>
		<author><name>Avagin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=14980</id>
		<title>Vzctl for upstream kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=14980"/>
		<updated>2014-01-19T19:20:00Z</updated>

		<summary type="html">&lt;p&gt;Avagin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE: vzctl for upstream kernel}}&lt;br /&gt;
&lt;br /&gt;
'''This article describes using OpenVZ tool vzctl as an alternative to LXC tools.'''&lt;br /&gt;
&lt;br /&gt;
Recent vzctl releases (starting from version 4.0) can be used with upstream (non-OpenVZ) Linux kernels (that essentially means any recent 3.x kernel). At the moment, it provides just basic functionality.&lt;br /&gt;
It is currently possible to create, start and stop a container with the same steps as one would use for a normal OpenVZ container. Other features may be present with limited functionality, while some are not present at all. We appreciate all bug reports, please file to [http://bugzilla.openvz.org/enter_bug.cgi?component=vzctl bugzilla].&lt;br /&gt;
&lt;br /&gt;
Running vzctl on upstream kernels is considered an experimental feature. See [[#Limitations]] below.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Note|This section describes installation for RPM-based distros. See [[#Building]] below if you want to compile vzctl from source.}}&lt;br /&gt;
&lt;br /&gt;
First, set up OpenVZ yum repository. Download [[download:openvz.repo|openvz.repo]] file and put it to your &amp;lt;code&amp;gt;/etc/yum.repos.d/&amp;lt;/code&amp;gt; repository,&lt;br /&gt;
and import OpenVZ GPG key used for signing RPM packages. This can be achieved by the following commands, as root:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
wget -P /etc/yum.repos.d/ http://download.openvz.org/openvz.repo&lt;br /&gt;
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
In case you can not cd to /etc/yum.repos.d, it means either yum is not installed on your system, or yum version is too old.&lt;br /&gt;
&lt;br /&gt;
Then, install vzctl-core package:&lt;br /&gt;
&lt;br /&gt;
 yum install vzctl-core&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For supported features, usage is expected to be the same as standard vzctl tool. See {{man|vzctl|8}} for more information.&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
{{Note|IP mode networking (--ipadd / --ipdel) is currently not supported}}&lt;br /&gt;
&lt;br /&gt;
Networking is available through the switches &amp;lt;code&amp;gt;--netdev_add&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--netif_add&amp;lt;/code&amp;gt;, and their respective deletion counterparts.&lt;br /&gt;
Unfortunately now it requires some manual configuration.&lt;br /&gt;
&lt;br /&gt;
== Bridged networking ==&lt;br /&gt;
&lt;br /&gt;
The following example assumes&lt;br /&gt;
* you already have a bridge configured on the host system&lt;br /&gt;
* bridge interface name is virbr0&lt;br /&gt;
* CT is running Red Hat like distro (CentOS)&lt;br /&gt;
&lt;br /&gt;
 vzctl set $CTID --netif_add eth0,,,,virbr0 --save&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;NETWORKING=yes&amp;quot; &amp;gt; /vz/private/$CTID/etc/sysconfig/network&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /vz/private/$CTID/etc/sysconfig/network-scripts/ifcfg-eth0&lt;br /&gt;
 DEVICE=eth0&lt;br /&gt;
 BOOTPROTO=dhcp&lt;br /&gt;
 ONBOOT=yes&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 vzctl start $CTID&lt;br /&gt;
&lt;br /&gt;
After this, you can find CT IP using this:&lt;br /&gt;
 # ip netns exec $CTID ip address list&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
{{Note|We recommend using [[Download/kernel/rhel6|OpenVZ kernel]] for features, stability and security}}&lt;br /&gt;
&lt;br /&gt;
The following vzctl commands are not working at all with the non-OpenVZ kernel:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;quotaon&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotaoff&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotainit&amp;lt;/code&amp;gt; (vzquota-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;convert&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;compact&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;snapshot*&amp;lt;/code&amp;gt; (ploop-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;console&amp;lt;/code&amp;gt; (needs a virtual /dev/console, /dev/ttyN device)&lt;br /&gt;
* &amp;lt;code&amp;gt;chkpnt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;restore&amp;lt;/code&amp;gt; (currently need OpenVZ-kernel-specific checkpointing, [http://criu.org/ CRIU] will be supported later)&lt;br /&gt;
&lt;br /&gt;
The following binaries are not ported to work on top of upstream kernel:&lt;br /&gt;
* vzlist&lt;br /&gt;
* vzcalc&lt;br /&gt;
* vzcfgvalidate&lt;br /&gt;
* vzcpucheck&lt;br /&gt;
* vzmemcheck&lt;br /&gt;
* vzmigrate&lt;br /&gt;
* vzeventd&lt;br /&gt;
* vzpid&lt;br /&gt;
* vzsplit&lt;br /&gt;
* vzubc&lt;br /&gt;
&lt;br /&gt;
=== /proc and /sys ===&lt;br /&gt;
Software that depend on information supplied by the proc filesystem may not work correctly, since there is not a full solution for full /proc virtualization. For instance, /proc/stat is not yet virtualized, and top will show distorted values.&lt;br /&gt;
&lt;br /&gt;
=== Resource management ===&lt;br /&gt;
&lt;br /&gt;
With non-OpenVZ kernel, setting resources like &amp;lt;code&amp;gt;--ram&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cpuunits&amp;lt;/code&amp;gt; works, but there their effect is dependent on what the current kernel supports, through the cgroups subsystem. When a particular cgroup file is present, it will be used. Currently, vzctl will search for the following files:&lt;br /&gt;
* cpu.cfs_quota_us&lt;br /&gt;
* cpu.shares&lt;br /&gt;
* cpuset.cpus&lt;br /&gt;
* memory.limit_in_bytes&lt;br /&gt;
* memory.memsw.limit_in_bytes&lt;br /&gt;
* memory.kmem.limit_in_bytes&lt;br /&gt;
* memory.kmem.tcp.limit_in_bytes&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
&lt;br /&gt;
In case you don't want to use packages provided by OpenVZ (available from [[Download/vzctl]]), but rather would like to compile vzctl from sources, read on.&lt;br /&gt;
&lt;br /&gt;
=== Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The following software needs to be installed on your system:&lt;br /&gt;
&lt;br /&gt;
* iproute2 &amp;gt;= 3.0.0 (runtime only)&lt;br /&gt;
* libcgroup &amp;gt;= 0.38&lt;br /&gt;
&lt;br /&gt;
=== Download ===&lt;br /&gt;
&lt;br /&gt;
You can get the latest released version from [[Download/vzctl/{{Latest vzctl}}#sources]] or directly from [[download:utils/vzctl/current/src/]].&lt;br /&gt;
&lt;br /&gt;
If you are living on the bleeding edge, get vzctl sources from git. Then run autogen.sh to recreate auto* files:&lt;br /&gt;
&lt;br /&gt;
 git clone &amp;lt;nowiki&amp;gt;git://git.openvz.org/pub/vzctl&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 cd vzctl&lt;br /&gt;
 ./autogen.sh&lt;br /&gt;
&lt;br /&gt;
=== Compile ===&lt;br /&gt;
&lt;br /&gt;
Usual &amp;lt;code&amp;gt;./configure &amp;amp;&amp;amp; make&amp;lt;/code&amp;gt; should do. But you probably want to specify more options. It makes sense to:&lt;br /&gt;
&lt;br /&gt;
* enable cgroup support&lt;br /&gt;
* add &amp;lt;code&amp;gt;--without-ploop&amp;lt;/code&amp;gt; (unless you want [[ploop]] compiled it) because otherwise you will need ploop lib headers (available from [[Download/ploop]]).&lt;br /&gt;
* enable bash completion support&lt;br /&gt;
* set prefix to /usr&lt;br /&gt;
&lt;br /&gt;
See &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt; output for more details and options available.&lt;br /&gt;
&lt;br /&gt;
So, the command will look like:&lt;br /&gt;
&lt;br /&gt;
 $ ./configure --with-cgroup --without-ploop --enable-bashcomp --prefix=/usr &lt;br /&gt;
 $ make -j4&lt;br /&gt;
&lt;br /&gt;
=== Install ===&lt;br /&gt;
&lt;br /&gt;
 # make install&lt;br /&gt;
=== FAQ ===&lt;br /&gt;
&lt;br /&gt;
# A container doesn't boot and udevd is in a process list&lt;br /&gt;
#: udev doesn't work, because uevent-s are not virtualized yet. If you don't know how to disable it, you can remove the package.&lt;br /&gt;
# You can't enter in CT and vzctl returns en error about pty&lt;br /&gt;
 Unable to open pty: No such file or directory&lt;br /&gt;
#: If a CT is executed in a user namespace, devpts must be mounted with the newinstance option. You can add this option in /etc/fstab.&lt;/div&gt;</summary>
		<author><name>Avagin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=12931</id>
		<title>Vzctl for upstream kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=12931"/>
		<updated>2012-09-13T14:59:38Z</updated>

		<summary type="html">&lt;p&gt;Avagin: /* Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since version 4.0, vzctl tool can be used with upstream (non-OpenVZ) Linux kernels (that essentially means any recent 3.x kernel). At the moment, it provides just basic functionality.&lt;br /&gt;
It is currently possible to create and start a container with the same steps as one would use for a normal OpenVZ container. Other features may be present with limited functionality, while some are not present at all.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Running vzctl on upstream kernels is considered an experimental feature. See [[#Limitatons]] below.}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Note|This section describes installation for RPM-based distros. See [[#Building]] below if you want to compile vzctl from source.}}&lt;br /&gt;
&lt;br /&gt;
First, set up OpenVZ yum repository. Download [[download:openvz.repo|openvz.repo]] file and put it to your &amp;lt;code&amp;gt;/etc/yum.repos.d/&amp;lt;/code&amp;gt; repository,&lt;br /&gt;
and import OpenVZ GPG key used for signing RPM packages. This can be achieved by the following commands, as root:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
wget -P /etc/yum.repos.d/ http://download.openvz.org/openvz.repo&lt;br /&gt;
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
In case you can not cd to /etc/yum.repos.d, it means either yum is not installed on your system, or yum version is too old.&lt;br /&gt;
&lt;br /&gt;
Then, install vzctl-core package:&lt;br /&gt;
&lt;br /&gt;
 yum install vzctl-core&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For supported features, usage is expected to be the same as standard vzctl tool. See {{man|vzctl|8}} for more information.&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
&lt;br /&gt;
Networking is available through the switches --netdev_add, --netif_add, and their respective deletion counterparts.&lt;br /&gt;
In this case [[Virtual Ethernet device]] is added in [[CT]].&lt;br /&gt;
&lt;br /&gt;
 One life hack may be useful while &amp;quot;vzctl enter&amp;quot; doesn't work.&lt;br /&gt;
 If you use DHCP and don't know which an IP address is in CT, you can find it in  /vz/root/[CTID]/var/log/message.&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;ip netns exec&amp;quot; can help you too, but it doesn't work sometimes.&lt;br /&gt;
 $ ip netns exec [CTID] ip a&lt;br /&gt;
&lt;br /&gt;
IP mode networking (--ipadd / --ipdel) is currently not supported.&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
The following vzctl commands are not working at all:&lt;br /&gt;
* &amp;lt;code&amp;gt;quotaon&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotaoff&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotainit&amp;lt;/code&amp;gt; (vzquota-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;convert&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;compact&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;snapshot*&amp;lt;/code&amp;gt; (ploop-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;console&amp;lt;/code&amp;gt; (needs a virtual /dev/console, /dev/ttyN device)&lt;br /&gt;
* &amp;lt;code&amp;gt;enter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;exec&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;runscript&amp;lt;/code&amp;gt; (need pidns entering support)&lt;br /&gt;
* &amp;lt;code&amp;gt;chkpnt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;restore&amp;lt;/code&amp;gt; (currently need OpenVZ-kernel-specific checkpointing, [http://crui.org/ CRIU] will be supported later)&lt;br /&gt;
&lt;br /&gt;
The following commands have severe limitations:&lt;br /&gt;
* &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;. A container can be stopped from inside (say if one is connected to CT over ssh) in case the underlying kernel supports rebooting a PID namespace (&amp;gt; 3.4). Using vzctl, the &amp;quot;stop&amp;quot; command is not supported, unless accompanied by the --fast switch, which will simply forceably kill all processes in the container.&lt;br /&gt;
&lt;br /&gt;
The following binaries are not ported to work on top of upstream kernel:&lt;br /&gt;
* vzlist&lt;br /&gt;
* vzcalc&lt;br /&gt;
* vzcfgvalidate&lt;br /&gt;
* vzcpucheck&lt;br /&gt;
* vzmemcheck&lt;br /&gt;
* vzmigrate&lt;br /&gt;
* vzeventd&lt;br /&gt;
* vzpid&lt;br /&gt;
* vzsplit&lt;br /&gt;
* vzubc&lt;br /&gt;
&lt;br /&gt;
=== /proc and /sys ===&lt;br /&gt;
Software that depend on information supplied by the proc filesystem may not work correctly, since there is not a full solution for full /proc virtualization. For instance, /proc/stat is not yet virtualized, and top will show distorted values.&lt;br /&gt;
&lt;br /&gt;
=== Resource management ===&lt;br /&gt;
&lt;br /&gt;
Setting resources like &amp;lt;code&amp;gt;--ram&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cpuunits&amp;lt;/code&amp;gt; work, but there their effect is dependent on what the current kernel supports, through the cgroups subsystem. When a particular cgroup file is present, it will be used. Currently, vzctl will search for the following files:&lt;br /&gt;
* cpu.cfs_quota_us&lt;br /&gt;
* cpu.shares&lt;br /&gt;
* cpuset.cpus&lt;br /&gt;
* memory.limit_in_bytes&lt;br /&gt;
* memory.memsw.limit_in_bytes&lt;br /&gt;
* memory.kmem.limit_in_bytes&lt;br /&gt;
* memory.kmem.tcp.limit_in_bytes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
&lt;br /&gt;
=== Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The following software needs to be installed on your system:&lt;br /&gt;
&lt;br /&gt;
* iproute2 &amp;gt;= 3.0.0 (runtime only)&lt;br /&gt;
* libcgroup &amp;gt;= 0.38&lt;br /&gt;
&lt;br /&gt;
=== Download ===&lt;br /&gt;
&lt;br /&gt;
You can get the latest released version from [[Download/vzctl/{{Latest vzctl}}#sources]] or directly from [[download:utils/vzctl/current/src/]].&lt;br /&gt;
&lt;br /&gt;
If you are living on the bleeding edge, get vzctl sources from git. Then run autogen.sh to recreate auto* files:&lt;br /&gt;
&lt;br /&gt;
 git clone git://git.openvz.org/pub/vzctl&lt;br /&gt;
 cd vzctl&lt;br /&gt;
 ./autogen.sh&lt;br /&gt;
&lt;br /&gt;
=== Compile ===&lt;br /&gt;
&lt;br /&gt;
Usual ./confi&lt;br /&gt;
&lt;br /&gt;
t makes sense to add &amp;lt;code&amp;gt;--without-ploop&amp;lt;/code&amp;gt; (unless you want ploop compiled it) because otherwise you will need ploop lib headers.&lt;br /&gt;
&lt;br /&gt;
 $ ./configure --with-cgroup --without-ploop&lt;/div&gt;</summary>
		<author><name>Avagin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=12930</id>
		<title>Vzctl for upstream kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=12930"/>
		<updated>2012-09-13T13:55:43Z</updated>

		<summary type="html">&lt;p&gt;Avagin: /* Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since version 4.0, vzctl tool can be used with upstream (non-OpenVZ) Linux kernels (that essentially means any recent 3.x kernel). At the moment, it provides just basic functionality.&lt;br /&gt;
It is currently possible to create and start a container with the same steps as one would use for a normal OpenVZ container. Other features may be present with limited functionality, while some are not present at all.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Running vzctl on upstream kernels is considered an experimental feature. See [[#Limitatons]] below.}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Note|This section describes installation for RPM-based distros. See [[#Building]] below if you want to compile vzctl from source.}}&lt;br /&gt;
&lt;br /&gt;
First, set up OpenVZ yum repository. Download [[download:openvz.repo|openvz.repo]] file and put it to your &amp;lt;code&amp;gt;/etc/yum.repos.d/&amp;lt;/code&amp;gt; repository,&lt;br /&gt;
and import OpenVZ GPG key used for signing RPM packages. This can be achieved by the following commands, as root:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
wget -P /etc/yum.repos.d/ http://download.openvz.org/openvz.repo&lt;br /&gt;
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
In case you can not cd to /etc/yum.repos.d, it means either yum is not installed on your system, or yum version is too old.&lt;br /&gt;
&lt;br /&gt;
Then, install vzctl-core package:&lt;br /&gt;
&lt;br /&gt;
 yum install vzctl-core&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For supported features, usage is expected to be the same as standard vzctl tool. See {{man|vzctl|8}} for more information.&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
&lt;br /&gt;
Networking is available through the switches --netdev_add, --netif_add, and their respective deletion counterparts.&lt;br /&gt;
In this case [[Virtual Ethernet device]] is added in [[CT]].&lt;br /&gt;
&lt;br /&gt;
 One life hack may be useful while &amp;quot;vzctl enter&amp;quot; doesn't work.&lt;br /&gt;
 If you use DHCP and don't know which an IP address is in CT, you can find it in  /vz/root/[CTID]/var/log/message.&lt;br /&gt;
&lt;br /&gt;
IP mode networking (--ipadd / --ipdel) is currently not supported.&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
The following vzctl commands are not working at all:&lt;br /&gt;
* &amp;lt;code&amp;gt;quotaon&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotaoff&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotainit&amp;lt;/code&amp;gt; (vzquota-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;convert&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;compact&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;snapshot*&amp;lt;/code&amp;gt; (ploop-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;console&amp;lt;/code&amp;gt; (needs a virtual /dev/console, /dev/ttyN device)&lt;br /&gt;
* &amp;lt;code&amp;gt;enter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;exec&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;runscript&amp;lt;/code&amp;gt; (need pidns entering support)&lt;br /&gt;
* &amp;lt;code&amp;gt;chkpnt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;restore&amp;lt;/code&amp;gt; (currently need OpenVZ-kernel-specific checkpointing, [http://crui.org/ CRIU] will be supported later)&lt;br /&gt;
&lt;br /&gt;
The following commands have severe limitations:&lt;br /&gt;
* &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;. A container can be stopped from inside (say if one is connected to CT over ssh) in case the underlying kernel supports rebooting a PID namespace (&amp;gt; 3.4). Using vzctl, the &amp;quot;stop&amp;quot; command is not supported, unless accompanied by the --fast switch, which will simply forceably kill all processes in the container.&lt;br /&gt;
&lt;br /&gt;
The following binaries are not ported to work on top of upstream kernel:&lt;br /&gt;
* vzlist&lt;br /&gt;
* vzcalc&lt;br /&gt;
* vzcfgvalidate&lt;br /&gt;
* vzcpucheck&lt;br /&gt;
* vzmemcheck&lt;br /&gt;
* vzmigrate&lt;br /&gt;
* vzeventd&lt;br /&gt;
* vzpid&lt;br /&gt;
* vzsplit&lt;br /&gt;
* vzubc&lt;br /&gt;
&lt;br /&gt;
=== /proc and /sys ===&lt;br /&gt;
Software that depend on information supplied by the proc filesystem may not work correctly, since there is not a full solution for full /proc virtualization. For instance, /proc/stat is not yet virtualized, and top will show distorted values.&lt;br /&gt;
&lt;br /&gt;
=== Resource management ===&lt;br /&gt;
&lt;br /&gt;
Setting resources like &amp;lt;code&amp;gt;--ram&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cpuunits&amp;lt;/code&amp;gt; work, but there their effect is dependent on what the current kernel supports, through the cgroups subsystem. When a particular cgroup file is present, it will be used. Currently, vzctl will search for the following files:&lt;br /&gt;
* cpu.cfs_quota_us&lt;br /&gt;
* cpu.shares&lt;br /&gt;
* cpuset.cpus&lt;br /&gt;
* memory.limit_in_bytes&lt;br /&gt;
* memory.memsw.limit_in_bytes&lt;br /&gt;
* memory.kmem.limit_in_bytes&lt;br /&gt;
* memory.kmem.tcp.limit_in_bytes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
&lt;br /&gt;
=== Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The following software needs to be installed on your system:&lt;br /&gt;
&lt;br /&gt;
* iproute2 &amp;gt;= 3.0.0 (runtime only)&lt;br /&gt;
* libcgroup &amp;gt;= 0.38&lt;br /&gt;
&lt;br /&gt;
=== Download ===&lt;br /&gt;
&lt;br /&gt;
You can get the latest released version from [[Download/vzctl/{{Latest vzctl}}#sources]] or directly from [[download:utils/vzctl/current/src/]].&lt;br /&gt;
&lt;br /&gt;
If you are living on the bleeding edge, get vzctl sources from git. Then run autogen.sh to recreate auto* files:&lt;br /&gt;
&lt;br /&gt;
 git clone git://git.openvz.org/pub/vzctl&lt;br /&gt;
 cd vzctl&lt;br /&gt;
 ./autogen.sh&lt;br /&gt;
&lt;br /&gt;
=== Compile ===&lt;br /&gt;
&lt;br /&gt;
Usual ./confi&lt;br /&gt;
&lt;br /&gt;
t makes sense to add &amp;lt;code&amp;gt;--without-ploop&amp;lt;/code&amp;gt; (unless you want ploop compiled it) because otherwise you will need ploop lib headers.&lt;br /&gt;
&lt;br /&gt;
 $ ./configure --with-cgroup --without-ploop&lt;/div&gt;</summary>
		<author><name>Avagin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=12929</id>
		<title>Vzctl for upstream kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Vzctl_for_upstream_kernel&amp;diff=12929"/>
		<updated>2012-09-13T13:55:12Z</updated>

		<summary type="html">&lt;p&gt;Avagin: /* Networking */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since version 4.0, vzctl tool can be used with upstream (non-OpenVZ) Linux kernels (that essentially means any recent 3.x kernel). At the moment, it provides just basic functionality.&lt;br /&gt;
It is currently possible to create and start a container with the same steps as one would use for a normal OpenVZ container. Other features may be present with limited functionality, while some are not present at all.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Running vzctl on upstream kernels is considered an experimental feature. See [[#Limitatons]] below.}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Note|This section describes installation for RPM-based distros. See [[#Building]] below if you want to compile vzctl from source.}}&lt;br /&gt;
&lt;br /&gt;
First, set up OpenVZ yum repository. Download [[download:openvz.repo|openvz.repo]] file and put it to your &amp;lt;code&amp;gt;/etc/yum.repos.d/&amp;lt;/code&amp;gt; repository,&lt;br /&gt;
and import OpenVZ GPG key used for signing RPM packages. This can be achieved by the following commands, as root:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
wget -P /etc/yum.repos.d/ http://download.openvz.org/openvz.repo&lt;br /&gt;
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
In case you can not cd to /etc/yum.repos.d, it means either yum is not installed on your system, or yum version is too old.&lt;br /&gt;
&lt;br /&gt;
Then, install vzctl-core package:&lt;br /&gt;
&lt;br /&gt;
 yum install vzctl-core&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For supported features, usage is expected to be the same as standard vzctl tool. See {{man|vzctl|8}} for more information.&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
&lt;br /&gt;
Networking is available through the switches --netdev_add, --netif_add, and their respective deletion counterparts.&lt;br /&gt;
In this case [[Virtual Ethernet device]] is added in [[CT]].&lt;br /&gt;
&lt;br /&gt;
 One life hack may be useful while &amp;quot;vzctl enter&amp;quot; doesn't work. If you use DHCP and don't know which an IP address is in CT, you can find it in  /vz/root/[CTID]/var/log/message.&lt;br /&gt;
&lt;br /&gt;
IP mode networking (--ipadd / --ipdel) is currently not supported.&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
The following vzctl commands are not working at all:&lt;br /&gt;
* &amp;lt;code&amp;gt;quotaon&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotaoff&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;quotainit&amp;lt;/code&amp;gt; (vzquota-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;convert&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;compact&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;snapshot*&amp;lt;/code&amp;gt; (ploop-specific)&lt;br /&gt;
* &amp;lt;code&amp;gt;console&amp;lt;/code&amp;gt; (needs a virtual /dev/console, /dev/ttyN device)&lt;br /&gt;
* &amp;lt;code&amp;gt;enter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;exec&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;runscript&amp;lt;/code&amp;gt; (need pidns entering support)&lt;br /&gt;
* &amp;lt;code&amp;gt;chkpnt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;restore&amp;lt;/code&amp;gt; (currently need OpenVZ-kernel-specific checkpointing, [http://crui.org/ CRIU] will be supported later)&lt;br /&gt;
&lt;br /&gt;
The following commands have severe limitations:&lt;br /&gt;
* &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;. A container can be stopped from inside (say if one is connected to CT over ssh) in case the underlying kernel supports rebooting a PID namespace (&amp;gt; 3.4). Using vzctl, the &amp;quot;stop&amp;quot; command is not supported, unless accompanied by the --fast switch, which will simply forceably kill all processes in the container.&lt;br /&gt;
&lt;br /&gt;
The following binaries are not ported to work on top of upstream kernel:&lt;br /&gt;
* vzlist&lt;br /&gt;
* vzcalc&lt;br /&gt;
* vzcfgvalidate&lt;br /&gt;
* vzcpucheck&lt;br /&gt;
* vzmemcheck&lt;br /&gt;
* vzmigrate&lt;br /&gt;
* vzeventd&lt;br /&gt;
* vzpid&lt;br /&gt;
* vzsplit&lt;br /&gt;
* vzubc&lt;br /&gt;
&lt;br /&gt;
=== /proc and /sys ===&lt;br /&gt;
Software that depend on information supplied by the proc filesystem may not work correctly, since there is not a full solution for full /proc virtualization. For instance, /proc/stat is not yet virtualized, and top will show distorted values.&lt;br /&gt;
&lt;br /&gt;
=== Resource management ===&lt;br /&gt;
&lt;br /&gt;
Setting resources like &amp;lt;code&amp;gt;--ram&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cpuunits&amp;lt;/code&amp;gt; work, but there their effect is dependent on what the current kernel supports, through the cgroups subsystem. When a particular cgroup file is present, it will be used. Currently, vzctl will search for the following files:&lt;br /&gt;
* cpu.cfs_quota_us&lt;br /&gt;
* cpu.shares&lt;br /&gt;
* cpuset.cpus&lt;br /&gt;
* memory.limit_in_bytes&lt;br /&gt;
* memory.memsw.limit_in_bytes&lt;br /&gt;
* memory.kmem.limit_in_bytes&lt;br /&gt;
* memory.kmem.tcp.limit_in_bytes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
&lt;br /&gt;
=== Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The following software needs to be installed on your system:&lt;br /&gt;
&lt;br /&gt;
* iproute2 &amp;gt;= 3.0.0 (runtime only)&lt;br /&gt;
* libcgroup &amp;gt;= 0.38&lt;br /&gt;
&lt;br /&gt;
=== Download ===&lt;br /&gt;
&lt;br /&gt;
You can get the latest released version from [[Download/vzctl/{{Latest vzctl}}#sources]] or directly from [[download:utils/vzctl/current/src/]].&lt;br /&gt;
&lt;br /&gt;
If you are living on the bleeding edge, get vzctl sources from git. Then run autogen.sh to recreate auto* files:&lt;br /&gt;
&lt;br /&gt;
 git clone git://git.openvz.org/pub/vzctl&lt;br /&gt;
 cd vzctl&lt;br /&gt;
 ./autogen.sh&lt;br /&gt;
&lt;br /&gt;
=== Compile ===&lt;br /&gt;
&lt;br /&gt;
Usual ./confi&lt;br /&gt;
&lt;br /&gt;
t makes sense to add &amp;lt;code&amp;gt;--without-ploop&amp;lt;/code&amp;gt; (unless you want ploop compiled it) because otherwise you will need ploop lib headers.&lt;br /&gt;
&lt;br /&gt;
 $ ./configure --with-cgroup --without-ploop&lt;/div&gt;</summary>
		<author><name>Avagin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=VPN_via_the_TUN/TAP_device&amp;diff=10815</id>
		<title>VPN via the TUN/TAP device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=VPN_via_the_TUN/TAP_device&amp;diff=10815"/>
		<updated>2011-08-18T11:59:45Z</updated>

		<summary type="html">&lt;p&gt;Avagin: Someone joked about net_admin. Do it never, it's security hole.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article describes how to use VPN via the TUN/TAP device inside a [[container]].&lt;br /&gt;
&lt;br /&gt;
== Kernel TUN/TAP support ==&lt;br /&gt;
OpenVZ supports VPN inside a container via kernel TUN/TAP module and device.&lt;br /&gt;
To allow container #101 to use the TUN/TAP device the following should be done:&lt;br /&gt;
&lt;br /&gt;
Make sure the '''tun''' module has been already loaded on the [[hardware node]]:&lt;br /&gt;
 lsmod | grep tun&lt;br /&gt;
&lt;br /&gt;
If it is not there, use the following command to load '''tun''' module:&lt;br /&gt;
 modprobe tun&lt;br /&gt;
&lt;br /&gt;
To make sure that '''tun''' module will be automatically loaded on every reboot you can also add it or into &amp;lt;code&amp;gt;/etc/modules.conf&amp;lt;/code&amp;gt; (on RHEL see &amp;lt;code&amp;gt;/etc/sysconfig/modules/&amp;lt;/code&amp;gt; directory).&lt;br /&gt;
&lt;br /&gt;
== Granting container an access to TUN/TAP ==&lt;br /&gt;
Allow your container to use the tun/tap device by running the following commands on the host node:&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --devnodes net/tun:rw --save&lt;br /&gt;
&lt;br /&gt;
== Configuring VPN inside container ==&lt;br /&gt;
After the configuration steps above are done it is possible to use VPN software working with TUN/TAP inside&lt;br /&gt;
container just like on a usual standalone Linux box.&lt;br /&gt;
&lt;br /&gt;
The following software can be used for VPN with TUN/TAP:&lt;br /&gt;
* Tinc (http://tinc-vpn.org)&lt;br /&gt;
* OpenVPN (http://openvpn.net)&lt;br /&gt;
* Virtual TUNnel (http://vtun.sourceforge.net)&lt;br /&gt;
&lt;br /&gt;
== Reaching hosts behind VPN container ==&lt;br /&gt;
In order to reach hosts behind VPN container you must configure it to use a VETH interface instead a VENET one, at least with an OpenVPN server.&lt;br /&gt;
&lt;br /&gt;
With a VENET interface you will only reach the VPN container.&lt;br /&gt;
&lt;br /&gt;
To use a VETH device follow [[Veth]] article.&lt;br /&gt;
&lt;br /&gt;
If you insist on using a VENET interface and need to reach hosts behind the OpenVPN VE then you can use source NAT. You need to mangle source packets so that they appear to originate from the OpenVPN server VE.&lt;br /&gt;
&lt;br /&gt;
== Tinc problems ==&lt;br /&gt;
&lt;br /&gt;
Using the default venet0:0 interface on the container, tinc seems to have problems as it complains the port 655 is already used on 0.0.0.0.&lt;br /&gt;
&lt;br /&gt;
Netstat shows that the port 655 is available:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@132 / [3]# netstat -l&lt;br /&gt;
Active Internet connections (only servers)&lt;br /&gt;
Proto Recv-Q Send-Q Local Address           Foreign Address         State      &lt;br /&gt;
tcp        0      0 localhost.localdom:8001 *:*                     LISTEN     &lt;br /&gt;
tcp        0      0 *:2223                  *:*                     LISTEN     &lt;br /&gt;
tcp6       0      0 [::]:2223               [::]:*                  LISTEN     &lt;br /&gt;
udp6       0      0 [::]:talk               [::]:*                             &lt;br /&gt;
udp6       0      0 [::]:ntalk              [::]:*                             &lt;br /&gt;
Active UNIX domain sockets (only servers)&lt;br /&gt;
Proto RefCnt Flags       Type       State         I-Node   Path&lt;br /&gt;
unix  2      [ ACC ]     STREAM     LISTENING     4831020  /var/run/uml-utilities/uml_switch.ctl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starting the Tincd daemon where it complains that port 655 is not available:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@132 / [4]# tincd -n myvpn&lt;br /&gt;
root@132 / [5]# tail -f /var/log/syslog&lt;br /&gt;
Jul 26 14:08:01 132 /USR/SBIN/CRON[15159]: (root) CMD (   cd / &amp;amp;&amp;amp; run-parts --report /etc/cron.hourly)&lt;br /&gt;
Jul 26 14:37:42 132 -- MARK --&lt;br /&gt;
Jul 26 14:57:42 132 -- MARK --&lt;br /&gt;
Jul 26 15:08:01 132 /USR/SBIN/CRON[15178]: (root) CMD (   cd / &amp;amp;&amp;amp; run-parts --report /etc/cron.hourly)&lt;br /&gt;
Jul 26 15:11:23 132 tinc.myvpn[15139]: Got TERM signal&lt;br /&gt;
Jul 26 15:11:23 132 tinc.myvpn[15139]: Terminating&lt;br /&gt;
Jul 26 15:11:37 132 tinc.myvpn[15191]: tincd 1.0.8 (Aug 14 2007 13:51:23) starting, debug level 0&lt;br /&gt;
Jul 26 15:11:37 132 tinc.myvpn[15191]: /dev/net/tun is a Linux tun/tap device (tun mode)&lt;br /&gt;
Jul 26 15:11:37 132 tinc.myvpn[15191]: Can't bind to 0.0.0.0 port 655/tcp: Address already in use&lt;br /&gt;
Jul 26 15:11:37 132 tinc.myvpn[15191]: Ready&lt;br /&gt;
^C&lt;br /&gt;
root@132 / [6]# &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An echo to Bindv6only (see [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=440150 discussion here]) seems to resolve the problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@132 / [12]# echo 1 &amp;gt; /proc/sys/net/ipv6/bindv6only&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or put in your /etc/sysctl.conf file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
net.ipv6.bindv6only = 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply the changes with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@132 / [14]# sysctl -p&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The tunctl problem ==&lt;br /&gt;
Unfortunately, you are limited to [http://forum.openvz.org/index.php?t=msg&amp;amp;th=4280&amp;amp;goto=22066&amp;amp;#msg_22066 non-persistent tunnels inside the VEs]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# tunctl&lt;br /&gt;
enabling TUNSETPERSIST: Operation not permitted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get a patched tunctl [https://github.com/xl0/uml-utilities here], and run it with the -n option. It will create a non-persistent tun device and sleep instead of terminating, to keep the device from deletion. To remove the tunnel, kill the tunctl process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If NAT is needed within the VE, this error will occur on attempts to use NAT:&lt;br /&gt;
&lt;br /&gt;
 # iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j MASQUERADE&lt;br /&gt;
 iptables v1.4.3.2: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)&lt;br /&gt;
 Perhaps iptables or your kernel needs to be upgraded.&lt;br /&gt;
&lt;br /&gt;
The solution is given here:&lt;br /&gt;
&lt;br /&gt;
 http://kb.parallels.com/en/5228&lt;br /&gt;
&lt;br /&gt;
Also see page 69-70 of:&lt;br /&gt;
&lt;br /&gt;
 http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf&lt;br /&gt;
&lt;br /&gt;
Note that the above steps do not solve the problem if a gentoo VE sits on a Centos HN; it's still an unsolved mystery.&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://vtun.sourceforge.net Virtual TUNnel]&lt;br /&gt;
* [http://openvpn.net OpenVPN]&lt;br /&gt;
* [http://tinc-vpn.org Tinc]&lt;br /&gt;
* [http://openvpn.net/index.php/access-server/howto-openvpn-as/186-how-to-run-access-server-on-a-vps-container.html How to run OpenVPN Access Server in OpenVZ]&lt;br /&gt;
* [http://kb.parallels.com/en/696 Parallels KB#696: Is VPN via the TUN/TAP device supported inside a Container?]&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Networking]]&lt;/div&gt;</summary>
		<author><name>Avagin</name></author>
		
	</entry>
</feed>