Skip to content
Search

Veth

lastmod 2023-07-06created 2023-03-097 edits

Virtual Ethernet Device

DESCRIPTION

The veth devices are virtual Ethernet devices. They can act as tunnels between network namespaces to create a bridge to a physical network device in another namespace, but can also be used as standalone network devices.

What is veth (virtual Ethernet interface)?

veth stands for the virtual Ethernet interface in Linux. veth devices are created in pairs and can be used to connect network namespaces as a tunnel, or to connect a physical device with a device in another network namespace.

On Linux, you can create a virtual network device of type veth using ip. Since veth devices are created in pairs, replace <veth0_name> and <veth1_name> with suitable names.

$ ip link add <veth0_name> type veth peer name <veth1_name>

To create a veth pair made of veth0 and veth1, run the command below.

$ ip link add veth0 type veth peer name veth1

A device of type veth belongs to Linux's default namespace by default and is created in an inactive state. Because veth0 and veth1 are directly connected, their activation state always changes at the same time.

The diagram with veth0 and veth1 added is as follows.

Veth0_-_veth1.png

With the ip link command, you can confirm that veth0 and veth1 have been added to the current network namespace (default). The part after @ is not a name but the connected destination.

$ ip -br link
...
veth1@veth0      DOWN           18:b9:5a:bb:f0:4a <BROADCAST,MULTICAST,M-DOWN>
veth0@veth1      DOWN           39:e0:cf:aa:1b:2c <BROADCAST,MULTICAST,M-DOWN>

For examples of adding network namespaces and configuring network connections with veth, see the following posts. They show how the ip command and veth virtual devices are actually used, centered on network namespaces:

... TODO - organize step by step later

See also

Favorite site

References


  1. 44BITS_-_container-network-1-uts-namespace.pdf ↩

  2. 44bits_-_container-network-2-ip-command-and-network-namespace.pdf ↩

author Zer0 sitemap