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.
To create a veth pair made of veth0 and veth1, run the command below.
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:
- Hostname isolation with UTS namespaces - Container networking basics, part 1 | 44BITS 1 - UTS, Linux Namespace
- Building network namespaces and bridge networks by hand with ip - Container networking basics, part 2 | 44BITS 2 - ip
... TODO - organize step by step later