blob: 4a3bb20a49e31724dfc7be2aab585146de58c6f6 [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
157.BI name " NAME "
158sets the session network interface name. Default is l2tpethN.
159.TP
160.BI tunnel_id " ID"
161set the tunnel id, which is a 32-bit integer value. Uniquely
162identifies the tunnel. The value used must match the peer_tunnel_id
163value being used at the peer.
164.TP
165.BI peer_tunnel_id " ID"
166set the peer tunnel id, which is a 32-bit integer value assigned to
167the tunnel by the peer. The value used must match the tunnel_id value
168being used at the peer.
169.TP
170.BI remote " ADDR"
171set the IP address of the remote peer. May be specified as an IPv4
172address or an IPv6 address.
173.TP
174.BI local " ADDR"
175set the IP address of the local interface to be used for the
176tunnel. This address must be the address of a local interface. May be
177specified as an IPv4 address or an IPv6 address.
178.TP
179.BI encap " ENCAP"
180set the encapsulation type of the tunnel.
181.br
182Valid values for encapsulation are:
183.BR udp ", " ip "."
184.TP
185.BI udp_sport " PORT"
186set the UDP source port to be used for the tunnel. Must be present
187when udp encapsulation is selected. Ignored when ip encapsulation is
188selected.
189.TP
190.BI udp_dport " PORT"
191set the UDP destination port to be used for the tunnel. Must be
192present when udp encapsulation is selected. Ignored when ip
193encapsulation is selected.
194.SS ip l2tp del tunnel - destroy a tunnel
195.TP
196.BI tunnel_id " ID"
197set the tunnel id of the tunnel to be deleted. All sessions within the
198tunnel must be deleted first.
199.SS ip l2tp show tunnel - show information about tunnels
200.TP
201.BI tunnel_id " ID"
202set the tunnel id of the tunnel to be shown. If not specified,
203information about all tunnels is printed.
204.SS ip l2tp add session - add a new session to a tunnel
205.TP
206.BI name " NAME "
207sets the session network interface name. Default is l2tpethN.
208.TP
209.BI tunnel_id " ID"
210set the tunnel id, which is a 32-bit integer value. Uniquely
211identifies the tunnel into which the session will be created. The
212tunnel must already exist.
213.TP
214.BI session_id " ID"
215set the session id, which is a 32-bit integer value. Uniquely
216identifies the session being created. The value used must match the
217peer_session_id value being used at the peer.
218.TP
219.BI peer_session_id " ID"
220set the peer session id, which is a 32-bit integer value assigned to
221the session by the peer. The value used must match the session_id
222value being used at the peer.
223.TP
224.BI cookie " HEXSTR"
225sets an optional cookie value to be assigned to the session. This is a
2264 or 8 byte value, specified as 8 or 16 hex digits,
227e.g. 014d3636deadbeef. The value must match the peer_cookie value set
228at the peer. The cookie value is carried in L2TP data packets and is
229checked for expected value at the peer. Default is to use no cookie.
230.TP
231.BI peer_cookie " HEXSTR"
232sets an optional peer cookie value to be assigned to the session. This
233is a 4 or 8 byte value, specified as 8 or 16 hex digits,
234e.g. 014d3636deadbeef. The value must match the cookie value set at
235the peer. It tells the local system what cookie value to expect to
236find in received L2TP packets. Default is to use no cookie.
237.TP
James Chapman9c064b52013-03-26 06:49:23 +0000238.BI l2spec_type " L2SPECTYPE"
239set the layer2specific header type of the session.
240.br
241Valid values are:
Asbjørn Sloth Tønnesen222c4da2016-11-16 22:45:18 +0000242.BR none ", " default "."
James Chapman9c064b52013-03-26 06:49:23 +0000243.TP
James Chapman6121e1f2012-05-01 15:25:23 +0100244.BI offset " OFFSET"
245sets the byte offset from the L2TP header where user data starts in
246transmitted L2TP data packets. This is hardly ever used. If set, the
247value must match the peer_offset value used at the peer. Default is 0.
248.TP
249.BI peer_offset " OFFSET"
250sets the byte offset from the L2TP header where user data starts in
251received L2TP data packets. This is hardly ever used. If set, the
252value must match the offset value used at the peer. Default is 0.
253.SS ip l2tp del session - destroy a session
254.TP
255.BI tunnel_id " ID"
256set the tunnel id in which the session to be deleted is located.
257.TP
258.BI session_id " ID"
259set the session id of the session to be deleted.
260.SS ip l2tp show session - show information about sessions
261.TP
262.BI tunnel_id " ID"
263set the tunnel id of the session(s) to be shown. If not specified,
264information about sessions in all tunnels is printed.
265.TP
266.BI session_id " ID"
267set the session id of the session to be shown. If not specified,
268information about all sessions is printed.
269.SH EXAMPLES
270.PP
271.SS Setup L2TP tunnels and sessions
272.nf
273site-A:# ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 \\
274 encap udp local 1.2.3.4 remote 5.6.7.8 \\
275 udp_sport 5000 udp_dport 6000
276site-A:# ip l2tp add session tunnel_id 3000 session_id 1000 \\
277 peer_session_id 2000
278
279site-B:# ip l2tp add tunnel tunnel_id 4000 peer_tunnel_id 3000 \\
280 encap udp local 5.6.7.8 remote 1.2.3.4 \\
281 udp_sport 6000 udp_dport 5000
282site-B:# ip l2tp add session tunnel_id 4000 session_id 2000 \\
283 peer_session_id 1000
284
285site-A:# ip link set l2tpeth0 up mtu 1488
286
287site-B:# ip link set l2tpeth0 up mtu 1488
288.fi
289.PP
290Notice that the IP addresses, UDP ports and tunnel / session ids are
291matched and reversed at each site.
292.SS Configure as IP interfaces
293The two interfaces can be configured with IP addresses if only IP data
294is to be carried. This is perhaps the simplest configuration.
295.PP
296.nf
297site-A:# ip addr add 10.42.1.1 peer 10.42.1.2 dev l2tpeth0
298
299site-B:# ip addr add 10.42.1.2 peer 10.42.1.1 dev l2tpeth0
300
301site-A:# ping 10.42.1.2
302.fi
303.PP
304Now the link should be usable. Add static routes as needed to have
305data sent over the new link.
306.PP
307.SS Configure as bridged interfaces
308To carry non-IP data, the L2TP network interface is added to a bridge
309instead of being assigned its own IP address, using standard Linux
310utilities. Since raw ethernet frames are then carried inside the
311tunnel, the MTU of the L2TP interfaces must be set to allow space for
312those headers.
313.PP
314.nf
315site-A:# ip link set l2tpeth0 up mtu 1446
Stephen Hemmingerec72fd72012-10-03 08:45:32 -0700316site-A:# ip link add br0 type bridge
317site-A:# ip link set l2tpeth0 master br0
318site-A:# ip link set eth0 master br0
James Chapman6121e1f2012-05-01 15:25:23 +0100319site-A:# ip link set br0 up
320.fi
321.PP
322If you are using VLANs, setup a bridge per VLAN and bridge each VLAN
323over a separate L2TP session. For example, to bridge VLAN ID 5 on eth1
324over an L2TP pseudowire:
325.PP
326.nf
327site-A:# ip link set l2tpeth0 up mtu 1446
Stephen Hemmingerec72fd72012-10-03 08:45:32 -0700328site-A:# ip link add brvlan5 type bridge
329site-A:# ip link set l2tpeth0.5 master brvlan5
330site-A:# ip link set eth1.5 master brvlan5
James Chapman6121e1f2012-05-01 15:25:23 +0100331site-A:# ip link set brvlan5 up
332.fi
333.PP
334Adding the L2TP interface to a bridge causes the bridge to forward
335traffic over the L2TP pseudowire just like it forwards over any other
336interface. The bridge learns MAC addresses of hosts attached to each
337interface and intelligently forwards frames from one bridge port to
338another. IP addresses are not assigned to the l2tpethN interfaces. If
339the bridge is correctly configured at both sides of the L2TP
340pseudowire, it should be possible to reach hosts in the peer's bridged
341network.
342.PP
343When raw ethernet frames are bridged across an L2TP tunnel, large
344frames may be fragmented and forwarded as individual IP fragments to
345the recipient, depending on the MTU of the physical interface used by
346the tunnel. When the ethernet frames carry protocols which are
347reassembled by the recipient, like IP, this isn't a problem. However,
348such fragmentation can cause problems for protocols like PPPoE where
349the recipient expects to receive ethernet frames exactly as
350transmitted. In such cases, it is important that frames leaving the
351tunnel are reassembled back into a single frame before being
352forwarded on. To do so, enable netfilter connection tracking
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500353(conntrack) or manually load the Linux netfilter defrag modules at
James Chapman6121e1f2012-05-01 15:25:23 +0100354each tunnel endpoint.
355.PP
356.nf
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500357site-A:# modprobe nf_defrag_ipv4
James Chapman6121e1f2012-05-01 15:25:23 +0100358
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500359site-B:# modprobe nf_defrag_ipv4
James Chapman6121e1f2012-05-01 15:25:23 +0100360.fi
361.PP
Lennart Sorensenc9ae9ba2015-02-24 15:29:15 -0500362If L2TP is being used over IPv6, use the IPv6 defrag module.
Petr Sabata6274b0b2013-04-04 03:36:57 +0000363.SH INTEROPERABILITY
James Chapman6121e1f2012-05-01 15:25:23 +0100364.PP
365Unmanaged (static) L2TPv3 tunnels are supported by some network
366equipment equipment vendors such as Cisco.
367.PP
368In Linux, L2TP Hello messages are not supported in unmanaged
369tunnels. Hello messages are used by L2TP clients and servers to detect
370link failures in order to automate tearing down and reestablishing
371dynamic tunnels. If a non-Linux peer supports Hello messages in
372unmanaged tunnels, it must be turned off to interoperate with Linux.
James Chapman9c064b52013-03-26 06:49:23 +0000373.PP
374Linux defaults to use the Default Layer2SpecificHeader type as defined
375in the L2TPv3 protocol specification, RFC3931. This setting must be
376consistent with that configured at the peer. Some vendor
377implementations (e.g. Cisco) default to use a Layer2SpecificHeader
378type of None.
James Chapman6121e1f2012-05-01 15:25:23 +0100379.SH SEE ALSO
380.br
James Chapman6121e1f2012-05-01 15:25:23 +0100381.BR ip (8)
382.SH AUTHOR
383James Chapman <jchapman@katalix.com>