blob: 991d097374750b006873d2bebcd2f48b9ef40cce [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
33.ti -8
34.BR "ip l2tp add session"
35.RB "[ " name
36.IR NAME
37.RB " ]"
38.br
39.B tunnel_id
40.IR ID
41.B session_id
42.IR ID
43.B peer_session_id
44.IR ID
45.br
46.RB "[ " cookie
47.IR HEXSTR
48.RB " ] [ " peer_cookie
49.IR HEXSTR
50.RB " ]"
51.br
James Chapman9c064b52013-03-26 06:49:23 +000052.RB "[ " l2spec_type " { " none " | " default " } ]"
53.br
James Chapman6121e1f2012-05-01 15:25:23 +010054.RB "[ " offset
55.IR OFFSET
56.RB " ] [ " peer_offset
57.IR OFFSET
58.RB " ]"
59.br
60.ti -8
61.BR "ip l2tp del tunnel"
62.B tunnel_id
63.IR ID
64.br
65.ti -8
66.BR "ip l2tp del session"
67.B tunnel_id
68.IR ID
69.B session_id
70.IR ID
71.br
72.ti -8
Phil Sutter2227f2a2016-03-02 19:20:07 +010073.BR "ip l2tp show tunnel" " [ " tunnel_id
74.IR ID " ]"
James Chapman6121e1f2012-05-01 15:25:23 +010075.br
76.ti -8
Phil Sutter2227f2a2016-03-02 19:20:07 +010077.BR "ip l2tp show session" " [ " tunnel_id
78.IR ID .B " ] ["
79.B session_id
80.IR ID " ]"
James Chapman6121e1f2012-05-01 15:25:23 +010081.br
82.ti -8
83.IR NAME " := "
84.IR STRING
85.ti -8
Phil Sutter2227f2a2016-03-02 19:20:07 +010086.IR ADDR " := { " IP_ADDRESS " |"
87.BR any " }"
James Chapman6121e1f2012-05-01 15:25:23 +010088.ti -8
89.IR PORT " := { " NUMBER " }"
90.ti -8
91.IR ID " := { " NUMBER " }"
92.ti -8
93.ti -8
94.IR HEXSTR " := { 8 or 16 hex digits (4 / 8 bytes) }"
95.SH DESCRIPTION
96The
97.B ip l2tp
98commands are used to establish static, or so-called
99.I unmanaged
100L2TPv3 ethernet tunnels. For unmanaged tunnels, there is no L2TP
101control protocol so no userspace daemon is required - tunnels are
102manually created by issuing commands at a local system and at a remote
103peer.
104.PP
Petr Sabata6274b0b2013-04-04 03:36:57 +0000105L2TPv3 is suitable for Layer-2 tunneling. Static tunnels are useful
James Chapman6121e1f2012-05-01 15:25:23 +0100106to establish network links across IP networks when the tunnels are
107fixed. L2TPv3 tunnels can carry data of more than one session. Each
108session is identified by a session_id and its parent tunnel's
109tunnel_id. A tunnel must be created before a session can be created in
110the tunnel.
111.PP
112When creating an L2TP tunnel, the IP address of the remote peer is
113specified, which can be either an IPv4 or IPv6 address. The local IP
114address to be used to reach the peer must also be specified. This is
115the address on which the local system will listen for and accept
116received L2TP data packets from the peer.
117.PP
118L2TPv3 defines two packet encapsulation formats: UDP or IP. UDP
119encapsulation is most common. IP encapsulation uses a dedicated IP
120protocol value to carry L2TP data without the overhead of UDP. Use IP
121encapsulation only when there are no NAT devices or firewalls in the
122network path.
123.PP
124When an L2TPv3 ethernet session is created, a virtual network
125interface is created for the session, which must then be configured
126and brought up, just like any other network interface. When data is
127passed through the interface, it is carried over the L2TP tunnel to
128the peer. By configuring the system's routing tables or adding the
129interface to a bridge, the L2TP interface is like a virtual wire
130(pseudowire) connected to the peer.
131.PP
132Establishing an unmanaged L2TPv3 ethernet pseudowire involves manually
133creating L2TP contexts on the local system and at the peer. Parameters
134used at each site must correspond or no data will be passed. No
135consistency checks are possible since there is no control protocol
136used to establish unmanaged L2TP tunnels. Once the virtual network
137interface of a given L2TP session is configured and enabled, data can
138be transmitted, even if the peer isn't yet configured. If the peer
139isn't configured, the L2TP data packets will be discarded by
140the peer.
141.PP
142To establish an unmanaged L2TP tunnel, use
143.B l2tp add tunnel
144and
145.B l2tp add session
146commands described in this document. Then configure and enable the
147tunnel's virtual network interface, as required.
148.PP
149Note that unmanaged tunnels carry only ethernet frames. If you need to
150carry PPP traffic (L2TPv2) or your peer doesn't support unmanaged
151L2TPv3 tunnels, you will need an L2TP server which implements the L2TP
152control protocol. The L2TP control protocol allows dynamic L2TP
153tunnels and sessions to be established and provides for detecting and
154acting upon network failures.
155.SS ip l2tp add tunnel - add a new tunnel
156.TP
James Chapman6121e1f2012-05-01 15:25:23 +0100157.BI tunnel_id " ID"
158set the tunnel id, which is a 32-bit integer value. Uniquely
159identifies the tunnel. The value used must match the peer_tunnel_id
160value being used at the peer.
161.TP
162.BI peer_tunnel_id " ID"
163set the peer tunnel id, which is a 32-bit integer value assigned to
164the tunnel by the peer. The value used must match the tunnel_id value
165being used at the peer.
166.TP
167.BI remote " ADDR"
168set the IP address of the remote peer. May be specified as an IPv4
169address or an IPv6 address.
170.TP
171.BI local " ADDR"
172set the IP address of the local interface to be used for the
173tunnel. This address must be the address of a local interface. May be
174specified as an IPv4 address or an IPv6 address.
175.TP
176.BI encap " ENCAP"
177set the encapsulation type of the tunnel.
178.br
179Valid values for encapsulation are:
180.BR udp ", " ip "."
181.TP
182.BI udp_sport " PORT"
183set the UDP source port to be used for the tunnel. Must be present
184when udp encapsulation is selected. Ignored when ip encapsulation is
185selected.
186.TP
187.BI udp_dport " PORT"
188set the UDP destination port to be used for the tunnel. Must be
189present when udp encapsulation is selected. Ignored when ip
190encapsulation is selected.
191.SS ip l2tp del tunnel - destroy a tunnel
192.TP
193.BI tunnel_id " ID"
194set the tunnel id of the tunnel to be deleted. All sessions within the
195tunnel must be deleted first.
196.SS ip l2tp show tunnel - show information about tunnels
197.TP
198.BI tunnel_id " ID"
199set the tunnel id of the tunnel to be shown. If not specified,
200information about all tunnels is printed.
201.SS ip l2tp add session - add a new session to a tunnel
202.TP
203.BI name " NAME "
204sets the session network interface name. Default is l2tpethN.
205.TP
206.BI tunnel_id " ID"
207set the tunnel id, which is a 32-bit integer value. Uniquely
208identifies the tunnel into which the session will be created. The
209tunnel must already exist.
210.TP
211.BI session_id " ID"
212set the session id, which is a 32-bit integer value. Uniquely
213identifies the session being created. The value used must match the
214peer_session_id value being used at the peer.
215.TP
216.BI peer_session_id " ID"
217set the peer session id, which is a 32-bit integer value assigned to
218the session by the peer. The value used must match the session_id
219value being used at the peer.
220.TP
221.BI cookie " HEXSTR"
222sets an optional cookie value to be assigned to the session. This is a
2234 or 8 byte value, specified as 8 or 16 hex digits,
224e.g. 014d3636deadbeef. The value must match the peer_cookie value set
225at the peer. The cookie value is carried in L2TP data packets and is
226checked for expected value at the peer. Default is to use no cookie.
227.TP
228.BI peer_cookie " HEXSTR"
229sets an optional peer cookie value to be assigned to the session. This
230is a 4 or 8 byte value, specified as 8 or 16 hex digits,
231e.g. 014d3636deadbeef. The value must match the cookie value set at
232the peer. It tells the local system what cookie value to expect to
233find in received L2TP packets. Default is to use no cookie.
234.TP
James Chapman9c064b52013-03-26 06:49:23 +0000235.BI l2spec_type " L2SPECTYPE"
236set the layer2specific header type of the session.
237.br
238Valid values are:
Asbjørn Sloth Tønnesen222c4da2016-11-16 22:45:18 +0000239.BR none ", " default "."
James Chapman9c064b52013-03-26 06:49:23 +0000240.TP
James Chapman6121e1f2012-05-01 15:25:23 +0100241.BI offset " OFFSET"
242sets the byte offset from the L2TP header where user data starts in
243transmitted L2TP data packets. This is hardly ever used. If set, the
244value must match the peer_offset value used at the peer. Default is 0.
245.TP
246.BI peer_offset " OFFSET"
247sets the byte offset from the L2TP header where user data starts in
248received L2TP data packets. This is hardly ever used. If set, the
249value must match the offset value used at the peer. Default is 0.
250.SS ip l2tp del session - destroy a session
251.TP
252.BI tunnel_id " ID"
253set the tunnel id in which the session to be deleted is located.
254.TP
255.BI session_id " ID"
256set the session id of the session to be deleted.
257.SS ip l2tp show session - show information about sessions
258.TP
259.BI tunnel_id " ID"
260set the tunnel id of the session(s) to be shown. If not specified,
261information about sessions in all tunnels is printed.
262.TP
263.BI session_id " ID"
264set the session id of the session to be shown. If not specified,
265information about all sessions is printed.
266.SH EXAMPLES
267.PP
268.SS Setup L2TP tunnels and sessions
269.nf
270site-A:# ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 \\
271 encap udp local 1.2.3.4 remote 5.6.7.8 \\
272 udp_sport 5000 udp_dport 6000
273site-A:# ip l2tp add session tunnel_id 3000 session_id 1000 \\
274 peer_session_id 2000
275
276site-B:# ip l2tp add tunnel tunnel_id 4000 peer_tunnel_id 3000 \\
277 encap udp local 5.6.7.8 remote 1.2.3.4 \\
278 udp_sport 6000 udp_dport 5000
279site-B:# ip l2tp add session tunnel_id 4000 session_id 2000 \\
280 peer_session_id 1000
281
282site-A:# ip link set l2tpeth0 up mtu 1488
283
284site-B:# ip link set l2tpeth0 up mtu 1488
285.fi
286.PP
287Notice that the IP addresses, UDP ports and tunnel / session ids are
288matched and reversed at each site.
289.SS Configure as IP interfaces
290The two interfaces can be configured with IP addresses if only IP data
291is to be carried. This is perhaps the simplest configuration.
292.PP
293.nf
294site-A:# ip addr add 10.42.1.1 peer 10.42.1.2 dev l2tpeth0
295
296site-B:# ip addr add 10.42.1.2 peer 10.42.1.1 dev l2tpeth0
297
298site-A:# ping 10.42.1.2
299.fi
300.PP
301Now the link should be usable. Add static routes as needed to have
302data sent over the new link.
303.PP
304.SS Configure as bridged interfaces
305To carry non-IP data, the L2TP network interface is added to a bridge
306instead of being assigned its own IP address, using standard Linux
307utilities. Since raw ethernet frames are then carried inside the
308tunnel, the MTU of the L2TP interfaces must be set to allow space for
309those headers.
310.PP
311.nf
312site-A:# ip link set l2tpeth0 up mtu 1446
Stephen Hemmingerec72fd72012-10-03 08:45:32 -0700313site-A:# ip link add br0 type bridge
314site-A:# ip link set l2tpeth0 master br0
315site-A:# ip link set eth0 master br0
James Chapman6121e1f2012-05-01 15:25:23 +0100316site-A:# ip link set br0 up
317.fi
318.PP
319If you are using VLANs, setup a bridge per VLAN and bridge each VLAN
320over a separate L2TP session. For example, to bridge VLAN ID 5 on eth1
321over an L2TP pseudowire:
322.PP
323.nf
324site-A:# ip link set l2tpeth0 up mtu 1446
Stephen Hemmingerec72fd72012-10-03 08:45:32 -0700325site-A:# ip link add brvlan5 type bridge
326site-A:# ip link set l2tpeth0.5 master brvlan5
327site-A:# ip link set eth1.5 master brvlan5
James Chapman6121e1f2012-05-01 15:25:23 +0100328site-A:# ip link set brvlan5 up
329.fi
330.PP
331Adding the L2TP interface to a bridge causes the bridge to forward
332traffic over the L2TP pseudowire just like it forwards over any other
333interface. The bridge learns MAC addresses of hosts attached to each
334interface and intelligently forwards frames from one bridge port to
335another. IP addresses are not assigned to the l2tpethN interfaces. If
336the bridge is correctly configured at both sides of the L2TP
337pseudowire, it should be possible to reach hosts in the peer's bridged
338network.
339.PP
340When raw ethernet frames are bridged across an L2TP tunnel, large
341frames may be fragmented and forwarded as individual IP fragments to
342the recipient, depending on the MTU of the physical interface used by
343the tunnel. When the ethernet frames carry protocols which are
344reassembled by the recipient, like IP, this isn't a problem. However,
345such fragmentation can cause problems for protocols like PPPoE where
346the recipient expects to receive ethernet frames exactly as
347transmitted. In such cases, it is important that frames leaving the
348tunnel are reassembled back into a single frame before being
349forwarded on. To do so, enable netfilter connection tracking
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500350(conntrack) or manually load the Linux netfilter defrag modules at
James Chapman6121e1f2012-05-01 15:25:23 +0100351each tunnel endpoint.
352.PP
353.nf
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500354site-A:# modprobe nf_defrag_ipv4
James Chapman6121e1f2012-05-01 15:25:23 +0100355
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500356site-B:# modprobe nf_defrag_ipv4
James Chapman6121e1f2012-05-01 15:25:23 +0100357.fi
358.PP
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500359If L2TP is being used over IPv6, use the IPv6 defrag module.
Petr Sabata6274b0b2013-04-04 03:36:57 +0000360.SH INTEROPERABILITY
James Chapman6121e1f2012-05-01 15:25:23 +0100361.PP
362Unmanaged (static) L2TPv3 tunnels are supported by some network
363equipment equipment vendors such as Cisco.
364.PP
365In Linux, L2TP Hello messages are not supported in unmanaged
366tunnels. Hello messages are used by L2TP clients and servers to detect
367link failures in order to automate tearing down and reestablishing
368dynamic tunnels. If a non-Linux peer supports Hello messages in
369unmanaged tunnels, it must be turned off to interoperate with Linux.
James Chapman9c064b52013-03-26 06:49:23 +0000370.PP
371Linux defaults to use the Default Layer2SpecificHeader type as defined
372in the L2TPv3 protocol specification, RFC3931. This setting must be
373consistent with that configured at the peer. Some vendor
374implementations (e.g. Cisco) default to use a Layer2SpecificHeader
375type of None.
James Chapman6121e1f2012-05-01 15:25:23 +0100376.SH SEE ALSO
377.br
James Chapman6121e1f2012-05-01 15:25:23 +0100378.BR ip (8)
379.SH AUTHOR
380James Chapman <jchapman@katalix.com>