<?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=Laboa</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=Laboa"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Laboa"/>
	<updated>2026-05-13T18:01:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=6507</id>
		<title>Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Virtual_Ethernet_device&amp;diff=6507"/>
		<updated>2008-10-12T21:02:24Z</updated>

		<summary type="html">&lt;p&gt;Laboa: /* method for vzctl version &amp;lt;= 3.0.22 */ Add hint to possibly subst. VEID for CTID&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Virtual Ethernet device''' is an Ethernet-like device which can be used&lt;br /&gt;
inside a [[container]]. Unlike [[venet]] network device, veth device&lt;br /&gt;
has a MAC address, therefore it can be used in configurations, when veth&lt;br /&gt;
is bridged to ethX or other device and container's user fully sets up&lt;br /&gt;
his networking himself, including IPs, gateways etc.&lt;br /&gt;
&lt;br /&gt;
Virtual Ethernet device consist of two Ethernet devices --&lt;br /&gt;
the one in [[CT0]] and another one in CT. These devices are connected&lt;br /&gt;
to each other, so if a packet goes to one&lt;br /&gt;
device it will come out from the other device.&lt;br /&gt;
&lt;br /&gt;
== Virtual Ethernet device usage ==&lt;br /&gt;
&lt;br /&gt;
=== Kernel module ===&lt;br /&gt;
First of all, make sure the &amp;lt;code&amp;gt;vzethdev&amp;lt;/code&amp;gt; module is loaded:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# lsmod | grep vzeth&lt;br /&gt;
vzethdev                8224  0&lt;br /&gt;
vzmon                  35164  5 vzethdev,vznetdev,vzrst,vzcpt&lt;br /&gt;
vzdev                   3080  4 vzethdev,vznetdev,vzmon,vzdquota&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not loaded, load it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# modprobe vzethdev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|in vzctl &amp;lt; 3.0.11, vzethdev is not autoloaded by &amp;lt;code&amp;gt;/etc/init.d/vz&amp;lt;/code&amp;gt; script, so you have to edit it to load this module.}}&lt;br /&gt;
&lt;br /&gt;
=== MAC addresses ===&lt;br /&gt;
In the below commands, you should use random MAC addresses. Do not use MAC addresses of real eth devices, because this can lead to collisions.&lt;br /&gt;
&lt;br /&gt;
MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.&lt;br /&gt;
&lt;br /&gt;
YOU MAY NOT NEED TO GENERATE MAC ADDRESSES BY HAND BECAUSE vzctl --veth_add&lt;br /&gt;
MAY GENERATE THEM AUTOMATICALLY AS NECESSARY.&lt;br /&gt;
&lt;br /&gt;
Nevertheless, there is a utility script available for generating MAC addresses: http://www.easyvmx.com/software/easymac.sh. It is to be used like this:&lt;br /&gt;
&lt;br /&gt;
 chmod +x easymac.sh&lt;br /&gt;
 ./easymac.sh -R&lt;br /&gt;
&lt;br /&gt;
=== Adding veth to a CT ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt; 3.0.22 ====&lt;br /&gt;
&lt;br /&gt;
 vzctl set &amp;lt;CTID&amp;gt; --netif_add &amp;lt;ifname&amp;gt;[,&amp;lt;mac&amp;gt;,&amp;lt;host_ifname&amp;gt;,&amp;lt;host_mac&amp;gt;,&amp;lt;bridge&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;tt&amp;gt;ifname&amp;lt;/tt&amp;gt; is the Ethernet device name in the CT&lt;br /&gt;
* &amp;lt;tt&amp;gt;mac&amp;lt;/tt&amp;gt; is its MAC address in the CT&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_ifname&amp;lt;/tt&amp;gt;  is the Ethernet device name on the host ([[CT0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;host_mac&amp;lt;/tt&amp;gt; is its MAC address on the host ([[CT0]])&lt;br /&gt;
* &amp;lt;tt&amp;gt;bridge&amp;lt;/tt&amp;gt; is an optional parameter which can be used in custom network start scripts to automatically add  the interface to a bridge.&lt;br /&gt;
&lt;br /&gt;
{{Note|All parameters except &amp;lt;code&amp;gt;ifname&amp;lt;/code&amp;gt; are optional and are automatically generated if not specified.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --netif_add eth0 --save&lt;br /&gt;
&lt;br /&gt;
Or, if you want to specify everything:&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save&lt;br /&gt;
&lt;br /&gt;
Or, if you want to specify the bridge and leave the other values autogenerated:&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --netif_add eth0,,,,vmbr1 --save&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
Syntax is the same as above, but without a &amp;lt;bridge&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
 vzctl set &amp;lt;CTID&amp;gt; --veth_add &amp;lt;dev_name&amp;gt;,&amp;lt;dev_addr&amp;gt;,&amp;lt;ve_dev_name&amp;gt;,&amp;lt;ve_dev_addr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here &lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the Ethernet device name that you are creating on the [[CT0|host system]]&lt;br /&gt;
* &amp;lt;tt&amp;gt;dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_name&amp;lt;/tt&amp;gt; is the corresponding Ethernet device name you are creating on the CT&lt;br /&gt;
* &amp;lt;tt&amp;gt;ve_dev_addr&amp;lt;/tt&amp;gt; is its MAC address&lt;br /&gt;
&lt;br /&gt;
{{Note|this option is incremental, so devices are added to already existing ones.}}&lt;br /&gt;
&lt;br /&gt;
NB there should no spaces after the commas.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node] ifconfig eth0&lt;br /&gt;
...&lt;br /&gt;
HWaddress 00:12:34:56:78:9B&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [host-node] easymac.sh -R&lt;br /&gt;
 00:12:34:56:78:9A&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&lt;br /&gt;
After executing this command &amp;lt;tt&amp;gt;veth&amp;lt;/tt&amp;gt; device will be created for CT 101 and veth configuration will be saved to a CT configuration file.&lt;br /&gt;
Host-side Ethernet device will have &amp;lt;tt&amp;gt;veth101.0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9A&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
CT-side Ethernet device will have &amp;lt;tt&amp;gt;eth0&amp;lt;/tt&amp;gt; name and &amp;lt;tt&amp;gt;00:12:34:56:78:9B&amp;lt;/tt&amp;gt; MAC address.&lt;br /&gt;
&lt;br /&gt;
=== Removing veth from a CT ===&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;gt;= 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
 vzctl set &amp;lt;CTID&amp;gt; --netif_del &amp;lt;dev_name&amp;gt;|all&lt;br /&gt;
&lt;br /&gt;
Here&lt;br /&gt;
* &amp;lt;code&amp;gt;dev_name&amp;lt;/code&amp;gt; is the Ethernet device name in the [[CT]].&lt;br /&gt;
&lt;br /&gt;
{{Note|If you want to remove all Ethernet devices in CT, use &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --netif_del eth0 --save&lt;br /&gt;
&lt;br /&gt;
==== syntax vzctl version &amp;lt; 3.0.14 ====&lt;br /&gt;
&lt;br /&gt;
 vzctl set &amp;lt;CTID&amp;gt; --veth_del &amp;lt;dev_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;tt&amp;gt;dev_name&amp;lt;/tt&amp;gt; is the Ethernet device name in the [[CT0|host system]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 vzctl set 101 --veth_del veth101.0 --save&lt;br /&gt;
&lt;br /&gt;
After executing this command veth device with host-side Ethernet name&lt;br /&gt;
&amp;lt;code&amp;gt;veth101.0&amp;lt;/code&amp;gt; will be removed from CT101 and veth configuration&lt;br /&gt;
will be updated in CT config file.&lt;br /&gt;
&lt;br /&gt;
== Common configurations with virtual Ethernet devices ==&lt;br /&gt;
Module &amp;lt;tt&amp;gt;vzethdev&amp;lt;/tt&amp;gt; must be loaded to operate with veth devices.&lt;br /&gt;
&lt;br /&gt;
=== Simple configuration with virtual Ethernet device ===&lt;br /&gt;
&lt;br /&gt;
==== Start a CT ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# vzctl start 101&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to CT ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# vzctl set 101 --netif_add veth101 --save&lt;br /&gt;
&lt;br /&gt;
This allocates a MAC address and associates it with the host eth0 port.&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in CT0 ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig veth101.0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/veth101.0/proxy_arp&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* These files did not exist for me when trying ([[User:Mrjcleaver|Mrjcleaver]] 14:04, 31 May 2008 (EDT))&lt;br /&gt;
&lt;br /&gt;
==== Configure device in CT ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# vzctl enter 101&lt;br /&gt;
[ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
[ve-101]# /sbin/ip addr add 192.168.0.101 dev eth0&lt;br /&gt;
[ve-101]# /sbin/ip route add default dev eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* Until you ifconfig eth0 it won't appear. When you do it will use the mac address netif_add added earlier&lt;br /&gt;
* 192.168.0.101 is chosen to be an [[unrouteable private ip address]]. Where 101 reminds you that it is node 101.&lt;br /&gt;
* The &amp;quot;ip route&amp;quot; tells all traffic to head to &amp;quot;device eth0&amp;quot;&lt;br /&gt;
* In theory you could [[use dhcpd with OpenVZ]] and dhclient to pick up an DHCP address from your router instead of hardwiring it&lt;br /&gt;
** http://openvz.org/pipermail/users/2005-November/000020.html&lt;br /&gt;
&lt;br /&gt;
==== Add route in [[CT0]] ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# ip route add 192.168.0.101 dev veth101.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Virtual Ethernet device with IPv6 ===&lt;br /&gt;
&lt;br /&gt;
==== Start a [[CT]] ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# vzctl start 101&lt;br /&gt;
&lt;br /&gt;
==== Add veth device to the [[CT]] ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save&lt;br /&gt;
&lt;br /&gt;
==== Configure devices in the [[CT0]] ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# ifconfig veth101.0 0&lt;br /&gt;
 [host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/veth101.0/forwarding&lt;br /&gt;
 [host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/eth0/forwarding&lt;br /&gt;
 [host-node]# echo 1 &amp;gt; /proc/sys/net/ipv6/conf/all/forwarding&lt;br /&gt;
&lt;br /&gt;
==== Configure device in [[CT]] ====&lt;br /&gt;
&lt;br /&gt;
 [host-node]# vzctl enter 101&lt;br /&gt;
 [ve-101]# /sbin/ifconfig eth0 0&lt;br /&gt;
&lt;br /&gt;
==== Start router advertisement daemon (radvd) for IPv6 in CT0 ====&lt;br /&gt;
First you need to edit radvd configuration file. Here is a simple example of &amp;lt;tt&amp;gt;/etc/radv.conf&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface veth101.0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:2400:0:0::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
interface eth0&lt;br /&gt;
{&lt;br /&gt;
        AdvSendAdvert on;&lt;br /&gt;
        MinRtrAdvInterval 3;&lt;br /&gt;
        MaxRtrAdvInterval 10;&lt;br /&gt;
        AdvHomeAgentFlag off;&lt;br /&gt;
&lt;br /&gt;
        prefix 3ffe:0302:0011:0002::/64&lt;br /&gt;
        {&lt;br /&gt;
                AdvOnLink on;&lt;br /&gt;
                AdvAutonomous on;&lt;br /&gt;
                AdvRouterAddr off;&lt;br /&gt;
        };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start radvd:&lt;br /&gt;
&lt;br /&gt;
 [host-node]# /etc/init.d/radvd start&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Add IPv6 addresses to devices in [[CT0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip addr add dev veth101.0 3ffe:2400::212:34ff:fe56:789a/64&lt;br /&gt;
[host-node]# ip addr add dev eth0 3ffe:0302:0011:0002:211:22ff:fe33:4455/64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Ethernet devices can be joined in one bridge ===&lt;br /&gt;
Perform steps 1 - 4 from Simple configuration chapter for several containers and/or veth devices&lt;br /&gt;
&lt;br /&gt;
==== Create bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addbr vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add veth devices to bridge ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth101.n&lt;br /&gt;
[host-node]# brctl addif vzbr0 veth102.0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# brctl addif vzbr0 vethXXX.N&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Configure bridge device ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ifconfig vzbr0 0&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/vzbr0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add routes in [[CT0]] ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# ip route add 192.168.101.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.101.n dev vzbr0&lt;br /&gt;
[host-node]# ip route add 192.168.102.1 dev vzbr0&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
[host-node]# ip route add 192.168.XXX.N dev vzbr0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus you'll have more convinient configuration, i.e. all routes to containers will be through this bridge and containers can communicate with each other even without these routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Making a veth-device persistent ===&lt;br /&gt;
According to http://bugzilla.openvz.org/show_bug.cgi?id=301 , a bug that stopped the veth device persistent was &amp;quot;Obsoleted now when --veth_add/--veth_del are introduced&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See http://wiki.openvz.org/w/index.php?title=Virtual_Ethernet_device&amp;amp;diff=5990&amp;amp;oldid=5989 for a workaround that used to be described in this section.&lt;br /&gt;
&lt;br /&gt;
That's it! At this point, when you restart the CT you should see a new line in the output, indicating that the interface is being configured and a new route being added. And you should be able to ping the host, and to enter the CT and use the network.&lt;br /&gt;
&lt;br /&gt;
=== Making a bridged veth-device persistent ===&lt;br /&gt;
&lt;br /&gt;
Like the above example, here it is how to add the veth device to a bridge in a persistent way. &lt;br /&gt;
&lt;br /&gt;
==== method for vzctl version &amp;gt; 3.0.22 ====&lt;br /&gt;
&lt;br /&gt;
Newer versions of vzctl includes a 'vznetaddbr' script, which makes use of the new &amp;lt;bridge&amp;gt; parameter of the --netif_add switch.&lt;br /&gt;
&lt;br /&gt;
Just create /etc/vz/vznet.conf containing the following.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddbr&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script uses 'vmbr0' as default bridge name when no bridge is specified.&lt;br /&gt;
&lt;br /&gt;
==== method for vzctl version &amp;lt;= 3.0.22 ====&lt;br /&gt;
&lt;br /&gt;
older vzctl doesn't offer an automatic function to do this.&lt;br /&gt;
&lt;br /&gt;
1. First, edit the CT's configuration to specify what is the host bridge , and to indicate that a custom script should be run when starting up a CT.&lt;br /&gt;
* Open up /etc/vz/conf/CTID.conf&lt;br /&gt;
* Comment out any IP_ADDRESS entries to prevent a CTNET-device from being created in the CT&lt;br /&gt;
* Add or change the entry CONFIG_CUSTOMIZED=&amp;quot;yes&amp;quot;&lt;br /&gt;
* Add an entry VZHOSTBR=&amp;quot;&amp;lt;bridge if&amp;gt;&amp;quot; which is the bridge interface (already configured and up), you want to extend.&lt;br /&gt;
&lt;br /&gt;
2. Now to create that &amp;quot;custom script&amp;quot;. The following helper script will check the configuration file for the bridge interface name and for the veth interface, and add the interface to the bridge. Create the script /usr/sbin/vznetaddbr to have the following, and then &amp;lt;code&amp;gt;chmod 0500 /usr/sbin/vznetaddbr&amp;lt;/code&amp;gt; to make it executable.&lt;br /&gt;
&lt;br /&gt;
'''NB:''' You may need to substitute $CTID with $VEID on line 5!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# /usr/sbin/vznetaddbr&lt;br /&gt;
# a script to add virtual network interfaces (veth's) in a CT to a bridge on CT0&lt;br /&gt;
&lt;br /&gt;
CONFIGFILE=/etc/vz/conf/$CTID.conf&lt;br /&gt;
. $CONFIGFILE&lt;br /&gt;
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$VZHOSTIF&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;According to $CONFIGFILE CT$CTID has no veth interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ ! -n &amp;quot;$VZHOSTBR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;According to $CONFIGFILE CT$CTID has no bridge interface configured.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Adding interface $VZHOSTIF to bridge $VZHOSTBR on CT0 for CT$CTID&amp;quot;&lt;br /&gt;
/sbin/ifconfig $VZHOSTIF 0&lt;br /&gt;
echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/proxy_arp&lt;br /&gt;
echo 1 &amp;gt; /proc/sys/net/ipv4/conf/$VZHOSTIF/forwarding&lt;br /&gt;
/usr/sbin/brctl addif $VZHOSTBR $VZHOSTIF&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Now create /etc/vz/vznet.conf containing the following. This is what defines the &amp;quot;custom script&amp;quot; as being the vznetaddbr which you just created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
EXTERNAL_SCRIPT=&amp;quot;/usr/sbin/vznetaddbr&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Of course, the CT's operating system will need to have . Consult the manual for your CT's OS for details.&lt;br /&gt;
&lt;br /&gt;
When the CT is started, the veth specified in the NETIF value is added to the bridge specified. You can check this by doing &amp;lt;code&amp;gt;brctl show&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Inside the CT you can configure the interface statically or using dhcp, as a real interface attached to a switch on the lan.&lt;br /&gt;
&lt;br /&gt;
=== Virtual Ethernet devices + VLAN ===&lt;br /&gt;
This configuration can be done by adding vlan device to the previous configuration.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Virtual network device]]&lt;br /&gt;
* [[Differences between venet and veth]]&lt;br /&gt;
* [[Using private IPs for Hardware Nodes]]&lt;br /&gt;
* Troubleshooting: [[Bridge doesn't forward packets]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-radvd.html Linux IPv6 HOWTO, a chapter about radvd]&lt;br /&gt;
* [http://vireso.blogspot.com/2008/02/2-veth-with-2-brindges-on-openvz-at.html 2 veth with 2 bridges setup]&lt;br /&gt;
&lt;br /&gt;
[[Category: Networking]]&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Laboa</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Virtual_Ethernet_device&amp;diff=6506</id>
		<title>Talk:Virtual Ethernet device</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Virtual_Ethernet_device&amp;diff=6506"/>
		<updated>2008-10-12T20:58:33Z</updated>

		<summary type="html">&lt;p&gt;Laboa: /* Making a bridged veth-device persistent */ reasoning for keeping&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Under Common Configurations -&amp;gt; Simple configuration -&amp;gt; Configure devices in VE0, the example shows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/forwarding&lt;br /&gt;
[host-node]# echo 1 &amp;gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
being run on the host node, VE0.  I don't think this can be correct, because eth0 exists in VE 101, not VE0. {{unsigned|Andrex|01:11, 15 July 2006}}&lt;br /&gt;
&lt;br /&gt;
: This is correct, because we need to enable forwarding on both network interfaces in VE0 (host-node eth0 and veth101.0) to allow the network packets on one network interface (host-node eth0) to be forwarded to another network interface (veth101.0). The same thing with proxy ARP, we need to enable it on host-node eth0 and veth101.0 network interfaces. --[[User:Major|Major]] 08:42, 17 July 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
==Multiple persistent Veth interfaces==&lt;br /&gt;
The script for making a persistent bridge get added to a particular host-bridge on startup VPS/VE, doesn't seem to account for having multiple bridges. I have a bridge to a private lan for administrative functions and a bridge to the public network for inbound connections for services. How might one ensure that the vethVEID.x's are hooked up to the bridges on the host every time the VE is started? --[[User:Btrotter|Btrotter]] 05:34, 17 March 2008 (EDT)&lt;br /&gt;
&lt;br /&gt;
: Please take a look at [[Using private IPs for Hardware Nodes]] and http://vireso.blogspot.com/2008/02/2-veth-with-2-brindges-on-openvz-at.html. There you will find scripts which will help you to manage 2 bridges, and you can simply extend this script to use more then 2 bridges. --[[User:Major|Major]] 15:59, 27 March 2008 (MSK)&lt;br /&gt;
&lt;br /&gt;
==Making a bridged veth-device persistent==&lt;br /&gt;
&lt;br /&gt;
Is this also obsolete, like the section I just deleted? [[User:Mrjcleaver|Mrjcleaver]] 13:35, 31 May 2008 (EDT)&lt;br /&gt;
&lt;br /&gt;
Please leave this in for now! I just needed it today for setup on a Debian HN.&amp;lt;br&amp;gt;&lt;br /&gt;
Also I noted that a crucial word/reference at the end of the following sentence is missing: &amp;quot;4. Of course, the CT's operating system will need to have .&amp;quot; Could someone with wiki-knowledge please restore this (if it was ever known)?&lt;br /&gt;
[[User:Laboa|Laboa]] 22:50, 12. Oct 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
==Configure devices in CT0==&lt;br /&gt;
These devices under /proc didn't exist for me, but I left them in case they are still needed, even with the new vzctl. [[User:Mrjcleaver|Mrjcleaver]] 13:59, 31 May 2008 (EDT)&lt;/div&gt;</summary>
		<author><name>Laboa</name></author>
		
	</entry>
</feed>