]> git.ipfire.org Git - thirdparty/openvpn.git/blob - doc/man-sections/link-options.rst
Persist-key: enable persist-key option by default
[thirdparty/openvpn.git] / doc / man-sections / link-options.rst
1 Link Options
2 ------------
3 This link options section covers options related to the connection between
4 the local and the remote host.
5
6 --bind keywords
7 Bind to local address and port. This is the default unless any of
8 ``--proto tcp-client`` , ``--http-proxy`` or ``--socks-proxy`` are used.
9
10 If the optional :code:`ipv6only` keyword is present OpenVPN will bind only
11 to IPv6 (as opposed to IPv6 and IPv4) when a IPv6 socket is opened.
12
13 --float
14 Allow remote peer to change its IP address and/or port number, such as
15 due to DHCP (this is the default if ``--remote`` is not used).
16 ``--float`` when specified with ``--remote`` allows an OpenVPN session
17 to initially connect to a peer at a known address, however if packets
18 arrive from a new address and pass all authentication tests, the new
19 address will take control of the session. This is useful when you are
20 connecting to a peer which holds a dynamic address such as a dial-in
21 user or DHCP client.
22
23 Essentially, ``--float`` tells OpenVPN to accept authenticated packets
24 from any address, not only the address which was specified in the
25 ``--remote`` option.
26
27 --fragment args
28
29 Valid syntax:
30 ::
31
32 fragment max
33 fragment max mtu
34
35 Enable internal datagram fragmentation so that no UDP datagrams are sent
36 which are larger than ``max`` bytes.
37
38 If the :code:`mtu` parameter is present the ``max`` parameter is
39 interpreted to include IP and UDP encapsulation overhead. The
40 :code:`mtu` parameter is introduced in OpenVPN version 2.6.0.
41
42 If the :code:`mtu` parameter is absent, the ``max`` parameter is
43 interpreted in the same way as the ``--link-mtu`` parameter, i.e.
44 the UDP packet size after encapsulation overhead has been added in,
45 but not including the UDP header itself.
46
47 The ``--fragment`` option only makes sense when you are using the UDP
48 protocol (``--proto udp``).
49
50 ``--fragment`` adds 4 bytes of overhead per datagram.
51
52 See the ``--mssfix`` option below for an important related option to
53 ``--fragment``.
54
55 It should also be noted that this option is not meant to replace UDP
56 fragmentation at the IP stack level. It is only meant as a last resort
57 when path MTU discovery is broken. Using this option is less efficient
58 than fixing path MTU discovery for your IP link and using native IP
59 fragmentation instead.
60
61 Having said that, there are circumstances where using OpenVPN's internal
62 fragmentation capability may be your only option, such as tunneling a
63 UDP multicast stream which requires fragmentation.
64
65 --keepalive args
66 A helper directive designed to simplify the expression of ``--ping`` and
67 ``--ping-restart``.
68
69 Valid syntax:
70 ::
71
72 keepalive interval timeout
73
74 Send ping once every ``interval`` seconds, restart if ping is not received
75 for ``timeout`` seconds.
76
77 This option can be used on both client and server side, but it is enough
78 to add this on the server side as it will push appropriate ``--ping``
79 and ``--ping-restart`` options to the client. If used on both server and
80 client, the values pushed from server will override the client local
81 values.
82
83 The ``timeout`` argument will be twice as long on the server side. This
84 ensures that a timeout is detected on client side before the server side
85 drops the connection.
86
87 For example, ``--keepalive 10 60`` expands as follows:
88 ::
89
90 if mode server:
91 ping 10 # Argument: interval
92 ping-restart 120 # Argument: timeout*2
93 push "ping 10" # Argument: interval
94 push "ping-restart 60" # Argument: timeout
95 else
96 ping 10 # Argument: interval
97 ping-restart 60 # Argument: timeout
98
99 --link-mtu n
100 **DEPRECATED** Sets an upper bound on the size of UDP packets which are sent between
101 OpenVPN peers. *It's best not to set this parameter unless you know what
102 you're doing.*
103
104 Due to variable header size of IP header (20 bytes for IPv4 and 40 bytes
105 for IPv6) and dynamically negotiated data channel cipher, this option
106 is not reliable. It is recommended to set tun-mtu with enough headroom
107 instead.
108
109 --local host
110 Local host name or IP address for bind. If specified, OpenVPN will bind
111 to this address only. If unspecified, OpenVPN will bind to all
112 interfaces.
113
114 --lport port
115 Set local TCP/UDP port number or name. Cannot be used together with
116 ``--nobind`` option.
117
118 --mark value
119 Mark encrypted packets being sent with ``value``. The mark value can be
120 matched in policy routing and packetfilter rules. This option is only
121 supported in Linux and does nothing on other operating systems.
122
123 --mode m
124 Set OpenVPN major mode. By default, OpenVPN runs in point-to-point mode
125 (:code:`p2p`). OpenVPN 2.0 introduces a new mode (:code:`server`) which
126 implements a multi-client server capability.
127
128 --mssfix args
129
130 Valid syntax:
131 ::
132
133 mssfix max [mtu]
134
135 mssfix max [fixed]
136
137 mssfix
138
139 Announce to TCP sessions running over the tunnel that they should limit
140 their send packet sizes such that after OpenVPN has encapsulated them,
141 the resulting UDP packet size that OpenVPN sends to its peer will not
142 exceed ``max`` bytes. The default value is :code:`1492 mtu`. Use :code:`0`
143 as max to disable mssfix.
144
145 If the :code:`mtu` parameter is specified the ``max`` value is interpreted
146 as the resulting packet size of VPN packets including the IP and UDP header.
147 Support for the :code:`mtu` parameter was added with OpenVPN version 2.6.0.
148
149 If the :code:`mtu` parameter is not specified, the ``max`` parameter
150 is interpreted in the same way as the ``--link-mtu`` parameter, i.e.
151 the UDP packet size after encapsulation overhead has been added in, but
152 not including the UDP header itself. Resulting packet would be at most 28
153 bytes larger for IPv4 and 48 bytes for IPv6 (20/40 bytes for IP header and
154 8 bytes for UDP header). Default value of 1450 allows OpenVPN packets to be
155 transmitted over IPv4 on a link with MTU 1478 or higher without IP level
156 fragmentation (and 1498 for IPv6).
157
158 If the :code:`fixed` parameter is specified, OpenVPN will make no attempt
159 to calculate the VPN encapsulation overhead but instead will set the MSS to
160 limit the size of the payload IP packets to the specified number. IPv4 packets
161 will have the MSS value lowered to mssfix - 40 and IPv6 packets to mssfix - 60.
162
163 if ``--mssfix`` is specified is specified without any parameter it
164 inherits the parameters of ``--fragment`` if specified or uses the
165 default for ``--mssfix`` otherwise.
166
167 The ``--mssfix`` option only makes sense when you are using the UDP
168 protocol for OpenVPN peer-to-peer communication, i.e. ``--proto udp``.
169
170 ``--mssfix`` and ``--fragment`` can be ideally used together, where
171 ``--mssfix`` will try to keep TCP from needing packet fragmentation in
172 the first place, and if big packets come through anyhow (from protocols
173 other than TCP), ``--fragment`` will internally fragment them.
174
175 ``--max-packet-size``, ``--fragment``, and ``--mssfix`` are designed to
176 work around cases where Path MTU discovery is broken on the network path
177 between OpenVPN peers.
178
179 The usual symptom of such a breakdown is an OpenVPN connection which
180 successfully starts, but then stalls during active usage.
181
182 If ``--fragment`` and ``--mssfix`` are used together, ``--mssfix`` will
183 take its default ``max`` parameter from the ``--fragment max`` option.
184
185 Therefore, one could lower the maximum UDP packet size to 1300 (a good
186 first try for solving MTU-related connection problems) with the
187 following options:
188 ::
189
190 --tun-mtu 1500 --fragment 1300 --mssfix
191
192 If the ``max-packet-size size`` option is used in the configuration
193 it will also act as if ``mssfix size mtu`` was specified in the
194 configuration.
195
196 --mtu-disc type
197 Should we do Path MTU discovery on TCP/UDP channel? Only supported on
198 OSes such as Linux that supports the necessary system call to set.
199
200 Valid types:
201
202 :code:`no` Never send DF (Don't Fragment) frames
203
204 :code:`maybe` Use per-route hints
205
206 :code:`yes` Always DF (Don't Fragment)
207
208 --mtu-test
209 To empirically measure MTU on connection startup, add the ``--mtu-test``
210 option to your configuration. OpenVPN will send ping packets of various
211 sizes to the remote peer and measure the largest packets which were
212 successfully received. The ``--mtu-test`` process normally takes about 3
213 minutes to complete.
214
215 --nobind
216 Do not bind to local address and port. The IP stack will allocate a
217 dynamic port for returning packets. Since the value of the dynamic port
218 could not be known in advance by a peer, this option is only suitable
219 for peers which will be initiating connections by using the ``--remote``
220 option.
221
222 --passtos
223 Set the TOS field of the tunnel packet to what the payload's TOS is.
224
225 --ping n
226 Ping remote over the TCP/UDP control channel if no packets have been
227 sent for at least ``n`` seconds (specify ``--ping`` on both peers to
228 cause ping packets to be sent in both directions since OpenVPN ping
229 packets are not echoed like IP ping packets).
230
231 This option has two intended uses:
232
233 (1) Compatibility with stateful firewalls. The periodic ping will ensure
234 that a stateful firewall rule which allows OpenVPN UDP packets to
235 pass will not time out.
236
237 (2) To provide a basis for the remote to test the existence of its peer
238 using the ``--ping-exit`` option.
239
240 When using OpenVPN in server mode see also ``--keepalive``.
241
242 --ping-exit n
243 Causes OpenVPN to exit after ``n`` seconds pass without reception of a
244 ping or other packet from remote. This option can be combined with
245 ``--inactive``, ``--ping`` and ``--ping-exit`` to create a two-tiered
246 inactivity disconnect.
247
248 For example,
249 ::
250
251 openvpn [options...] --inactive 3600 --ping 10 --ping-exit 60
252
253 when used on both peers will cause OpenVPN to exit within 60 seconds if
254 its peer disconnects, but will exit after one hour if no actual tunnel
255 data is exchanged.
256
257 --ping-restart n
258 Similar to ``--ping-exit``, but trigger a :code:`SIGUSR1` restart after
259 ``n`` seconds pass without reception of a ping or other packet from
260 remote.
261
262 This option is useful in cases where the remote peer has a dynamic IP
263 address and a low-TTL DNS name is used to track the IP address using a
264 service such as https://www.nsupdate.info/ + a dynamic DNS client such as
265 ``ddclient``.
266
267 If the peer cannot be reached, a restart will be triggered, causing the
268 hostname used with ``--remote`` to be re-resolved (if ``--resolv-retry``
269 is also specified).
270
271 In server mode, ``--ping-restart``, ``--inactive`` or any other type of
272 internally generated signal will always be applied to individual client
273 instance objects, never to whole server itself. Note also in server mode
274 that any internally generated signal which would normally cause a
275 restart, will cause the deletion of the client instance object instead.
276
277 In client mode, the ``--ping-restart`` parameter is set to 120 seconds
278 by default. This default will hold until the client pulls a replacement
279 value from the server, based on the ``--keepalive`` setting in the
280 server configuration. To disable the 120 second default, set
281 ``--ping-restart 0`` on the client.
282
283 See the signals section below for more information on :code:`SIGUSR1`.
284
285 Note that the behavior of ``SIGUSR1`` can be modified by the
286 ``--persist-tun``, ``--persist-local-ip`` and
287 ``--persist-remote-ip`` options.
288
289 Also note that ``--ping-exit`` and ``--ping-restart`` are mutually
290 exclusive and cannot be used together.
291
292 --ping-timer-rem
293 Run the ``--ping-exit`` / ``--ping-restart`` timer only if we have a
294 remote address. Use this option if you are starting the daemon in listen
295 mode (i.e. without an explicit ``--remote`` peer), and you don't want to
296 start clocking timeouts until a remote peer connects.
297
298 --proto p
299 Use protocol ``p`` for communicating with remote host. ``p`` can be
300 :code:`udp`, :code:`tcp-client`, or :code:`tcp-server`. You can also
301 limit OpenVPN to use only IPv4 or only IPv6 by specifying ``p`` as
302 :code:`udp4`, :code:`tcp4-client`, :code:`tcp4-server` or :code:`udp6`,
303 :code:`tcp6-client`, :code:`tcp6-server`, respectively.
304
305 The default protocol is :code:`udp` when ``--proto`` is not specified.
306
307 For UDP operation, ``--proto udp`` should be specified on both peers.
308
309 For TCP operation, one peer must use ``--proto tcp-server`` and the
310 other must use ``--proto tcp-client``. A peer started with
311 :code:`tcp-server` will wait indefinitely for an incoming connection. A peer
312 started with :code:`tcp-client` will attempt to connect, and if that fails,
313 will sleep for 5 seconds (adjustable via the ``--connect-retry`` option)
314 and try again infinite or up to N retries (adjustable via the
315 ``--connect-retry-max`` option). Both TCP client and server will
316 simulate a SIGUSR1 restart signal if either side resets the connection.
317
318 OpenVPN is designed to operate optimally over UDP, but TCP capability is
319 provided for situations where UDP cannot be used. In comparison with
320 UDP, TCP will usually be somewhat less efficient and less robust when
321 used over unreliable or congested networks.
322
323 This article outlines some of problems with tunneling IP over TCP:
324 http://sites.inka.de/sites/bigred/devel/tcp-tcp.html
325
326 There are certain cases, however, where using TCP may be advantageous
327 from a security and robustness perspective, such as tunneling non-IP or
328 application-level UDP protocols, or tunneling protocols which don't
329 possess a built-in reliability layer.
330
331 --port port
332 TCP/UDP port number or port name for both local and remote (sets both
333 ``--lport`` and ``--rport`` options to given port). The current default
334 of 1194 represents the official IANA port number assignment for OpenVPN
335 and has been used since version 2.0-beta17. Previous versions used port
336 5000 as the default.
337
338 --rport port
339 Set TCP/UDP port number or name used by the ``--remote`` option. The
340 port can also be set directly using the ``--remote`` option.
341
342 --replay-window args
343 Modify the replay protection sliding-window size and time window.
344
345 Valid syntaxes::
346
347 replay-window n
348 replay-window n t
349
350 Use a replay protection sliding-window of size ``n`` and a time window
351 of ``t`` seconds.
352
353 By default ``n`` is :code:`64` (the IPSec default) and ``t`` is
354 :code:`15` seconds.
355
356 This option is only relevant in UDP mode, i.e. when either ``--proto
357 udp`` is specified, or no ``--proto`` option is specified.
358
359 When OpenVPN tunnels IP packets over UDP, there is the possibility that
360 packets might be dropped or delivered out of order. Because OpenVPN,
361 like IPSec, is emulating the physical network layer, it will accept an
362 out-of-order packet sequence, and will deliver such packets in the same
363 order they were received to the TCP/IP protocol stack, provided they
364 satisfy several constraints.
365
366 (a) The packet cannot be a replay.
367
368 (b) If a packet arrives out of order, it will only be accepted if
369 the difference between its sequence number and the highest sequence
370 number received so far is less than ``n``.
371
372 (c) If a packet arrives out of order, it will only be accepted if it
373 arrives no later than ``t`` seconds after any packet containing a higher
374 sequence number.
375
376 If you are using a network link with a large pipeline (meaning that the
377 product of bandwidth and latency is high), you may want to use a larger
378 value for ``n``. Satellite links in particular often require this.
379
380 If you run OpenVPN at ``--verb 4``, you will see the message
381 "PID_ERR replay-window backtrack occurred [x]" every time the maximum sequence
382 number backtrack seen thus far increases. This can be used to calibrate
383 ``n``.
384
385 There is some controversy on the appropriate method of handling packet
386 reordering at the security layer.
387
388 Namely, to what extent should the security layer protect the
389 encapsulated protocol from attacks which masquerade as the kinds of
390 normal packet loss and reordering that occur over IP networks?
391
392 The IPSec and OpenVPN approach is to allow packet reordering within a
393 certain fixed sequence number window.
394
395 OpenVPN adds to the IPSec model by limiting the window size in time as
396 well as sequence space.
397
398 OpenVPN also adds TCP transport as an option (not offered by IPSec) in
399 which case OpenVPN can adopt a very strict attitude towards message
400 deletion and reordering: Don't allow it. Since TCP guarantees
401 reliability, any packet loss or reordering event can be assumed to be an
402 attack.
403
404 In this sense, it could be argued that TCP tunnel transport is preferred
405 when tunneling non-IP or UDP application protocols which might be
406 vulnerable to a message deletion or reordering attack which falls within
407 the normal operational parameters of IP networks.
408
409 So I would make the statement that one should never tunnel a non-IP
410 protocol or UDP application protocol over UDP, if the protocol might be
411 vulnerable to a message deletion or reordering attack that falls within
412 the normal operating parameters of what is to be expected from the
413 physical IP layer. The problem is easily fixed by simply using TCP as
414 the VPN transport layer.
415
416 --replay-persist file
417 Persist replay-protection state across sessions using ``file`` to save
418 and reload the state.
419
420 This option will keep a disk copy of the current replay protection state
421 (i.e. the most recent packet timestamp and sequence number received from
422 the remote peer), so that if an OpenVPN session is stopped and
423 restarted, it will reject any replays of packets which were already
424 received by the prior session.
425
426 This option only makes sense when replay protection is enabled (the
427 default) and you are using TLS mode with ``--tls-auth``.
428
429 --session-timeout n
430 Raises :code:`SIGTERM` for the client instance after ``n`` seconds since
431 the beginning of the session, forcing OpenVPN to disconnect.
432 In client mode, OpenVPN will disconnect and exit, while in server mode
433 all client sessions are terminated.
434
435 This option can also be specified in a client instance config file
436 using ``--client-config-dir`` or dynamically generated using a
437 ``--client-connect`` script. In these cases, only the related client
438 session is terminated.
439
440 --socket-flags flags
441 Apply the given flags to the OpenVPN transport socket. Currently, only
442 :code:`TCP_NODELAY` is supported.
443
444 The :code:`TCP_NODELAY` socket flag is useful in TCP mode, and causes the
445 kernel to send tunnel packets immediately over the TCP connection without
446 trying to group several smaller packets into a larger packet. This can
447 result in a considerably improvement in latency.
448
449 This option is pushable from server to client, and should be used on
450 both client and server for maximum effect.
451
452 --tcp-nodelay
453 This macro sets the :code:`TCP_NODELAY` socket flag on the server as well
454 as pushes it to connecting clients. The :code:`TCP_NODELAY` flag disables
455 the Nagle algorithm on TCP sockets causing packets to be transmitted
456 immediately with low latency, rather than waiting a short period of time
457 in order to aggregate several packets into a larger containing packet.
458 In VPN applications over TCP, :code:`TCP_NODELAY` is generally a good
459 latency optimization.
460
461 The macro expands as follows:
462 ::
463
464 if mode server:
465 socket-flags TCP_NODELAY
466 push "socket-flags TCP_NODELAY"
467
468 --max-packet-size size
469 This option will instruct OpenVPN to try to limit the maximum on-write packet
470 size by restricting the control channel packet size and setting ``--mssfix``.
471
472 OpenVPN will try to keep its control channel messages below this size but
473 due to some constraints in the protocol this is not always possible. If the
474 option is not set, the control packet maximum size defaults to 1250.
475 The control channel packet size will be restricted to values between
476 154 and 2048. The maximum packet size includes encapsulation overhead like
477 UDP and IP.
478
479 In terms of ``--mssfix`` it will expand to:
480 ::
481
482 mssfix size mtu
483
484 If you need to set ``--mssfix`` for data channel and control channel maximum
485 packet size independently, use ``--max-packet-size`` first, followed by a
486 ``--mssfix`` in the configuration.
487
488 In general the default size of 1250 should work almost universally apart
489 from specific corner cases, especially since IPv6 requires a MTU of 1280
490 or larger.