Difference between revisions of "Virtual Ethernet device"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(Adding veth to a VE)
(Minor rephrasing and formatting fixes in Examples)
Line 26: Line 26:
 
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save
 
vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save
 
</pre>
 
</pre>
After executing this command veth device will be created for VE 101 and veth configuration will be saved to VE config file.
+
After executing this command <tt>veth</tt> device will be created for VE 101 and veth configuration will be saved to a VE configuration file.
Host-side ethernet device will have <tt>veth101.0</tt> name and <tt>00:12:34:56:78:9A</tt> MAC address,
+
Host-side ethernet device will have <tt>veth101.0</tt> name and <tt>00:12:34:56:78:9A</tt> MAC address.
VE-side ethernet device will have <tt>eth0</tt> name and <tt>00:12:34:56:78:9B</tt> MAC address. Please do not use MAC address of eth0
+
VE-side ethernet device will have <tt>eth0</tt> name and <tt>00:12:34:56:78:9B</tt> MAC address.
device in host sytem for veth devices, beacuse this can lead to collisions.
+
{{Note|Use random MAC addresses. Do not use MAC addresses of real eth devices, beacuse this can lead to collisions.}}
 
<pre>
 
<pre>
 
vzctl set 101 --veth_del veth101.0 --save
 
vzctl set 101 --veth_del veth101.0 --save

Revision as of 12:05, 8 June 2006

Virtual ethernet device is ethernet device which can be used inside a VE. Unlike venet network device, veth device has a MAC address.

Virtual ethernet device consist of two ethernet devices - one in VE0 and another one in VE. These devices are connected to each other, so if a packet goes to one device it will come out from the other device.


Virtual ethernet device usage

Adding veth to a VE

vzctl set <VEID> --veth_add <dev_name>,<dev_addr>,<ve_dev_name>,<ve_dev_addr>

Here

  • dev_name is ethernet device name in the host system
  • dev_addr is its MAC address
  • ve_dev_name is an ethernet device name in the VE
  • ve_dev_addr is its MAC address

MAC addresses must be entered in XX:XX:XX:XX:XX:XX format. Note that this option is incremental, so devices are added to already existing ones.

Examples

vzctl set 101 --veth_add veth101.0,00:12:34:56:78:9A,eth0,00:12:34:56:78:9B --save

After executing this command veth device will be created for VE 101 and veth configuration will be saved to a VE configuration file. Host-side ethernet device will have veth101.0 name and 00:12:34:56:78:9A MAC address. VE-side ethernet device will have eth0 name and 00:12:34:56:78:9B MAC address.

Yellowpin.svg Note: Use random MAC addresses. Do not use MAC addresses of real eth devices, beacuse this can lead to collisions.
vzctl set 101 --veth_del veth101.0 --save

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.

Removing veth from a VE

vzctl set <VEID> --veth_del <dev_name>

Here dev_name is the ethernet device name in the host system.

Common configurations with virtual ethernet devices

Virtual ethernet device can be used with IPv6

You'll need to setup IPv6 address on ethernet device inside a VE, add default route inside a VE and add route to this address via host-side veth in host system.

Virtual ethernet devices can be joined in one bridge

Thus you'll have more convinient configuration, i.e. all routes to VEs will be through this bridge and VEs can communicate with each other even without these routes.

Virtual ethernet devices + VLAN

This configuration can be done by adding vlan device to the previous configuration.