5.4.2.1. Creating and Deleting veth Network Adapters

By default, any container on the hardware node starts functioning in the venet0 mode right after its creation. However, at any time you can create additional virtual adapters for containers and set them to work in the bridged mode. You can do this using the --netif_add option of the prlctl set command.

Let us assume that you wish to create a new virtual adapter with the name of netif1 in the container MyCT and make it function in the bridged mode. To do this, run the following command:

# prlctl set MyCT --netif_add netif1

The settings of the newly created virtual adapter are saved as the value of the NETIF parameter in the configuration file of the container MyCT (/etc/vz/conf/26bc47f6-353f-444b-bc35-b634a88dbbcc.conf). So, you can use the following command to display the parameters assigned to the veth network adapter in the container MyCT:

# grep NETIF /etc/vz/conf/26bc47f6-353f-444b-bc35-b634a88dbbcc.conf
NETIF="ifname=netif1,mac=00:1C:42:63:B3:12,host_mac=FE:18:51:6C:0B:A8, \
network=Bridged,configure=none"

As you can see, the parameters set for the veth virtual network adapter during its creation are the following:

  • ifname, name set for the veth Ethernet interface in the container MyCT. You specified this name when creating the container virtual network adapter.
  • mac, MAC address assigned to the veth Ethernet interface in the container MyCT.
  • host_mac, MAC address assigned to the veth Ethernet interface on the hardware node.

ifname is the only mandatory parameter that you need to specify when creating a container virtual network adapter. All the other parameters are optional and generated by OpenVZ automatically, if not indicated.

At any time, you can remove the veth virtual network adapter from the container MyCT by executing the following command:

# prlctl set MyCT --netif_del netif1