]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man4/veth.4
veth.4: Add a more direct example
[thirdparty/man-pages.git] / man4 / veth.4
1 .\" Copyright (c) 2012 Tomáš Pospíšek (tpo_deb@sourcepole.ch),
2 .\" Fri, 03 Nov 2012 22:35:33 +0100
3 .\" and Copyright (c) 2012 Eric W. Biederman <ebiederm@xmission.com>
4 .\"
5 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
10 .\"
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
15 .\"
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 .\" GNU General Public License for more details.
20 .\"
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, write to the Free
23 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
24 .\" USA.
25 .\" %%%LICENSE_END
26 .\"
27 .\"
28 .TH VETH 4 2018-02-02 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 veth \- Virtual Ethernet Device
31 .SH DESCRIPTION
32 The
33 .B veth
34 devices are virtual Ethernet devices.
35 They can act as tunnels between network namespaces to create
36 a bridge to a physical network device in another namespace,
37 but can also be used as standalone network devices.
38 .PP
39 .B veth
40 devices are always created in interconnected pairs.
41 A pair can be created using the command:
42 .PP
43 .in +4n
44 .EX
45 # ip link add <p1-name> type veth peer name <p2-name>
46 .EE
47 .in
48 .PP
49 In the above,
50 .I p1-name
51 and
52 .I p2-name
53 are the names assigned to the two connected end points.
54 .PP
55 Packets transmitted on one device in the pair are immediately received on
56 the other device.
57 When either devices is down the link state of the pair is down.
58 .PP
59 .B veth
60 device pairs are useful for combining the network
61 facilities of the kernel together in interesting ways.
62 A particularly interesting use case is to place one end of a
63 .B veth
64 pair in one network namespace and the other end in another network namespace,
65 thus allowing communication between network namespaces.
66 To do this, one can provide the
67 .B netns
68 parameter when creating the interfaces:
69 .PP
70 .in +4n
71 .EX
72 # ip link add <p1-name> netns <p1-ns> type veth peer <p2-name> netns <p2-ns>
73 .EE
74 .in
75 .PP
76 or, for an existing
77 .B veth
78 pair, move one side to the other namespace:
79 .PP
80 .in +4n
81 .EX
82 # ip link set <p2-name> netns <p2-ns>
83 .EE
84 .in
85 .PP
86 .BR ethtool (8)
87 can be used to find the peer of a
88 .B veth
89 network interface, using commands something like:
90 .PP
91 .in +4n
92 .EX
93 # \fBip link add ve_A type veth peer name ve_B\fP # Create veth pair
94 # \fBethtool -S ve_A\fP # Discover interface index of peer
95 NIC statistics:
96 peer_ifindex: 16
97 # \fBip link | grep '^16:'\fP # Look up interface
98 16: ve_B@ve_A: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc ...
99 .EE
100 .in
101 .PP
102 .SH "SEE ALSO"
103 .BR clone (2),
104 .BR network_namespaces (7),
105 .BR ip (8),
106 .BR ip-link (8),
107 .BR ip-netns (8)