blob: 8ce630a6e61244bd1549c0b7576f50af40673449 [file] [log] [blame]
James Chapman6121e1f2012-05-01 15:25:23 +01001.TH IP\-L2TP 8 "19 Apr 2012" "iproute2" "Linux"
2.SH "NAME"
3ip-l2tp - L2TPv3 static unmanaged tunnel configuration
4.SH "SYNOPSIS"
5.sp
6.ad l
7.in +8
8.ti -8
9.B ip
10.RI "[ " OPTIONS " ]"
11.B l2tp
12.RI " { " COMMAND " | "
13.BR help " }"
14.sp
15.ti -8
16.BR "ip l2tp add tunnel"
17.br
Phil Sutter2227f2a2016-03-02 19:20:07 +010018.BI remote " ADDR " local " ADDR "
James Chapman6121e1f2012-05-01 15:25:23 +010019.br
20.B tunnel_id
21.IR ID
22.B peer_tunnel_id
23.IR ID
24.br
25.RB "[ " encap " { " ip " | " udp " } ]"
26.br
27.RB "[ " udp_sport
28.IR PORT
29.RB " ] [ " udp_dport
30.IR PORT
31.RB " ]"
32.br
Asbjørn Sloth Tønnesen51a9d012016-11-16 22:45:26 +000033.RB "[ " udp_csum " { " on " | " off " } ]"
34.br
35.RB "[ " udp6_csum_tx " { " on " | " off " } ]"
36.br
37.RB "[ " udp6_csum_rx " { " on " | " off " } ]"
38.br
James Chapman6121e1f2012-05-01 15:25:23 +010039.ti -8
40.BR "ip l2tp add session"
41.RB "[ " name
42.IR NAME
43.RB " ]"
44.br
45.B tunnel_id
46.IR ID
47.B session_id
48.IR ID
49.B peer_session_id
50.IR ID
51.br
52.RB "[ " cookie
53.IR HEXSTR
54.RB " ] [ " peer_cookie
55.IR HEXSTR
56.RB " ]"
57.br
James Chapman9c064b52013-03-26 06:49:23 +000058.RB "[ " l2spec_type " { " none " | " default " } ]"
59.br
Asbjørn Sloth Tønnesen8a114212016-11-16 22:45:24 +000060.RB "[ " seq " { " none " | " send " | " recv " | " both " } ]"
61.br
James Chapman6121e1f2012-05-01 15:25:23 +010062.RB "[ " offset
63.IR OFFSET
64.RB " ] [ " peer_offset
65.IR OFFSET
66.RB " ]"
67.br
68.ti -8
69.BR "ip l2tp del tunnel"
70.B tunnel_id
71.IR ID
72.br
73.ti -8
74.BR "ip l2tp del session"
75.B tunnel_id
76.IR ID
77.B session_id
78.IR ID
79.br
80.ti -8
Phil Sutter2227f2a2016-03-02 19:20:07 +010081.BR "ip l2tp show tunnel" " [ " tunnel_id
82.IR ID " ]"
James Chapman6121e1f2012-05-01 15:25:23 +010083.br
84.ti -8
Phil Sutter2227f2a2016-03-02 19:20:07 +010085.BR "ip l2tp show session" " [ " tunnel_id
86.IR ID .B " ] ["
87.B session_id
88.IR ID " ]"
James Chapman6121e1f2012-05-01 15:25:23 +010089.br
90.ti -8
91.IR NAME " := "
92.IR STRING
93.ti -8
Phil Sutter2227f2a2016-03-02 19:20:07 +010094.IR ADDR " := { " IP_ADDRESS " |"
95.BR any " }"
James Chapman6121e1f2012-05-01 15:25:23 +010096.ti -8
97.IR PORT " := { " NUMBER " }"
98.ti -8
99.IR ID " := { " NUMBER " }"
100.ti -8
101.ti -8
102.IR HEXSTR " := { 8 or 16 hex digits (4 / 8 bytes) }"
103.SH DESCRIPTION
104The
105.B ip l2tp
106commands are used to establish static, or so-called
107.I unmanaged
108L2TPv3 ethernet tunnels. For unmanaged tunnels, there is no L2TP
109control protocol so no userspace daemon is required - tunnels are
110manually created by issuing commands at a local system and at a remote
111peer.
112.PP
Petr Sabata6274b0b2013-04-04 03:36:57 +0000113L2TPv3 is suitable for Layer-2 tunneling. Static tunnels are useful
James Chapman6121e1f2012-05-01 15:25:23 +0100114to establish network links across IP networks when the tunnels are
115fixed. L2TPv3 tunnels can carry data of more than one session. Each
116session is identified by a session_id and its parent tunnel's
117tunnel_id. A tunnel must be created before a session can be created in
118the tunnel.
119.PP
120When creating an L2TP tunnel, the IP address of the remote peer is
121specified, which can be either an IPv4 or IPv6 address. The local IP
122address to be used to reach the peer must also be specified. This is
123the address on which the local system will listen for and accept
124received L2TP data packets from the peer.
125.PP
126L2TPv3 defines two packet encapsulation formats: UDP or IP. UDP
127encapsulation is most common. IP encapsulation uses a dedicated IP
128protocol value to carry L2TP data without the overhead of UDP. Use IP
129encapsulation only when there are no NAT devices or firewalls in the
130network path.
131.PP
132When an L2TPv3 ethernet session is created, a virtual network
133interface is created for the session, which must then be configured
134and brought up, just like any other network interface. When data is
135passed through the interface, it is carried over the L2TP tunnel to
136the peer. By configuring the system's routing tables or adding the
137interface to a bridge, the L2TP interface is like a virtual wire
138(pseudowire) connected to the peer.
139.PP
140Establishing an unmanaged L2TPv3 ethernet pseudowire involves manually
141creating L2TP contexts on the local system and at the peer. Parameters
142used at each site must correspond or no data will be passed. No
143consistency checks are possible since there is no control protocol
144used to establish unmanaged L2TP tunnels. Once the virtual network
145interface of a given L2TP session is configured and enabled, data can
146be transmitted, even if the peer isn't yet configured. If the peer
147isn't configured, the L2TP data packets will be discarded by
148the peer.
149.PP
150To establish an unmanaged L2TP tunnel, use
151.B l2tp add tunnel
152and
153.B l2tp add session
154commands described in this document. Then configure and enable the
155tunnel's virtual network interface, as required.
156.PP
157Note that unmanaged tunnels carry only ethernet frames. If you need to
158carry PPP traffic (L2TPv2) or your peer doesn't support unmanaged
159L2TPv3 tunnels, you will need an L2TP server which implements the L2TP
160control protocol. The L2TP control protocol allows dynamic L2TP
161tunnels and sessions to be established and provides for detecting and
162acting upon network failures.
163.SS ip l2tp add tunnel - add a new tunnel
164.TP
James Chapman6121e1f2012-05-01 15:25:23 +0100165.BI tunnel_id " ID"
166set the tunnel id, which is a 32-bit integer value. Uniquely
167identifies the tunnel. The value used must match the peer_tunnel_id
168value being used at the peer.
169.TP
170.BI peer_tunnel_id " ID"
171set the peer tunnel id, which is a 32-bit integer value assigned to
172the tunnel by the peer. The value used must match the tunnel_id value
173being used at the peer.
174.TP
175.BI remote " ADDR"
176set the IP address of the remote peer. May be specified as an IPv4
177address or an IPv6 address.
178.TP
179.BI local " ADDR"
180set the IP address of the local interface to be used for the
181tunnel. This address must be the address of a local interface. May be
182specified as an IPv4 address or an IPv6 address.
183.TP
184.BI encap " ENCAP"
185set the encapsulation type of the tunnel.
186.br
187Valid values for encapsulation are:
188.BR udp ", " ip "."
189.TP
190.BI udp_sport " PORT"
191set the UDP source port to be used for the tunnel. Must be present
192when udp encapsulation is selected. Ignored when ip encapsulation is
193selected.
194.TP
195.BI udp_dport " PORT"
196set the UDP destination port to be used for the tunnel. Must be
197present when udp encapsulation is selected. Ignored when ip
198encapsulation is selected.
Asbjørn Sloth Tønnesen51a9d012016-11-16 22:45:26 +0000199.TP
200.BI udp_csum " STATE"
201(IPv4 only) control if IPv4 UDP checksums should be calculated and checked for the
202encapsulating UDP packets, when UDP encapsulating is selected.
203Default is
204.BR off "."
205.br
206Valid values are:
207.BR on ", " off "."
208.TP
209.BI udp6_csum_tx " STATE"
210(IPv6 only) control if IPv6 UDP checksums should be calculated for encapsulating
211UDP packets, when UDP encapsulating is selected.
212Default is
213.BR on "."
214.br
215Valid values are:
216.BR on ", " off "."
217.TP
218.BI udp6_csum_rx " STATE"
219(IPv6 only) control if IPv6 UDP checksums should be checked for the encapsulating
220UDP packets, when UDP encapsulating is selected.
221Default is
222.BR on "."
223.br
224Valid values are:
225.BR on ", " off "."
James Chapman6121e1f2012-05-01 15:25:23 +0100226.SS ip l2tp del tunnel - destroy a tunnel
227.TP
228.BI tunnel_id " ID"
229set the tunnel id of the tunnel to be deleted. All sessions within the
230tunnel must be deleted first.
231.SS ip l2tp show tunnel - show information about tunnels
232.TP
233.BI tunnel_id " ID"
234set the tunnel id of the tunnel to be shown. If not specified,
235information about all tunnels is printed.
236.SS ip l2tp add session - add a new session to a tunnel
237.TP
238.BI name " NAME "
239sets the session network interface name. Default is l2tpethN.
240.TP
241.BI tunnel_id " ID"
242set the tunnel id, which is a 32-bit integer value. Uniquely
243identifies the tunnel into which the session will be created. The
244tunnel must already exist.
245.TP
246.BI session_id " ID"
247set the session id, which is a 32-bit integer value. Uniquely
248identifies the session being created. The value used must match the
249peer_session_id value being used at the peer.
250.TP
251.BI peer_session_id " ID"
252set the peer session id, which is a 32-bit integer value assigned to
253the session by the peer. The value used must match the session_id
254value being used at the peer.
255.TP
256.BI cookie " HEXSTR"
257sets an optional cookie value to be assigned to the session. This is a
2584 or 8 byte value, specified as 8 or 16 hex digits,
259e.g. 014d3636deadbeef. The value must match the peer_cookie value set
260at the peer. The cookie value is carried in L2TP data packets and is
261checked for expected value at the peer. Default is to use no cookie.
262.TP
263.BI peer_cookie " HEXSTR"
264sets an optional peer cookie value to be assigned to the session. This
265is a 4 or 8 byte value, specified as 8 or 16 hex digits,
266e.g. 014d3636deadbeef. The value must match the cookie value set at
267the peer. It tells the local system what cookie value to expect to
268find in received L2TP packets. Default is to use no cookie.
269.TP
James Chapman9c064b52013-03-26 06:49:23 +0000270.BI l2spec_type " L2SPECTYPE"
271set the layer2specific header type of the session.
272.br
273Valid values are:
Asbjørn Sloth Tønnesen222c4da2016-11-16 22:45:18 +0000274.BR none ", " default "."
James Chapman9c064b52013-03-26 06:49:23 +0000275.TP
Asbjørn Sloth Tønnesen8a114212016-11-16 22:45:24 +0000276.BI seq " SEQ"
277controls sequence numbering to prevent or detect out of order packets.
278.B send
279puts a sequence number in the default layer2specific header of each
280outgoing packet.
281.B recv
282reorder packets if they are received out of order.
283Default is
284.BR none "."
285.br
286Valid values are:
287.BR none ", " send ", " recv ", " both "."
288.TP
James Chapman6121e1f2012-05-01 15:25:23 +0100289.BI offset " OFFSET"
290sets the byte offset from the L2TP header where user data starts in
291transmitted L2TP data packets. This is hardly ever used. If set, the
292value must match the peer_offset value used at the peer. Default is 0.
293.TP
294.BI peer_offset " OFFSET"
295sets the byte offset from the L2TP header where user data starts in
296received L2TP data packets. This is hardly ever used. If set, the
297value must match the offset value used at the peer. Default is 0.
298.SS ip l2tp del session - destroy a session
299.TP
300.BI tunnel_id " ID"
301set the tunnel id in which the session to be deleted is located.
302.TP
303.BI session_id " ID"
304set the session id of the session to be deleted.
305.SS ip l2tp show session - show information about sessions
306.TP
307.BI tunnel_id " ID"
308set the tunnel id of the session(s) to be shown. If not specified,
309information about sessions in all tunnels is printed.
310.TP
311.BI session_id " ID"
312set the session id of the session to be shown. If not specified,
313information about all sessions is printed.
314.SH EXAMPLES
315.PP
316.SS Setup L2TP tunnels and sessions
317.nf
318site-A:# ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 \\
319 encap udp local 1.2.3.4 remote 5.6.7.8 \\
320 udp_sport 5000 udp_dport 6000
321site-A:# ip l2tp add session tunnel_id 3000 session_id 1000 \\
322 peer_session_id 2000
323
324site-B:# ip l2tp add tunnel tunnel_id 4000 peer_tunnel_id 3000 \\
325 encap udp local 5.6.7.8 remote 1.2.3.4 \\
326 udp_sport 6000 udp_dport 5000
327site-B:# ip l2tp add session tunnel_id 4000 session_id 2000 \\
328 peer_session_id 1000
329
330site-A:# ip link set l2tpeth0 up mtu 1488
331
332site-B:# ip link set l2tpeth0 up mtu 1488
333.fi
334.PP
335Notice that the IP addresses, UDP ports and tunnel / session ids are
336matched and reversed at each site.
337.SS Configure as IP interfaces
338The two interfaces can be configured with IP addresses if only IP data
339is to be carried. This is perhaps the simplest configuration.
340.PP
341.nf
342site-A:# ip addr add 10.42.1.1 peer 10.42.1.2 dev l2tpeth0
343
344site-B:# ip addr add 10.42.1.2 peer 10.42.1.1 dev l2tpeth0
345
346site-A:# ping 10.42.1.2
347.fi
348.PP
349Now the link should be usable. Add static routes as needed to have
350data sent over the new link.
351.PP
352.SS Configure as bridged interfaces
353To carry non-IP data, the L2TP network interface is added to a bridge
354instead of being assigned its own IP address, using standard Linux
355utilities. Since raw ethernet frames are then carried inside the
356tunnel, the MTU of the L2TP interfaces must be set to allow space for
357those headers.
358.PP
359.nf
360site-A:# ip link set l2tpeth0 up mtu 1446
Stephen Hemmingerec72fd72012-10-03 08:45:32 -0700361site-A:# ip link add br0 type bridge
362site-A:# ip link set l2tpeth0 master br0
363site-A:# ip link set eth0 master br0
James Chapman6121e1f2012-05-01 15:25:23 +0100364site-A:# ip link set br0 up
365.fi
366.PP
367If you are using VLANs, setup a bridge per VLAN and bridge each VLAN
368over a separate L2TP session. For example, to bridge VLAN ID 5 on eth1
369over an L2TP pseudowire:
370.PP
371.nf
372site-A:# ip link set l2tpeth0 up mtu 1446
Stephen Hemmingerec72fd72012-10-03 08:45:32 -0700373site-A:# ip link add brvlan5 type bridge
374site-A:# ip link set l2tpeth0.5 master brvlan5
375site-A:# ip link set eth1.5 master brvlan5
James Chapman6121e1f2012-05-01 15:25:23 +0100376site-A:# ip link set brvlan5 up
377.fi
378.PP
379Adding the L2TP interface to a bridge causes the bridge to forward
380traffic over the L2TP pseudowire just like it forwards over any other
381interface. The bridge learns MAC addresses of hosts attached to each
382interface and intelligently forwards frames from one bridge port to
383another. IP addresses are not assigned to the l2tpethN interfaces. If
384the bridge is correctly configured at both sides of the L2TP
385pseudowire, it should be possible to reach hosts in the peer's bridged
386network.
387.PP
388When raw ethernet frames are bridged across an L2TP tunnel, large
389frames may be fragmented and forwarded as individual IP fragments to
390the recipient, depending on the MTU of the physical interface used by
391the tunnel. When the ethernet frames carry protocols which are
392reassembled by the recipient, like IP, this isn't a problem. However,
393such fragmentation can cause problems for protocols like PPPoE where
394the recipient expects to receive ethernet frames exactly as
395transmitted. In such cases, it is important that frames leaving the
396tunnel are reassembled back into a single frame before being
397forwarded on. To do so, enable netfilter connection tracking
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500398(conntrack) or manually load the Linux netfilter defrag modules at
James Chapman6121e1f2012-05-01 15:25:23 +0100399each tunnel endpoint.
400.PP
401.nf
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500402site-A:# modprobe nf_defrag_ipv4
James Chapman6121e1f2012-05-01 15:25:23 +0100403
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500404site-B:# modprobe nf_defrag_ipv4
James Chapman6121e1f2012-05-01 15:25:23 +0100405.fi
406.PP
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500407If L2TP is being used over IPv6, use the IPv6 defrag module.
Petr Sabata6274b0b2013-04-04 03:36:57 +0000408.SH INTEROPERABILITY
James Chapman6121e1f2012-05-01 15:25:23 +0100409.PP
410Unmanaged (static) L2TPv3 tunnels are supported by some network
411equipment equipment vendors such as Cisco.
412.PP
413In Linux, L2TP Hello messages are not supported in unmanaged
414tunnels. Hello messages are used by L2TP clients and servers to detect
415link failures in order to automate tearing down and reestablishing
416dynamic tunnels. If a non-Linux peer supports Hello messages in
417unmanaged tunnels, it must be turned off to interoperate with Linux.
James Chapman9c064b52013-03-26 06:49:23 +0000418.PP
419Linux defaults to use the Default Layer2SpecificHeader type as defined
420in the L2TPv3 protocol specification, RFC3931. This setting must be
421consistent with that configured at the peer. Some vendor
422implementations (e.g. Cisco) default to use a Layer2SpecificHeader
423type of None.
James Chapman6121e1f2012-05-01 15:25:23 +0100424.SH SEE ALSO
425.br
James Chapman6121e1f2012-05-01 15:25:23 +0100426.BR ip (8)
427.SH AUTHOR
428James Chapman <jchapman@katalix.com>