Changes

Jump to: navigation, search

Virtual Ethernet device

84 bytes added, 17:23, 31 May 2008
Moved old way to after new way. Deleted old stuff from examples.
MAC addresses must be entered in XX:XX:XX:XX:XX:XX format.
There YOU MAY NOT NEED TO GENERATE MAC ADDRESSES BY HAND BECAUSE vzctl --netif_add MAY GENERATE THEM AUTOMATICALLY AS NECESSARY. 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:
chmod +x easymac.sh
=== Adding veth to a VE ===
 
==== syntax vzctl version >= 3.0.14 ====
 
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]
 
<pre>
vzctl set <VEID> --netif_add <ifname>[,<mac>,<host_ifname>,<host_mac]
</pre>
 
Here
* <tt>ifname</tt> is the ethernet device name in the VE
* <tt>mac</tt> is its MAC address in the VE
* <tt>host_ifname</tt> is the ethernet device name on the host ([[CT0]])
* <tt>host_mac</tt> is its MAC address on the host ([[CT0]])
 
{{Note|All parameters except ifname are optional and are automatically generated if not specified.}}
 
Example:
 
<pre>
vzctl set 101 --netif_add eth0
</pre>
 
Or, if you want to specify everything:
 
<pre>
vzctl set 101 --netif_add eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save
</pre>
==== syntax vzctl version < 3.0.14 ====
Example:
<pre>
[host-node] ifconfig eth0
...
HWaddress 00:12:34:56:78:9B
...
</pre>
 
<pre>
[host-node] easymac.sh -R
00:12:34:56:78:9A
</pre>
<pre>
VE-side ethernet device will have <tt>eth0</tt> name and <tt>00:12:34:56:78:9B</tt> MAC address.
=== Removing veth from a VE ===
==== syntax vzctl version >= 3.0.14 ====
 
Read Update infos about [http://openvz.org/news/updates/vzctl-3.0.14-1 vzctl 3.0.14]
 
<pre>
vzctl set <VEID> --netif_add netif_del <ifnamedev_name>[,<mac>,<host_ifname>,<host_mac]|all
</pre>
Here
* <ttcode>ifnamedev_name</ttcode> is the ethernet device name in the VE* <tt>mac</tt> is its MAC address in the VE* <tt>host_ifname</tt> is the ethernet device name on the host ([[CT0]])* <tt>host_mac</tt> is its MAC address on the host ([[CT0VE]]).
{{Note|All parameters except ifname are optional and are automatically generated if not specifiedIf you want to remove all ethernet devices in VE, use <code>all</code>.}}
Example:
<pre>
vzctl set 101 --netif_add netif_del eth0,00:12:34:56:78:9A,veth101.0,00:12:34:56:78:9B --save
</pre>
=== Removing veth from a VE ===
==== syntax vzctl version < 3.0.14 ====
After executing this command veth device with host-side ethernet name veth101.0 will be removed from VE 101 and veth configuration will be updated in VE config file.
 
==== syntax vzctl version >= 3.0.14 ====
<pre>
vzctl set <VEID> --netif_del <dev_name>|all
</pre>
 
Here
* <code>dev_name</code> is the ethernet device name in the [[VE]].
 
{{Note|If you want to remove all ethernet devices in VE, use <code>all</code>.}}
 
Example:
 
<pre>
vzctl set 101 --netif_del eth0 --save
</pre>
== Common configurations with virtual ethernet devices ==
==== Add veth device to VE ====
== old way ==
<pre>
[host-node] ifconfig eth0
...
HWaddress 00:12:34:56:78:9B
...
</pre>
 
<pre>
[host-node] easymac.sh -R
00:12:34:56:78:9A
</pre>
 
<pre>
[host-node]# vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save
</pre>
 
== new way ==
<pre>
38
edits

Navigation menu