Debian Codegraph @

upstream/debian-unstable/man4/veth.4

raw
1 .\" Copyright 2012, Eric W. Biederman <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .\"
6 .TH veth 4 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 veth \- Virtual Ethernet Device
9 .SH DESCRIPTION
10 The
11 .B veth
12 devices are virtual Ethernet devices.
13 They can act as tunnels between network namespaces to create
14 a bridge to a physical network device in another namespace,
15 but can also be used as standalone network devices.
16 .P
17 .B veth
18 devices are always created in interconnected pairs.
19 A pair can be created using the command:
20 .P
21 .in +4n
22 .EX
23 # ip link add <p1-name> type veth peer name <p2-name>
24 .EE
25 .in
26 .P
27 In the above,
28 .I p1-name
29 and
30 .I p2-name
31 are the names assigned to the two connected end points.
32 .P
33 Packets transmitted on one device in the pair are immediately received on
34 the other device.
35 When either device is down, the link state of the pair is down.
36 .P
37 .B veth
38 device pairs are useful for combining the network
39 facilities of the kernel together in interesting ways.
40 A particularly interesting use case is to place one end of a
41 .B veth
42 pair in one network namespace and the other end in another network namespace,
43 thus allowing communication between network namespaces.
44 To do this, one can provide the
45 .B netns
46 parameter when creating the interfaces:
47 .P
48 .in +4n
49 .EX
50 # ip link add <p1\-name> netns <p1\-ns> type veth peer <p2\-name> netns <p2\-ns>
51 .EE
52 .in
53 .P
54 or, for an existing
55 .B veth
56 pair, move one side to the other namespace:
57 .P
58 .in +4n
59 .EX
60 # ip link set <p2\-name> netns <p2\-ns>
61 .EE
62 .in
63 .P
64 .BR ethtool (8)
65 can be used to find the peer of a
66 .B veth
67 network interface, using commands something like:
68 .P
69 .in +4n
70 .EX
71 .RB # " ip link add ve_A type veth peer name ve_B" "; # Create veth pair"
72 .RB # " ethtool \-S ve_A" "; # Discover interface index of peer"
73 NIC statistics:
74 peer_ifindex: 16
75 .RB # " ip link | grep \[aq]\[ha]16:\[aq]" "; # Look up interface"
76 16: ve_B@ve_A: <BROADCAST,MULTICAST,M\-DOWN> mtu 1500 qdisc ...
77 .EE
78 .in
79 .SH "SEE ALSO"
80 .BR clone (2),
81 .BR network_namespaces (7),
82 .BR ip (8),
83 .BR ip\-link (8),
84 .BR ip\-netns (8)