openvpn

Secure IP tunnel daemon

Manual section:8
Manual group:System Manager's Manual

SYNOPSIS

openvpn [ options ... ]
openvpn --help

INTRODUCTION

OpenVPN is an open source VPN daemon by James Yonan. Because OpenVPN tries to be a universal VPN tool offering a great deal of flexibility, there are a lot of options on this manual page. If you're new to OpenVPN, you might want to skip ahead to the examples section where you will see how to construct simple VPNs on the command line without even needing a configuration file.

Also note that there's more documentation and examples on the OpenVPN web site: https://openvpn.net/

And if you would like to see a shorter version of this manual, see the openvpn usage message which can be obtained by running openvpn without any parameters.

DESCRIPTION

OpenVPN is a robust and highly flexible VPN daemon. OpenVPN supports SSL/TLS security, ethernet bridging, TCP or UDP tunnel transport through proxies or NAT, support for dynamic IP addresses and DHCP, scalability to hundreds or thousands of users, and portability to most major OS platforms.

OpenVPN is tightly bound to the OpenSSL library, and derives much of its crypto capabilities from it.

OpenVPN supports conventional encryption using a pre-shared secret key (Static Key mode) or public key security (SSL/TLS mode) using client & server certificates. OpenVPN also supports non-encrypted TCP/UDP tunnels.

OpenVPN is designed to work with the TUN/TAP virtual networking interface that exists on most platforms.

Overall, OpenVPN aims to offer many of the key features of IPSec but with a relatively lightweight footprint.

OPTIONS

OpenVPN allows any option to be placed either on the command line or in a configuration file. Though all command line options are preceded by a double-leading-dash ("--"), this prefix can be removed when an option is placed in a configuration file.

Generic Options

This section covers generic options which are accessible regardless of which mode OpenVPN is configured as.

--help Show options.
--auth-nocache

Don't cache --askpass or --auth-user-pass username/passwords in virtual memory.

If specified, this directive will cause OpenVPN to immediately forget username/password inputs after they are used. As a result, when OpenVPN needs a username/password, it will prompt for input from stdin, which may be multiple times during the duration of an OpenVPN session.

When using --auth-nocache in combination with a user/password file and --chroot or --daemon, make sure to use an absolute path.

This directive does not affect the --http-proxy username/password. It is always cached.

--cd dir

Change directory to dir prior to reading any files such as configuration files, key files, scripts, etc. dir should be an absolute path, with a leading "/", and without any references to the current directory such as . or ...

This option is useful when you are running OpenVPN in --daemon mode, and you want to consolidate all of your OpenVPN control files in one location.

--chroot dir

Chroot to dir after initialization. --chroot essentially redefines dir as being the top level directory tree (/). OpenVPN will therefore be unable to access any files outside this tree. This can be desirable from a security standpoint.

Since the chroot operation is delayed until after initialization, most OpenVPN options that reference files will operate in a pre-chroot context.

In many cases, the dir parameter can point to an empty directory, however complications can result when scripts or restarts are executed after the chroot operation.

Note: The SSL library will probably need /dev/urandom to be available inside the chroot directory dir. This is because SSL libraries occasionally need to collect fresh randomness. Newer linux kernels and some BSDs implement a getrandom() or getentropy() syscall that removes the need for /dev/urandom to be available.

--compat-mode version
 

This option provides a convenient way to alter the defaults of OpenVPN to be more compatible with the version version specified. All of the changes this option applies can also be achieved using individual configuration options.

The version specified with this option is the version of OpenVPN peer OpenVPN should try to be compatible with. In general OpenVPN should be compatible with the last two previous version without this option. E.g. OpenVPN 2.6.0 should be compatible with 2.5.x and 2.4.x without this option. However, there might be some edge cases that still require this option even in these cases.

Note: Using this option reverts defaults to no longer recommended values and should be avoided if possible.

The following table details what defaults are changed depending on the version specified.

  • 2.5.x or lower: --allow-compression asym is automatically added to the configuration if no other compression options are present.
  • 2.4.x or lower: The cipher in --cipher is appended to --data-ciphers.
  • 2.3.x or lower: --data-ciphers-fallback is automatically added with the same cipher as --cipher.
  • 2.3.6 or lower: --tls-version-min 1.0 is added to the configuration when --tls-version-min is not explicitly set.

If not required, this is option should be avoided. Setting this option can lower security or disable features like data-channel offloading.

--config file

Load additional config options from file where each line corresponds to one command line option, but with the leading -- removed.

If --config file is the only option to the openvpn command, the --config can be removed, and the command can be given as openvpn file

Note that configuration files can be nested to a reasonable depth.

Double quotation or single quotation characters ("", '') can be used to enclose single parameters containing whitespace, and "#" or ";" characters in the first column can be used to denote comments.

Note that OpenVPN 2.0 and higher performs backslash-based shell escaping for characters not in single quotations, so the following mappings should be observed:

\\       Maps to a single backslash character (\).
\"       Pass a literal doublequote character ("), don't
         interpret it as enclosing a parameter.
\[SPACE] Pass a literal space or tab character, don't
         interpret it as a parameter delimiter.

For example on Windows, use double backslashes to represent pathnames:

secret "c:\\OpenVPN\\secret.key"

For examples of configuration files, see https://openvpn.net/community-resources/how-to/

Here is an example configuration file:

#
# Sample OpenVPN configuration file for
# using a pre-shared static key.
#
# '#' or ';' may be used to delimit comments.

# Use a dynamic tun device.
dev tun

# Our remote peer
remote mypeer.mydomain

# 10.1.0.1 is our local VPN endpoint
# 10.1.0.2 is our remote VPN endpoint
ifconfig 10.1.0.1 10.1.0.2

# Our pre-shared static key
secret static.key
--daemon progname
 

Become a daemon after all initialization functions are completed.

Valid syntaxes:

daemon
daemon progname

This option will cause all message and error output to be sent to the syslog file (such as /var/log/messages), except for the output of scripts and ifconfig commands, which will go to /dev/null unless otherwise redirected. The syslog redirection occurs immediately at the point that --daemon is parsed on the command line even though the daemonization point occurs later. If one of the --log options is present, it will supersede syslog redirection.

The optional progname parameter will cause OpenVPN to report its program name to the system logger as progname. This can be useful in linking OpenVPN messages in the syslog file with specific tunnels. When unspecified, progname defaults to openvpn.

When OpenVPN is run with the --daemon option, it will try to delay daemonization until the majority of initialization functions which are capable of generating fatal errors are complete. This means that initialization scripts can test the return status of the openvpn command for a fairly reliable indication of whether the command has correctly initialized and entered the packet forwarding event loop.

In OpenVPN, the vast majority of errors which occur after initialization are non-fatal.

Note: as soon as OpenVPN has daemonized, it can not ask for usernames, passwords, or key pass phrases anymore. This has certain consequences, namely that using a password-protected private key will fail unless the --askpass option is used to tell OpenVPN to ask for the pass phrase (this requirement is new in v2.3.7, and is a consequence of calling daemon() before initializing the crypto layer).

Further, using --daemon together with --auth-user-pass (entered on console) and --auth-nocache will fail as soon as key renegotiation (and reauthentication) occurs.

--disable-dco

Disable "data channel offload" (DCO).

On Linux don't use the ovpn-dco device driver, but rather rely on the legacy tun module.

You may want to use this option if your server needs to allow clients older than version 2.4 to connect.

--disable-occ

DEPRECATED Disable "options consistency check" (OCC) in configurations that do not use TLS.

Don't output a warning message if option inconsistencies are detected between peers. An example of an option inconsistency would be where one peer uses --dev tun while the other peer uses --dev tap.

Use of this option is discouraged, but is provided as a temporary fix in situations where a recent version of OpenVPN must connect to an old version.

--engine engine-name
 

Enable OpenSSL hardware-based crypto engine functionality.

Valid syntaxes:

engine
engine engine-name

If engine-name is specified, use a specific crypto engine. Use the --show-engines standalone option to list the crypto engines which are supported by OpenSSL.

--fast-io

(Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to poll/epoll/select prior to the write operation. The purpose of such a call would normally be to block until the device or socket is ready to accept the write. Such blocking is unnecessary on some platforms which don't support write blocking on UDP sockets or TUN/TAP devices. In such cases, one can optimize the event loop by avoiding the poll/epoll/select call, improving CPU efficiency by 5% to 10%.

This option can only be used on non-Windows systems, when --proto udp is specified, and when --shaper is NOT specified.

--group group Similar to the --user option, this option changes the group ID of the OpenVPN process to group after initialization.
--ignore-unknown-option args
 

Valid syntax:

ignore-unknown-options opt1 opt2 opt3 ... optN

When one of options opt1 ... optN is encountered in the configuration file the configuration file parsing does not fail if this OpenVPN version does not support the option. Multiple --ignore-unknown-option options can be given to support a larger number of options to ignore.

This option should be used with caution, as there are good security reasons for having OpenVPN fail if it detects problems in a config file. Having said that, there are valid reasons for wanting new software features to gracefully degrade when encountered by older software versions.

--ignore-unknown-option is available since OpenVPN 2.3.3.

--iproute cmd Set alternate command to execute instead of default iproute2 command. May be used in order to execute OpenVPN in unprivileged environment.
--keying-material-exporter args
 

Save Exported Keying Material [RFC5705] of len bytes (must be between 16 and 4095 bytes) using label in environment (exported_keying_material) for use by plugins in OPENVPN_PLUGIN_TLS_FINAL callback.

Valid syntax:

keying-material-exporter label len

Note that exporter labels have the potential to collide with existing PRF labels. In order to prevent this, labels MUST begin with EXPORTER.

--mlock

Disable paging by calling the POSIX mlockall function. Requires that OpenVPN be initially run as root (though OpenVPN can subsequently downgrade its UID using the --user option).

Using this option ensures that key material and tunnel data are never written to disk due to virtual memory paging operations which occur under most modern operating systems. It ensures that even if an attacker was able to crack the box running OpenVPN, he would not be able to scan the system swap file to recover previously used ephemeral keys, which are used for a period of time governed by the --reneg options (see below), then are discarded.

The downside of using --mlock is that it will reduce the amount of physical memory available to other applications.

The limit on how much memory can be locked and how that limit is enforced are OS-dependent. On Linux the default limit that an unprivileged process may lock (RLIMIT_MEMLOCK) is low, and if privileges are dropped later, future memory allocations will very likely fail. The limit can be increased using ulimit or systemd directives depending on how OpenVPN is started.

If the platform has the getrlimit(2) system call, OpenVPN will check for the amount of mlock-able memory before calling mlockall(2), and tries to increase the limit to 100 MB if less than this is configured. 100 Mb is somewhat arbitrary - it is enough for a moderately-sized OpenVPN deployment, but the memory usage might go beyond that if the number of concurrent clients is high.

--nice n Change process priority after initialization (n greater than 0 is lower priority, n less than zero is higher priority).
--persist-key

Don't re-read key files across SIGUSR1 or --ping-restart.

This option can be combined with --user to allow restarts triggered by the SIGUSR1 signal. Normally if you drop root privileges in OpenVPN, the daemon cannot be restarted since it will now be unable to re-read protected key files.

This option solves the problem by persisting keys across SIGUSR1 resets, so they don't need to be re-read.

--providers providers
 

Load the list of (OpenSSL) providers. This is mainly useful for using an external provider for key management like tpm2-openssl or to load the legacy provider with

--providers legacy default

Behaviour of changing this option between SIGHUP might not be well behaving. If you need to change/add/remove this option, fully restart OpenVPN.

--remap-usr1 signal
 

Control whether internally or externally generated SIGUSR1 signals are remapped to SIGHUP (restart without persisting state) or SIGTERM (exit).

signal can be set to SIGHUP or SIGTERM. By default, no remapping occurs.

--script-security level
 

This directive offers policy-level control over OpenVPN's usage of external programs and scripts. Lower level values are more restrictive, higher values are more permissive. Settings for level:

0
Strictly no calling of external programs.
1
(Default) Only call built-in executables such as ifconfig, ip, route, or netsh.
2
Allow calling of built-in executables and user-defined scripts.
3
Allow passwords to be passed to scripts via environmental variables (potentially unsafe).

OpenVPN releases before v2.3 also supported a method flag which indicated how OpenVPN should call external commands and scripts. This could be either execve or system. As of OpenVPN 2.3, this flag is no longer accepted. In most *nix environments the execve() approach has been used without any issues.

Some directives such as --up allow options to be passed to the external script. In these cases make sure the script name does not contain any spaces or the configuration parser will choke because it can't determine where the script name ends and script options start.

To run scripts in Windows in earlier OpenVPN versions you needed to either add a full path to the script interpreter which can parse the script or use the system flag to run these scripts. As of OpenVPN 2.3 it is now a strict requirement to have full path to the script interpreter when running non-executables files. This is not needed for executable files, such as .exe, .com, .bat or .cmd files. For example, if you have a Visual Basic script, you must use this syntax now:

--up 'C:\\Windows\\System32\\wscript.exe C:\\Program\ Files\\OpenVPN\\config\\my-up-script.vbs'

Please note the single quote marks and the escaping of the backslashes (\) and the space character.

The reason the support for the system flag was removed is due to the security implications with shell expansions when executing scripts via the system() call.

--setcon context
 

Apply SELinux context after initialization. This essentially provides the ability to restrict OpenVPN's rights to only network I/O operations, thanks to SELinux. This goes further than --user and --chroot in that those two, while being great security features, unfortunately do not protect against privilege escalation by exploitation of a vulnerable system call. You can of course combine all three, but please note that since setcon requires access to /proc you will have to provide it inside the chroot directory (e.g. with mount --bind).

Since the setcon operation is delayed until after initialization, OpenVPN can be restricted to just network-related system calls, whereas by applying the context before startup (such as the OpenVPN one provided in the SELinux Reference Policies) you will have to allow many things required only during initialization.

Like with chroot, complications can result when scripts or restarts are executed after the setcon operation, which is why you should really consider using the --persist-key and --persist-tun options.

--status args

Write operational status to file every n seconds. n defaults to 60 if not specified.

Valid syntaxes:

status file
status file n

Status can also be written to the syslog by sending a SIGUSR2 signal.

With multi-client capability enabled on a server, the status file includes a list of clients and a routing table. The output format can be controlled by the --status-version option in that case.

For clients or instances running in point-to-point mode, it will contain the traffic statistics.

--status-version n
 

Set the status file format version number to n.

This only affects the status file on servers with multi-client capability enabled. Valid status version values:

1
Traditional format (default). The client list contains the following fields comma-separated: Common Name, Real Address, Bytes Received, Bytes Sent, Connected Since.
2
A more reliable format for external processing. Compared to version 1, the client list contains some additional fields: Virtual Address, Virtual IPv6 Address, Username, Client ID, Peer ID, Data Channel Cipher. Future versions may extend the number of fields.
3
Identical to 2, but fields are tab-separated.
--test-crypto

Do a self-test of OpenVPN's crypto options by encrypting and decrypting test packets using the data channel encryption options specified above. This option does not require a peer to function, and therefore can be specified without --dev or --remote.

The typical usage of --test-crypto would be something like this:

openvpn --test-crypto --secret key

or

openvpn --test-crypto --secret key --verb 9

This option is very useful to test OpenVPN after it has been ported to a new platform, or to isolate problems in the compiler, OpenSSL crypto library, or OpenVPN's crypto code. Since it is a self-test mode, problems with encryption and authentication can be debugged independently of network and tunnel issues.

--tmp-dir dir

Specify a directory dir for temporary files. This directory will be used by openvpn processes and script to communicate temporary data with openvpn main process. Note that the directory must be writable by the OpenVPN process after it has dropped it's root privileges.

This directory will be used by in the following cases:

  • --client-connect scripts and OPENVPN_PLUGIN_CLIENT_CONNECT plug-in hook to dynamically generate client-specific configuration client_connect_config_file and return success/failure via client_connect_deferred_file when using deferred client connect method
  • OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY plug-in hooks returns success/failure via auth_control_file when using deferred auth method and pending authentication via pending_auth_file.
--use-prediction-resistance
 

Enable prediction resistance on mbed TLS's RNG.

Enabling prediction resistance causes the RNG to reseed in each call for random. Reseeding this often can quickly deplete the kernel entropy pool.

If you need this option, please consider running a daemon that adds entropy to the kernel pool.

--user user

Change the user ID of the OpenVPN process to user after initialization, dropping privileges in the process. This option is useful to protect the system in the event that some hostile party was able to gain control of an OpenVPN session. Though OpenVPN's security features make this unlikely, it is provided as a second line of defense.

By setting user to an unprivileged user dedicated to run openvpn, the hostile party would be limited in what damage they could cause. Of course once you take away privileges, you cannot return them to an OpenVPN session. This means, for example, that if you want to reset an OpenVPN daemon with a SIGUSR1 signal (for example in response to a DHCP reset), you should make use of one or more of the --persist options to ensure that OpenVPN doesn't need to execute any privileged operations in order to restart (such as re-reading key files or running ifconfig on the TUN device).

NOTE: Previous versions of openvpn used nobody as the example unpriviledged user. It is not recommended to actually use that user since it is usually used by other system services already. Always create a dedicated user for openvpn.

--writepid file
 Write OpenVPN's main process ID to file.

Log options

--echo parms

Echo parms to log output.

Designed to be used to send messages to a controlling application which is receiving the OpenVPN log output.

--errors-to-stderr
 Output errors to stderr instead of stdout unless log output is redirected by one of the --log options.
--log file

Output logging messages to file, including output to stdout/stderr which is generated by called scripts. If file already exists it will be truncated. This option takes effect immediately when it is parsed in the command line and will supersede syslog output if --daemon is also specified. This option is persistent over the entire course of an OpenVPN instantiation and will not be reset by SIGHUP, SIGUSR1, or --ping-restart.

Note that on Windows, when OpenVPN is started as a service, logging occurs by default without the need to specify this option.

--log-append file
 Append logging messages to file. If file does not exist, it will be created. This option behaves exactly like --log except that it appends to rather than truncating the log file.
--machine-readable-output
 Always write timestamps and message flags to log messages, even when they otherwise would not be prefixed. In particular, this applies to log messages sent to stdout.
--mute n Log at most n consecutive messages in the same category. This is useful to limit repetitive logging of similar message types.
--mute-replay-warnings
 Silence the output of replay warnings, which are a common false alarm on WiFi networks. This option preserves the security of the replay protection code without the verbosity associated with warnings about duplicate packets.
--suppress-timestamps
 Avoid writing timestamps to log messages, even when they otherwise would be prepended. In particular, this applies to log messages sent to stdout.
--syslog progname
 Direct log output to system logger, but do not become a daemon. See --daemon directive above for description of progname parameter.
--verb n

Set output verbosity to n (default 1). Each level shows all info from the previous levels. Level 3 is recommended if you want a good summary of what's happening without being swamped by output.

0
No output except fatal errors.
1 to 4
Normal usage range.
5
Outputs R and W characters to the console for each packet read and write, uppercase is used for TCP/UDP packets and lowercase is used for TUN/TAP packets.
6 to 11
Debug info range (see errlevel.h in the source code for additional information on debug levels).

Protocol options

Options in this section affect features available in the OpenVPN wire protocol. Many of these options also define the encryption options of the data channel in the OpenVPN wire protocol. These options must be configured in a compatible way between both the local and remote side.

--allow-compression mode
 

As described in the --compress option, compression is a potentially dangerous option. This option allows controlling the behaviour of OpenVPN when compression is used and allowed.

Valid syntaxes:

allow-compression
allow-compression mode

The mode argument can be one of the following values:

asym
OpenVPN will only decompress downlink packets but not compress uplink packets. This also allows migrating to disable compression when changing both server and client configurations to remove compression at the same time is not a feasible option.
no (default)
OpenVPN will refuse any compression. If data-channel offloading is enabled, OpenVPN will additionally also refuse compression framing (stub).
yes
OpenVPN will send and receive compressed packets.
--auth alg

Authenticate data channel packets and (if enabled) tls-auth control channel packets with HMAC using message digest algorithm alg. (The default is SHA1 ). HMAC is a commonly used message authentication algorithm (MAC) that uses a data string, a secure hash algorithm and a key to produce a digital signature.

The OpenVPN data channel protocol uses encrypt-then-mac (i.e. first encrypt a packet then HMAC the resulting ciphertext), which prevents padding oracle attacks.

If an AEAD cipher mode (e.g. GCM) is chosen then the specified --auth algorithm is ignored for the data channel and the authentication method of the AEAD cipher is used instead. Note that alg still specifies the digest used for tls-auth.

In static-key encryption mode, the HMAC key is included in the key file generated by --genkey. In TLS mode, the HMAC key is dynamically generated and shared between peers via the TLS control channel. If OpenVPN receives a packet with a bad HMAC it will drop the packet. HMAC usually adds 16 or 20 bytes per packet. Set alg=none to disable authentication.

For more information on HMAC see http://www.cs.ucsd.edu/users/mihir/papers/hmac.html

--cipher alg

This option should not be used any longer in TLS mode and still exists for two reasons:

  • compatibility with old configurations still carrying it around;
  • allow users connecting to OpenVPN peers older than 2.6.0 to have --cipher configured the same way as the remote counterpart. This can avoid MTU/frame size warnings.

Before 2.4.0, this option was used to select the cipher to be configured on the data channel, however, later versions usually ignored this directive in favour of a negotiated cipher. Starting with 2.6.0, this option is always ignored in TLS mode when it comes to configuring the cipher and will only control the cipher for --secret pre-shared-key mode (note: this mode is deprecated and strictly not recommended).

If you wish to specify the cipher to use on the data channel, please see --data-ciphers (for regular negotiation) and --data-ciphers-fallback (for a fallback option when the negotiation cannot take place because the other peer is old or has negotiation disabled).

To see ciphers that are available with OpenVPN, use the --show-ciphers option.

Set alg to none to disable encryption.

--compress algorithm
 

DEPRECATED Enable a compression algorithm. Compression is generally not recommended. VPN tunnels which use compression are susceptible to the VORALCE attack vector. See also the migrate parameter below.

The algorithm parameter may be lzo, lz4, lz4-v2, stub, stub-v2, migrate or empty. LZO and LZ4 are different compression algorithms, with LZ4 generally offering the best performance with least CPU usage.

The lz4-v2 and stub-v2 variants implement a better framing that does not add overhead when packets cannot be compressed. All other variants always add one extra framing byte compared to no compression framing.

Especially stub-v2 is essentially identical to no compression and no compression framing as its header indicates IP version 5 in a tun setup and can (ab)used to complete disable compression to clients. (See the migrate option below)

If the algorithm parameter is stub, stub-v2 or empty, compression will be turned off, but the packet framing for compression will still be enabled, allowing a different setting to be pushed later. Additionally, stub and stub-v2 wil disable announcing lzo and lz4 compression support via IV_ variables to the server.

Note: the stub (or empty) option is NOT compatible with the older option --comp-lzo no.

Using migrate as compression algorithm enables a special migration mode. It allows migration away from the --compress/--comp-lzo options to no compression. This option sets the server to no compression mode and the server behaves identical to a server without a compression option for all clients without a compression in their config. However, if a client is detected that indicates that compression is used (via OCC), the server will automatically add --push compress stub-v2 to the client specific configuration if supported by the client and otherwise switch to comp-lzo no and add --push comp-lzo to the client specific configuration.

*Security Considerations*

Compression and encryption is a tricky combination. If an attacker knows or is able to control (parts of) the plain-text of packets that contain secrets, the attacker might be able to extract the secret if compression is enabled. See e.g. the CRIME and BREACH attacks on TLS and VORACLE on VPNs which also leverage to break encryption. If you are not entirely sure that the above does not apply to your traffic, you are advised to not enable compression.

--comp-lzo mode
 

DEPRECATED Enable LZO compression algorithm. Compression is generally not recommended. VPN tunnels which uses compression are suspectible to the VORALCE attack vector.

Use LZO compression -- may add up to 1 byte per packet for incompressible data. mode may be yes, no, or adaptive (default).

In a server mode setup, it is possible to selectively turn compression on or off for individual clients.

First, make sure the client-side config file enables selective compression by having at least one --comp-lzo directive, such as --comp-lzo no. This will turn off compression by default, but allow a future directive push from the server to dynamically change the on/off/adaptive setting.

Next in a --client-config-dir file, specify the compression setting for the client, for example:

comp-lzo yes
push "comp-lzo yes"

The first line sets the comp-lzo setting for the server side of the link, the second sets the client side.

--comp-noadapt

DEPRECATED When used in conjunction with --comp-lzo, this option will disable OpenVPN's adaptive compression algorithm. Normally, adaptive compression is enabled with --comp-lzo.

Adaptive compression tries to optimize the case where you have compression enabled, but you are sending predominantly incompressible (or pre-compressed) packets over the tunnel, such as an FTP or rsync transfer of a large, compressed file. With adaptive compression, OpenVPN will periodically sample the compression process to measure its efficiency. If the data being sent over the tunnel is already compressed, the compression efficiency will be very low, triggering openvpn to disable compression for a period of time until the next re-sample test.

--key-direction
 Alternative way of specifying the optional direction parameter for the --tls-auth and --secret options. Useful when using inline files (See section on inline files).
--data-ciphers cipher-list
 

Restrict the allowed ciphers to be negotiated to the ciphers in cipher-list. cipher-list is a colon-separated list of ciphers, and defaults to AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305 when Chacha20-Poly1305 is available and otherwise AES-256-GCM:AES-128-GCM.

For servers, the first cipher from cipher-list that is also supported by the client will be pushed to clients that support cipher negotiation.

For more details see the chapter on Data channel cipher negotiation. Especially if you need to support clients with OpenVPN versions older than 2.4!

Starting with OpenVPN 2.6 a cipher can be prefixed with a ? to mark it as optional. This allows including ciphers in the list that may not be available on all platforms. E.g. AES-256-GCM:AES-128-GCM:?CHACHA20-POLY1305 would only enable Chacha20-Poly1305 if the underlying SSL library (and its configuration) supports it.

Cipher negotiation is enabled in client-server mode only. I.e. if --mode is set to server (server-side, implied by setting --server ), or if --pull is specified (client-side, implied by setting --client).

If no common cipher is found during cipher negotiation, the connection is terminated. To support old clients/old servers that do not provide any cipher negotiation support see --data-ciphers-fallback.

If --compat-mode is set to a version older than 2.5.0 the cipher specified by --cipher will be appended to --data-ciphers if not already present.

This list is restricted to be 127 chars long after conversion to OpenVPN ciphers.

This option was called --ncp-ciphers in OpenVPN 2.4 but has been renamed to --data-ciphers in OpenVPN 2.5 to more accurately reflect its meaning.

--data-ciphers-fallback alg
 

Configure a cipher that is used to fall back to if we could not determine which cipher the peer is willing to use.

This option should only be needed to connect to peers that are running OpenVPN 2.3 or older versions, and have been configured with --enable-small (typically used on routers or other embedded devices).

--secret args

DEPRECATED Enable Static Key encryption mode (non-TLS). Use pre-shared secret file which was generated with --genkey.

Valid syntaxes:

secret file
secret file direction

The optional direction parameter enables the use of 4 distinct keys (HMAC-send, cipher-encrypt, HMAC-receive, cipher-decrypt), so that each data flow direction has a different set of HMAC and cipher keys. This has a number of desirable security properties including eliminating certain kinds of DoS and message replay attacks.

When the direction parameter is omitted, 2 keys are used bidirectionally, one for HMAC and the other for encryption/decryption.

The direction parameter should always be complementary on either side of the connection, i.e. one side should use 0 and the other should use 1, or both sides should omit it altogether.

The direction parameter requires that file contains a 2048 bit key. While pre-1.5 versions of OpenVPN generate 1024 bit key files, any version of OpenVPN which supports the direction parameter, will also support 2048 bit key file generation using the --genkey option.

Static key encryption mode has certain advantages, the primary being ease of configuration.

There are no certificates or certificate authorities or complicated negotiation handshakes and protocols. The only requirement is that you have a pre-existing secure channel with your peer (such as ssh) to initially copy the key. This requirement, along with the fact that your key never changes unless you manually generate a new one, makes it somewhat less secure than TLS mode (see below). If an attacker manages to steal your key, everything that was ever encrypted with it is compromised. Contrast that to the perfect forward secrecy features of TLS mode (using Diffie Hellman key exchange), where even if an attacker was able to steal your private key, he would gain no information to help him decrypt past sessions.

Another advantageous aspect of Static Key encryption mode is that it is a handshake-free protocol without any distinguishing signature or feature (such as a header or protocol handshake sequence) that would mark the ciphertext packets as being generated by OpenVPN. Anyone eavesdropping on the wire would see nothing but random-looking data.

--tran-window n
 Transition window -- our old key can live this many seconds after a new a key renegotiation begins (default 3600 seconds). This feature allows for a graceful transition from old to new key, and removes the key renegotiation sequence from the critical path of tunnel data forwarding.
--force-tls-key-material-export
 This option is only available in --mode server and forces to use Keying Material Exporters (RFC 5705) for clients. This can be used to simulate an environment where the cryptographic library does not support the older method to generate data channel keys anymore. This option is intended to be a test option and might be removed in a future OpenVPN version without notice.

Client Options

The client options are used when connecting to an OpenVPN server configured to use --server, --server-bridge, or --mode server in its configuration.

--allow-pull-fqdn
 Allow client to pull DNS names from server (rather than being limited to IP address) for --ifconfig, --route, and --route-gateway.
--allow-recursive-routing
 When this option is set, OpenVPN will not drop incoming tun packets with same destination as host.
--auth-token token
 

This is not an option to be used directly in any configuration files, but rather push this option from a --client-connect script or a --plugin which hooks into the OPENVPN_PLUGIN_CLIENT_CONNECT or OPENVPN_PLUGIN_CLIENT_CONNECT_V2 calls. This option provides a possibility to replace the clients password with an authentication token during the lifetime of the OpenVPN client.

Whenever the connection is renegotiated and the --auth-user-pass-verify script or --plugin making use of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY hook is triggered, it will pass over this token as the password instead of the password the user provided. The authentication token can only be reset by a full reconnect where the server can push new options to the client. The password the user entered is never preserved once an authentication token has been set. If the OpenVPN server side rejects the authentication token then the client will receive an AUTH_FAILED and disconnect.

The purpose of this is to enable two factor authentication methods, such as HOTP or TOTP, to be used without needing to retrieve a new OTP code each time the connection is renegotiated. Another use case is to cache authentication data on the client without needing to have the users password cached in memory during the life time of the session.

To make use of this feature, the --client-connect script or --plugin needs to put

push "auth-token UNIQUE_TOKEN_VALUE"

into the file/buffer for dynamic configuration data. This will then make the OpenVPN server to push this value to the client, which replaces the local password with the UNIQUE_TOKEN_VALUE.

Newer clients (2.4.7+) will fall back to the original password method after a failed auth. Older clients will keep using the token value and react according to --auth-retry

--auth-token-user base64username
 

Companion option to --auth-token. This options allows one to override the username used by the client when reauthenticating with the auth-token. It also allows one to use --auth-token in setups that normally do not use username and password.

The username has to be base64 encoded.

--auth-user-pass
 

Authenticate with server using username/password.

Valid syntaxes:

auth-user-pass
auth-user-pass up

If up is present, it must be a file containing username/password on 2 lines. If the password line is missing, OpenVPN will prompt for one.

If up is omitted, username/password will be prompted from the console.

This option can also be inlined

<auth-user-pass>
username
[password]
</auth-user-pass>

where password is optional, and will be prompted from the console if missing.

The server configuration must specify an --auth-user-pass-verify script to verify the username/password provided by the client.

--auth-retry type
 

Controls how OpenVPN responds to username/password verification errors such as the client-side response to an AUTH_FAILED message from the server or verification failure of the private key password.

Normally used to prevent auth errors from being fatal on the client side, and to permit username/password requeries in case of error.

An AUTH_FAILED message is generated by the server if the client fails --auth-user-pass authentication, or if the server-side --client-connect script returns an error status when the client tries to connect.

type can be one of:

none
Client will exit with a fatal error (this is the default).
nointeract
Client will retry the connection without requerying for an --auth-user-pass username/password. Use this option for unattended clients.
interact
Client will requery for an --auth-user-pass username/password and/or private key password before attempting a reconnection.

Note that while this option cannot be pushed, it can be controlled from the management interface.

--client

A helper directive designed to simplify the configuration of OpenVPN's client mode. This directive is equivalent to:

pull
tls-client
--client-nat args
 

This pushable client option sets up a stateless one-to-one NAT rule on packet addresses (not ports), and is useful in cases where routes or ifconfig settings pushed to the client would create an IP numbering conflict.

Examples:

client-nat snat 192.168.0.0/255.255.0.0
client-nat dnat 10.64.0.0/255.255.0.0

network/netmask (for example 192.168.0.0/255.255.0.0) defines the local view of a resource from the client perspective, while alias/netmask (for example 10.64.0.0/255.255.0.0) defines the remote view from the server perspective.

Use snat (source NAT) for resources owned by the client and dnat (destination NAT) for remote resources.

Set --verb 6 for debugging info showing the transformation of src/dest addresses in packets.

--connect-retry args
 

Wait n seconds between connection attempts (default 1). Repeated reconnection attempts are slowed down after 5 retries per remote by doubling the wait time after each unsuccessful attempt.

Valid syntaxes:

connect retry n
connect retry n max

If the optional argument max is specified, the maximum wait time in seconds gets capped at that value (default 300).

--connect-retry-max n
 n specifies the number of times each --remote or <connection> entry is tried. Specifying n as 1 would try each entry exactly once. A successful connection resets the counter. (default unlimited).
--connect-timeout n
 See --server-poll-timeout.
--dns args

Client DNS configuration to be used with the connection.

Valid syntaxes:

dns search-domains domain [domain ...]
dns server n address addr[:port] [addr[:port] ...]
dns server n resolve-domains domain [domain ...]
dns server n dnssec yes|optional|no
dns server n transport DoH|DoT|plain
dns server n sni server-name

The --dns search-domains directive takes one or more domain names to be added as DNS domain suffixes. If it is repeated multiple times within a configuration the domains are appended, thus e.g. domain names pushed by a server will amend locally defined ones.

The --dns server directive is used to configure DNS server n. The server id n must be a value between -128 and 127. For pushed DNS server options it must be between 0 and 127. The server id is used to group options and also for ordering the list of configured DNS servers; lower numbers come first. DNS servers being pushed to a client replace already configured DNS servers with the same server id.

The address option configures the IPv4 and / or IPv6 address(es) of the DNS server. Up to eight addresses can be specified per DNS server. Optionally a port can be appended after a colon. IPv6 addresses need to be enclosed in brackets if a port is appended.

The resolve-domains option takes one or more DNS domains used to define a split-dns or dns-routing setup, where only the given domains are resolved by the server. Systems which do not support fine grained DNS domain configuration will ignore this setting.

The dnssec option is used to configure validation of DNSSEC records. While the exact semantics may differ for resolvers on different systems, yes likely makes validation mandatory, no disables it, and optional uses it opportunistically.

The transport option enables DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) for a DNS server. The sni option can be used with them to specify the server-name for TLS server name indication.

Each server has to have at least one address configured for a configuration to be valid. All the other options can be omitted.

Note that not all options may be supported on all platforms. As soon support for different systems is implemented, information will be added here how unsupported options are treated.

The --dns option will eventually obsolete the --dhcp-option directive. Until then it will replace configuration at the places --dhcp-option puts it, so that --dns overrides --dhcp-option. Thus, --dns can be used today to migrate from --dhcp-option.

--explicit-exit-notify n
 

In UDP client mode or point-to-point mode, send server/peer an exit notification if tunnel is restarted or OpenVPN process is exited. In client mode, on exit/restart, this option will tell the server to immediately close its client instance object rather than waiting for a timeout.

If both server and client support sending this message using the control channel, the message will be sent as control-channel message. Otherwise the message is sent as data-channel message, which will be ignored by data-channel offloaded peers.

The n parameter (default 1 if not present) controls the maximum number of attempts that the client will try to resend the exit notification message if messages are sent in data-channel mode.

In UDP server mode, send RESTART control channel command to connected clients. The n parameter (default 1 if not present) controls client behavior. With n = 1 client will attempt to reconnect to the same server, with n = 2 client will advance to the next server.

OpenVPN will not send any exit notifications unless this option is enabled.

--inactive args
 

Causes OpenVPN to exit after n seconds of inactivity on the TUN/TAP device. The time length of inactivity is measured since the last incoming or outgoing tunnel packet. The default value is 0 seconds, which disables this feature.

Valid syntaxes:

inactive n
inactive n bytes

If the optional bytes parameter is included, exit if less than bytes of combined in/out traffic are produced on the tun/tap device in n seconds.

In any case, OpenVPN's internal ping packets (which are just keepalives) and TLS control packets are not considered "activity", nor are they counted as traffic, as they are used internally by OpenVPN and are not an indication of actual user activity.

--proto-force p
 

When iterating through connection profiles, only consider profiles using protocol p (tcp | udp).

Note that this specifically only filters by the transport layer protocol, i.e. UDP or TCP. This does not affect whether IPv4 or IPv6 is used as IP protocol.

For implementation reasons the option accepts the 4 and 6 suffixes when specifying the protocol (i.e. udp4 / udp6 / tcp4 / tcp6). However, these behave the same as without the suffix and should be avoided to prevent confusion.

--pull

This option must be used on a client which is connecting to a multi-client server. It indicates to OpenVPN that it should accept options pushed by the server, provided they are part of the legal set of pushable options (note that the --pull option is implied by --client ).

In particular, --pull allows the server to push routes to the client, so you should not use --pull or --client in situations where you don't trust the server to have control over the client's routing table.

--pull-filter args
 

Filter options on the client pushed by the server to the client.

Valid syntaxes:

pull-filter accept text
pull-filter ignore text
pull-filter reject text

Filter options received from the server if the option starts with text. The action flag accept allows the option, ignore removes it and reject flags an error and triggers a SIGUSR1 restart. The filters may be specified multiple times, and each filter is applied in the order it is specified. The filtering of each option stops as soon as a match is found. Unmatched options are accepted by default.

Prefix comparison is used to match text against the received option so that

pull-filter ignore "route"

would remove all pushed options starting with route which would include, for example, route-gateway. Enclose text in quotes to embed spaces.

pull-filter accept "route 192.168.1."
pull-filter ignore "route "

would remove all routes that do not start with 192.168.1.

Note that reject may result in a repeated cycle of failure and reconnect, unless multiple remotes are specified and connection to the next remote succeeds. To silently ignore an option pushed by the server, use ignore.

--push-peer-info
 

Push additional information about the client to server. The following data is always pushed to the server:

IV_VER=<version>
The client OpenVPN version
IV_PLAT=[linux|solaris|openbsd|mac|netbsd|freebsd|win]
The client OS platform
IV_PROTO

Details about protocol extensions that the peer supports. The variable is a bitfield and the bits are defined as follows:

  • bit 0: Reserved, should always be zero
  • bit 1: The peer supports peer-id floating mechanism
  • bit 2: The client expects a push-reply and the server may send this reply without waiting for a push-request first.
  • bit 3: The client is capable of doing key derivation using RFC5705 key material exporter.
  • bit 4: The client is capable of accepting additional arguments to the AUTH_PENDING message.
  • bit 5: The client supports doing feature negotiation in P2P mode
  • bit 6: The client is capable of parsing and receiving the --dns pushed option
  • bit 7: The client is capable of sending exit notification via control channel using EXIT message. Also, the client is accepting the protocol-flags pushed option for the EKM capability
  • bit 8: The client is capable of accepting AUTH_FAILED,TEMP messages
  • bit 9: The client is capable of dynamic tls-crypt
IV_NCP=2
Negotiable ciphers, client supports --cipher pushed by the server, a value of 2 or greater indicates client supports AES-GCM-128 and AES-GCM-256. IV_NCP is deprecated in favor of IV_CIPHERS.
IV_CIPHERS=<data-ciphers>
The client announces the list of supported ciphers configured with the --data-ciphers option to the server.
IV_MTU=<max_mtu>
The client announces the support of pushable MTU and the maximum MTU it is willing to accept.
IV_GUI_VER=<gui_id> <version>
The UI version of a UI if one is running, for example de.blinkt.openvpn 0.5.47 for the Android app. This may be set by the client UI/GUI using --setenv.
IV_SSO=[crtext,][openurl,][proxy_url]
Additional authentication methods supported by the client. This may be set by the client UI/GUI using --setenv.

The following flags depend on which compression formats are compiled in and whether compression is allowed by options. See Protocol options for more details.

IV_LZO=1
If client supports LZO compression.
IV_LZO_STUB=1
If client was built with LZO stub capability. This is only sent if IV_LZO=1 is not sent. This means the client can talk to a server configured with --comp-lzo no.
IV_LZ4=1 and IV_LZ4v2=1
If the client supports LZ4 compression.
IV_COMP_STUB=1 and IV_COMP_STUBv2=1
If the client supports stub compression. This means the client can talk to a server configured with --compress.

When --push-peer-info is enabled the additional information consists of the following data:

IV_HWADDR=<string>
This is intended to be a unique and persistent ID of the client. The string value can be any readable ASCII string up to 64 bytes. OpenVPN 2.x and some other implementations use the MAC address of the client's interface used to reach the default gateway. If this string is generated by the client, it should be consistent and preserved across independent sessions and preferably re-installations and upgrades.
IV_SSL=<version string>
The ssl library version used by the client, e.g. OpenSSL 1.0.2f 28 Jan 2016.
IV_PLAT_VER=x.y
The version of the operating system, e.g. 6.1 for Windows 7. This may be set by the client UI/GUI using --setenv. On Windows systems it is automatically determined by openvpn itself.
UV_<name>=<value>
Client environment variables whose names start with UV_
--remote args

Remote host name or IP address, port and protocol.

Valid syntaxes:

remote host
remote host port
remote host port proto

The port and proto arguments are optional. The OpenVPN client will try to connect to a server at host:port. The proto argument indicates the protocol to use when connecting with the remote, and may be tcp or udp. To enforce IPv4 or IPv6 connections add a 4 or 6 suffix; like udp4 / udp6 / tcp4 / tcp6.

On the client, multiple --remote options may be specified for redundancy, each referring to a different OpenVPN server, in the order specified by the list of --remote options. Specifying multiple --remote options for this purpose is a special case of the more general connection-profile feature. See the <connection> documentation below.

The client will move on to the next host in the list, in the event of connection failure. Note that at any given time, the OpenVPN client will at most be connected to one server.

Examples:

remote server1.example.net
remote server1.example.net 1194
remote server2.example.net 1194 tcp
Note:

Since UDP is connectionless, connection failure is defined by the --ping and --ping-restart options.

Also, if you use multiple --remote options, AND you are dropping root privileges on the client with --user and/or --group AND the client is running a non-Windows OS, if the client needs to switch to a different server, and that server pushes back different TUN/TAP or route settings, the client may lack the necessary privileges to close and reopen the TUN/TAP interface. This could cause the client to exit with a fatal error.

If --remote is unspecified, OpenVPN will listen for packets from any IP address, but will not act on those packets unless they pass all authentication tests. This requirement for authentication is binding on all potential peers, even those from known and supposedly trusted IP addresses (it is very easy to forge a source IP address on a UDP packet).

When used in TCP mode, --remote will act as a filter, rejecting connections from any host which does not match host.

If host is a DNS name which resolves to multiple IP addresses, OpenVPN will try them in the order that the system getaddrinfo() presents them, so priorization and DNS randomization is done by the system library. Unless an IP version is forced by the protocol specification (4/6 suffix), OpenVPN will try both IPv4 and IPv6 addresses, in the order getaddrinfo() returns them.

--remote-random
 When multiple --remote address/ports are specified, or if connection profiles are being used, initially randomize the order of the list as a kind of basic load-balancing measure.
--remote-random-hostname
 Prepend a random string (6 bytes, 12 hex characters) to hostname to prevent DNS caching. For example, "foo.bar.gov" would be modified to "<random-chars>.foo.bar.gov".
--resolv-retry n
 

If hostname resolve fails for --remote, retry resolve for n seconds before failing.

Set n to infinite to retry indefinitely.

By default, --resolv-retry infinite is enabled. You can disable by setting n=0.

--single-session
 

After initially connecting to a remote peer, disallow any new connections. Using this option means that a remote peer cannot connect, disconnect, and then reconnect.

If the daemon is reset by a signal or --ping-restart, it will allow one new connection.

--single-session can be used with --ping-exit or --inactive to create a single dynamic session that will exit when finished.

--server-poll-timeout n
 When connecting to a remote server do not wait for more than n seconds for a response before trying the next server. The default value is 120. This timeout includes proxy and TCP connect timeouts.
--static-challenge args
 

Enable static challenge/response protocol

Valid syntax:

static-challenge text echo

The text challenge text is presented to the user which describes what information is requested. The echo flag indicates if the user's input should be echoed on the screen. Valid echo values are 0 or 1.

See management-notes.txt in the OpenVPN distribution for a description of the OpenVPN challenge/response protocol.

--http-proxy args
 

Connect to remote host through an HTTP proxy. This requires at least an address server and port argument. If HTTP Proxy-Authenticate is required, a file name to an authfile file containing a username and password on 2 lines can be given, or stdin to prompt from console. Its content can also be specified in the config file with the --http-proxy-user-pass option (See INLINE FILE SUPPORT).

The last optional argument is an auth-method which should be one of none, basic, or ntlm.

HTTP Digest authentication is supported as well, but only via the auto or auto-nct flags (below). This must replace the authfile argument.

The auto flag causes OpenVPN to automatically determine the auth-method and query stdin or the management interface for username/password credentials, if required. This flag exists on OpenVPN 2.1 or higher.

The auto-nct flag (no clear-text auth) instructs OpenVPN to automatically determine the authentication method, but to reject weak authentication protocols such as HTTP Basic Authentication.

Examples:

# no authentication
http-proxy proxy.example.net 3128
# basic authentication, load credentials from file
http-proxy proxy.example.net 3128 authfile.txt
# basic authentication, ask user for credentials
http-proxy proxy.example.net 3128 stdin
# NTLM authentication, load credentials from file
http-proxy proxy.example.net 3128 authfile.txt ntlm2
# determine which authentication is required, ask user for credentials
http-proxy proxy.example.net 3128 auto
# determine which authentication is required, but reject basic
http-proxy proxy.example.net 3128 auto-nct
# determine which authentication is required, but set credentials
http-proxy proxy.example.net 3128 auto
http-proxy-user-pass authfile.txt
# basic authentication, specify credentials inline
http-proxy proxy.example.net 3128 "" basic
<http-proxy-user-pass>
username
password
</http-proxy-user-pass>
--http-proxy-user-pass userpass
 

Overwrite the username/password information for --http-proxy. If specified as an inline option (see INLINE FILE SUPPORT), it will be interpreted as username/password separated by a newline. When specified on the command line it is interpreted as a filename same as the third argument to --http-proxy.

Example:

<http-proxy-user-pass>
username
password
</http-proxy-user-pass>
--http-proxy-option args
 

Set extended HTTP proxy options. Requires an option type as argument and an optional parameter to the type. Repeat to set multiple options.

VERSION version
Set HTTP version number to version (default 1.0).
AGENT user-agent
Set HTTP "User-Agent" string to user-agent.
CUSTOM-HEADER name content
Adds the custom Header with name as name and content as the content of the custom HTTP header.

Examples:

http-proxy-option VERSION 1.1
http-proxy-option AGENT OpenVPN/2.4
http-proxy-option X-Proxy-Flag some-flags
--socks-proxy args
 Connect to remote host through a Socks5 proxy. A required server argument is needed. Optionally a port (default 1080) and authfile can be given. The authfile is a file containing a username and password on 2 lines, or stdin can be used to prompt from console.

Server Options

Starting with OpenVPN 2.0, a multi-client TCP/UDP server mode is supported, and can be enabled with the --mode server option. In server mode, OpenVPN will listen on a single port for incoming client connections. All client connections will be routed through a single tun or tap interface. This mode is designed for scalability and should be able to support hundreds or even thousands of clients on sufficiently fast hardware. SSL/TLS authentication must be used in this mode.

--auth-gen-token args
 

Returns an authentication token to successfully authenticated clients.

Valid syntax:

auth-gen-token [lifetime] [renewal-time] [external-auth]

After successful user/password authentication, the OpenVPN server will with this option generate a temporary authentication token and push that to the client. On the following renegotiations, the OpenVPN client will pass this token instead of the users password. On the server side the server will do the token authentication internally and it will NOT do any additional authentications against configured external user/password authentication mechanisms.

The tokens implemented by this mechanism include an initial timestamp and a renew timestamp and are secured by HMAC.

The lifetime argument defines how long the generated token is valid. The lifetime is defined in seconds. If lifetime is not set or it is set to 0, the token will never expire.

If renewal-time is not set it defaults to reneg-sec.

The token will expire either after the configured lifetime of the token is reached or after not being renewed for more than 2 * renewal-time seconds. Clients will be sent renewed tokens on every TLS renegotiation. If renewal-time is lower than reneg-sec the server will push an updated temporary authentication token every reneweal-time seconds. This is done to invalidate a token if a client is disconnected for a sufficiently long time, while at the same time permitting much longer token lifetimes for active clients.

This feature is useful for environments which are configured to use One Time Passwords (OTP) as part of the user/password authentications and that authentication mechanism does not implement any auth-token support.

When the external-auth keyword is present the normal authentication method will always be called even if auth-token succeeds. Normally other authentications method are skipped if auth-token verification succeeds or fails.

This option postpones this decision to the external authentication methods and checks the validity of the account and do other checks.

In this mode the environment will have a session_id variable that holds the session id from auth-gen-token. Also an environment variable session_state is present. This variable indicates whether the auth-token has succeeded or not. It can have the following values:

Initial
No token from client.
Authenticated
Token is valid and not expired.
Expired
Token is valid but has expired.
Invalid
Token is invalid (failed HMAC or wrong length)
AuthenticatedEmptyUser / ExpiredEmptyUser
The token is not valid with the username sent from the client but would be valid (or expired) if we assume an empty username was used instead. These two cases are a workaround for behaviour in OpenVPN 3. If this workaround is not needed these two cases should be handled in the same way as Invalid.

Warning: Use this feature only if you want your authentication method called on every verification. Since the external authentication is called it needs to also indicate a success or failure of the authentication. It is strongly recommended to return an authentication failure in the case of the Invalid/Expired auth-token with the external-auth option unless the client could authenticate in another acceptable way (e.g. client certificate), otherwise returning success will lead to authentication bypass (as does returning success on a wrong password from a script).

--auth-gen-token-secret file
 Specifies a file that holds a secret for the HMAC used in --auth-gen-token If file is not present OpenVPN will generate a random secret on startup. This file should be used if auth-token should validate after restarting a server or if client should be able to roam between multiple OpenVPN servers with their auth-token.
--auth-user-pass-optional
 Allow connections by clients that do not specify a username/password. Normally, when --auth-user-pass-verify or --management-client-auth are specified (or an authentication plugin module), the OpenVPN server daemon will require connecting clients to specify a username and password. This option makes the submission of a username/password by clients optional, passing the responsibility to the user-defined authentication module/script to accept or deny the client based on other factors (such as the setting of X509 certificate fields). When this option is used, and a connecting client does not submit a username/password, the user-defined authentication module/script will see the username and password as being set to empty strings (""). The authentication module/script MUST have logic to detect this condition and respond accordingly.
--ccd-exclusive
 Require, as a condition of authentication, that a connecting client has a --client-config-dir file.
--client-config-dir dir
 

Specify a directory dir for custom client config files. After a connecting client has been authenticated, OpenVPN will look in this directory for a file having the same name as the client's X509 common name. If a matching file exists, it will be opened and parsed for client-specific configuration options. If no matching file is found, OpenVPN will instead try to open and parse a default file called "DEFAULT", which may be provided but is not required. Note that the configuration files must be readable by the OpenVPN process after it has dropped it's root privileges.

This file can specify a fixed IP address for a given client using --ifconfig-push, as well as fixed subnets owned by the client using --iroute.

One of the useful properties of this option is that it allows client configuration files to be conveniently created, edited, or removed while the server is live, without needing to restart the server.

The following options are legal in a client-specific context: --push, --push-reset, --push-remove, --iroute, --ifconfig-push, --vlan-pvid and --config.

--client-to-client
 

Because the OpenVPN server mode handles multiple clients through a single tun or tap interface, it is effectively a router. The --client-to-client flag tells OpenVPN to internally route client-to-client traffic rather than pushing all client-originating traffic to the TUN/TAP interface.

When this option is used, each client will "see" the other clients which are currently connected. Otherwise, each client will only see the server. Don't use this option if you want to firewall tunnel traffic using custom, per-client rules.

Please note that when using data channel offload this option has no effect. Packets are always sent to the tunnel interface and then routed based on the system routing table.

--disable

Disable a particular client (based on the common name) from connecting. Don't use this option to disable a client due to key or password compromise. Use a CRL (certificate revocation list) instead (see the --crl-verify option).

This option must be associated with a specific client instance, which means that it must be specified either in a client instance config file using --client-config-dir or dynamically generated using a --client-connect script.

--connect-freq args
 

Allow a maximum of n new connections per sec seconds from clients.

Valid syntax:

connect-freq n sec

This is designed to contain DoS attacks which flood the server with connection requests using certificates which will ultimately fail to authenticate.

This limit applies after --connect-freq-initial and only applies to client that have completed the three-way handshake or client that use --tls-crypt-v2 without cookie support (allow-noncookie argument to --tls-crypt-v2).

This is an imperfect solution however, because in a real DoS scenario, legitimate connections might also be refused.

For the best protection against DoS attacks in server mode, use --proto udp and either --tls-auth or --tls-crypt.

--connect-freq-initial args
 

(UDP only) Allow a maximum of n initial connection packet responses per sec seconds from the OpenVPN server to clients.

Valid syntax:

connect-freq-initial n sec

OpenVPN starting at 2.6 is very efficient in responding to initial connection packets. When not limiting the initial responses an OpenVPN daemon can be abused in reflection attacks. This option is designed to limit the rate OpenVPN will respond to initial attacks.

Connection attempts that complete the initial three-way handshake will not be counted against the limit. The default is to allow 100 initial connection per 10s.

--duplicate-cn Allow multiple clients with the same common name to concurrently connect. In the absence of this option, OpenVPN will disconnect a client instance upon connection of a new client having the same common name.
--ifconfig-pool args
 

Set aside a pool of subnets to be dynamically allocated to connecting clients, similar to a DHCP server.

Valid syntax:

ifconfig-pool start-IP end-IP [netmask]

For tun-style tunnels, each client will be given a /30 subnet (for interoperability with Windows clients). For tap-style tunnels, individual addresses will be allocated, and the optional netmask parameter will also be pushed to clients.

--ifconfig-ipv6-pool args
 

Specify an IPv6 address pool for dynamic assignment to clients.

Valid args:

ifconfig-ipv6-pool ipv6addr/bits

The pool starts at ipv6addr and matches the offset determined from the start of the IPv4 pool. If the host part of the given IPv6 address is 0, the pool starts at ipv6addr +1.

--ifconfig-pool-persist args
 

Persist/unpersist ifconfig-pool data to file, at seconds intervals (default 600), as well as on program startup and shutdown.

Valid syntax:

ifconfig-pool-persist file [seconds]

The goal of this option is to provide a long-term association between clients (denoted by their common name) and the virtual IP address assigned to them from the ifconfig-pool. Maintaining a long-term association is good for clients because it allows them to effectively use the --persist-tun option.

file is a comma-delimited ASCII file, formatted as <Common-Name>,<IP-address>.

If seconds = 0, file will be treated as read-only. This is useful if you would like to treat file as a configuration file.

Note that the entries in this file are treated by OpenVPN as suggestions only, based on past associations between a common name and IP address. They do not guarantee that the given common name will always receive the given IP address. If you want guaranteed assignment, use --ifconfig-push

--ifconfig-push args
 

Push virtual IP endpoints for client tunnel, overriding the --ifconfig-pool dynamic allocation.

Valid syntax:

ifconfig-push local remote-netmask [alias]

The parameters local and remote-netmask are set according to the --ifconfig directive which you want to execute on the client machine to configure the remote end of the tunnel. Note that the parameters local and remote-netmask are from the perspective of the client, not the server. They may be DNS names rather than IP addresses, in which case they will be resolved on the server at the time of client connection.

The optional alias parameter may be used in cases where NAT causes the client view of its local endpoint to differ from the server view. In this case local/remote-netmask will refer to the server view while alias/remote-netmask will refer to the client view.

This option must be associated with a specific client instance, which means that it must be specified either in a client instance config file using --client-config-dir or dynamically generated using a --client-connect script.

Remember also to include a --route directive in the main OpenVPN config file which encloses local, so that the kernel will know to route it to the server's TUN/TAP interface.

OpenVPN's internal client IP address selection algorithm works as follows:

  1. Use --client-connect script generated file for static IP (first choice).
  2. Use --client-config-dir file for static IP (next choice).
  3. Use --ifconfig-pool allocation for dynamic IP (last choice).
--ifconfig-ipv6-push args
 

for --client-config-dir per-client static IPv6 interface configuration, see --client-config-dir and --ifconfig-push for more details.

Valid syntax:

ifconfig-ipv6-push ipv6addr/bits ipv6remote
--multihome

Configure a multi-homed UDP server. This option needs to be used when a server has more than one IP address (e.g. multiple interfaces, or secondary IP addresses), and is not using --local to force binding to one specific address only. This option will add some extra lookups to the packet path to ensure that the UDP reply packets are always sent from the address that the client is talking to. This is not supported on all platforms, and it adds more processing, so it's not enabled by default.

Notes:
  • This option is only relevant for UDP servers.
  • If you do an IPv6+IPv4 dual-stack bind on a Linux machine with multiple IPv4 address, connections to IPv4 addresses will not work right on kernels before 3.15, due to missing kernel support for the IPv4-mapped case (some distributions have ported this to earlier kernel versions, though).
--iroute args

Generate an internal route to a specific client. The netmask parameter, if omitted, defaults to 255.255.255.255.

Valid syntax:

iroute network [netmask]

This directive can be used to route a fixed subnet from the server to a particular client, regardless of where the client is connecting from. Remember that you must also add the route to the system routing table as well (such as by using the --route directive). The reason why two routes are needed is that the --route directive routes the packet from the kernel to OpenVPN. Once in OpenVPN, the --iroute directive routes to the specific client.

However, when using DCO, the --iroute directive is usually enough for DCO to fully configure the routing table. The extra --route directive is required only if the expected behaviour is to route the traffic for a specific network to the VPN interface also when the responsible client is not connected (traffic will then be dropped).

This option must be specified either in a client instance config file using --client-config-dir or dynamically generated using a --client-connect script.

The --iroute directive also has an important interaction with --push "route ...". --iroute essentially defines a subnet which is owned by a particular client (we will call this client A). If you would like other clients to be able to reach A's subnet, you can use --push "route ..." together with --client-to-client to effect this. In order for all clients to see A's subnet, OpenVPN must push this route to all clients EXCEPT for A, since the subnet is already owned by A. OpenVPN accomplishes this by not not pushing a route to a client if it matches one of the client's iroutes.

--iroute-ipv6 args
 

for --client-config-dir per-client static IPv6 route configuration, see --iroute for more details how to setup and use this, and how --iroute and --route interact.

Valid syntax:

iroute-ipv6 ipv6addr/bits
--max-clients n
 Limit server to a maximum of n concurrent clients.
--max-routes-per-client n
 

Allow a maximum of n internal routes per client (default 256). This is designed to help contain DoS attacks where an authenticated client floods the server with packets appearing to come from many unique MAC addresses, forcing the server to deplete virtual memory as its internal routing table expands. This directive can be used in a --client-config-dir file or auto-generated by a --client-connect script to override the global value for a particular client.

Note that this directive affects OpenVPN's internal routing table, not the kernel routing table.

--opt-verify

DEPRECATED Clients that connect with options that are incompatible with those of the server will be disconnected.

Options that will be compared for compatibility include dev-type, link-mtu, tun-mtu, proto, ifconfig, comp-lzo, fragment, keydir, cipher, auth, keysize, secret, no-replay, tls-auth, key-method, tls-server and tls-client.

This option requires that --disable-occ NOT be used.

--port-share args
 

Share OpenVPN TCP with another service

Valid syntax:

port-share host port [dir]

When run in TCP server mode, share the OpenVPN port with another application, such as an HTTPS server. If OpenVPN senses a connection to its port which is using a non-OpenVPN protocol, it will proxy the connection to the server at host:port. Currently only designed to work with HTTP/HTTPS, though it would be theoretically possible to extend to other protocols such as ssh.

dir specifies an optional directory where a temporary file with name N containing content C will be dynamically generated for each proxy connection, where N is the source IP:port of the client connection and C is the source IP:port of the connection to the proxy receiver. This directory can be used as a dictionary by the proxy receiver to determine the origin of the connection. Each generated file will be automatically deleted when the proxied connection is torn down.

Not implemented on Windows.

--push option

Push a config file option back to the client for remote execution. Note that option must be enclosed in double quotes (""). The client must specify --pull in its config file. The set of options which can be pushed is limited by both feasibility and security. Some options such as those which would execute scripts are banned, since they would effectively allow a compromised server to execute arbitrary code on the client. Other options such as TLS or MTU parameters cannot be pushed because the client needs to know them before the connection to the server can be initiated.

This is a partial list of options which can currently be pushed: --route, --route-gateway, --route-delay, --redirect-gateway, --ip-win32, --dhcp-option, --dns, --inactive, --ping, --ping-exit, --ping-restart, --setenv, --auth-token, --persist-key, --persist-tun, --echo, --comp-lzo, --socket-flags, --sndbuf, --rcvbuf, --session-timeout

--push-remove opt
 

Selectively remove all --push options matching "opt" from the option list for a client. opt is matched as a substring against the whole option string to-be-pushed to the client, so --push-remove route would remove all --push route ... and --push route-ipv6 ... statements, while --push-remove "route-ipv6 2001:" would only remove IPv6 routes for 2001:... networks.

--push-remove can only be used in a client-specific context, like in a --client-config-dir file, or --client-connect script or plugin -- similar to --push-reset, just more selective.

NOTE: to change an option, --push-remove can be used to first remove the old value, and then add a new --push option with the new value.

NOTE 2: due to implementation details, 'ifconfig' and 'ifconfig-ipv6' can only be removed with an exact match on the option ( push-remove ifconfig), no substring matching and no matching on the IPv4/IPv6 address argument is possible.

--push-reset

Don't inherit the global push list for a specific client instance. Specify this option in a client-specific context such as with a --client-config-dir configuration file. This option will ignore --push options at the global config file level.

NOTE: --push-reset is very thorough: it will remove almost all options from the list of to-be-pushed options. In many cases, some of these options will need to be re-configured afterwards - specifically, --topology subnet and --route-gateway will get lost and this will break client configs in many cases. Thus, for most purposes, --push-remove is better suited to selectively remove push options for individual clients.

--server args

A helper directive designed to simplify the configuration of OpenVPN's server mode. This directive will set up an OpenVPN server which will allocate addresses to clients out of the given network/netmask. The server itself will take the .1 address of the given network for use as the server-side endpoint of the local TUN/TAP interface. If the optional nopool flag is given, no dynamic IP address pool will prepared for VPN clients.

Valid syntax:

server network netmask [nopool]

For example, --server 10.8.0.0 255.255.255.0 expands as follows:

mode server
tls-server
push "topology [topology]"

if dev tun AND (topology == net30 OR topology == p2p):
  ifconfig 10.8.0.1 10.8.0.2
  if !nopool:
    ifconfig-pool 10.8.0.4 10.8.0.251
  route 10.8.0.0 255.255.255.0
  if client-to-client:
    push "route 10.8.0.0 255.255.255.0"
  else if topology == net30:
    push "route 10.8.0.1"

if dev tap OR (dev tun AND topology == subnet):
  ifconfig 10.8.0.1 255.255.255.0
  if !nopool:
    ifconfig-pool 10.8.0.2 10.8.0.253 255.255.255.0
  push "route-gateway 10.8.0.1"
  if route-gateway unset:
    route-gateway 10.8.0.2

Don't use --server if you are ethernet bridging. Use --server-bridge instead.

--server-bridge args
 

A helper directive similar to --server which is designed to simplify the configuration of OpenVPN's server mode in ethernet bridging configurations.

Valid syntaxes:

server-bridge gateway netmask pool-start-IP pool-end-IP
server-bridge [nogw]

If --server-bridge is used without any parameters, it will enable a DHCP-proxy mode, where connecting OpenVPN clients will receive an IP address for their TAP adapter from the DHCP server running on the OpenVPN server-side LAN. Note that only clients that support the binding of a DHCP client with the TAP adapter (such as Windows) can support this mode. The optional nogw flag (advanced) indicates that gateway information should not be pushed to the client.

To configure ethernet bridging, you must first use your OS's bridging capability to bridge the TAP interface with the ethernet NIC interface. For example, on Linux this is done with the brctl tool, and with Windows XP it is done in the Network Connections Panel by selecting the ethernet and TAP adapters and right-clicking on "Bridge Connections".

Next you you must manually set the IP/netmask on the bridge interface. The gateway and netmask parameters to --server-bridge can be set to either the IP/netmask of the bridge interface, or the IP/netmask of the default gateway/router on the bridged subnet.

Finally, set aside a IP range in the bridged subnet, denoted by pool-start-IP and pool-end-IP, for OpenVPN to allocate to connecting clients.

For example, server-bridge 10.8.0.4 255.255.255.0 10.8.0.128 10.8.0.254 expands as follows:

mode server
tls-server

ifconfig-pool 10.8.0.128 10.8.0.254 255.255.255.0
push "route-gateway 10.8.0.4"

In another example, --server-bridge (without parameters) expands as follows:

mode server
tls-server

push "route-gateway dhcp"

Or --server-bridge nogw expands as follows:

mode server
tls-server
--server-ipv6 args
 

Convenience-function to enable a number of IPv6 related options at once, namely --ifconfig-ipv6, --ifconfig-ipv6-pool and --push tun-ipv6.

Valid syntax:

server-ipv6 ipv6addr/bits

Pushing of the --tun-ipv6 directive is done for older clients which require an explicit --tun-ipv6 in their configuration.

--stale-routes-check args
 

Remove routes which haven't had activity for n seconds (i.e. the ageing time). This check is run every t seconds (i.e. check interval).

Valid syntax:

stale-routes-check n [t]

If t is not present it defaults to n.

This option helps to keep the dynamic routing table small. See also --max-routes-per-client

--username-as-common-name
 

Use the authenticated username as the common-name, rather than the common-name from the client certificate. Requires that some form of --auth-user-pass verification is in effect. As the replacement happens after --auth-user-pass verification, the verification script or plugin will still receive the common-name from the certificate.

The common_name environment variable passed to scripts and plugins invoked after authentication (e.g, client-connect script) and file names parsed in client-config directory will match the username.

--verify-client-cert mode
 

Specify whether the client is required to supply a valid certificate.

Possible mode options are:

none

A client certificate is not required. the client needs to authenticate using username/password only. Be aware that using this directive is less secure than requiring certificates from all clients.

If you use this directive, the entire responsibility of authentication will rest on your --auth-user-pass-verify script, so keep in mind that bugs in your script could potentially compromise the security of your VPN.

--verify-client-cert none is functionally equivalent to --client-cert-not-required.

optional

A client may present a certificate but it is not required to do so. When using this directive, you should also use a --auth-user-pass-verify script to ensure that clients are authenticated using a certificate, a username and password, or possibly even both.

Again, the entire responsibility of authentication will rest on your --auth-user-pass-verify script, so keep in mind that bugs in your script could potentially compromise the security of your VPN.

require
This is the default option. A client is required to present a certificate, otherwise VPN access is refused.

If you don't use this directive (or use --verify-client-cert require) but you also specify an --auth-user-pass-verify script, then OpenVPN will perform double authentication. The client certificate verification AND the --auth-user-pass-verify script will need to succeed in order for a client to be authenticated and accepted onto the VPN.

--vlan-tagging

Server-only option. Turns the OpenVPN server instance into a switch that understands VLAN-tagging, based on IEEE 802.1Q.

The server TAP device and each of the connecting clients is seen as a port of the switch. All client ports are in untagged mode and the server TAP device is VLAN-tagged, untagged or accepts both, depending on the --vlan-accept setting.

Ethernet frames with a prepended 802.1Q tag are called "tagged". If the VLAN Identifier (VID) field in such a tag is non-zero, the frame is called "VLAN-tagged". If the VID is zero, but the Priority Control Point (PCP) field is non-zero, the frame is called "prio-tagged". If there is no 802.1Q tag, the frame is "untagged".

Using the --vlan-pvid v option once per client (see --client-config-dir), each port can be associated with a certain VID. Packets can only be forwarded between ports having the same VID. Therefore, clients with differing VIDs are completely separated from one-another, even if --client-to-client is activated.

The packet filtering takes place in the OpenVPN server. Clients should not have any VLAN tagging configuration applied.

The --vlan-tagging option is off by default. While turned off, OpenVPN accepts any Ethernet frame and does not perform any special processing for VLAN-tagged packets.

This option can only be activated in --dev tap mode.

--vlan-accept args
 

Configure the VLAN tagging policy for the server TAP device.

Valid syntax:

vlan-accept  all|tagged|untagged

The following modes are available:

tagged
Admit only VLAN-tagged frames. Only VLAN-tagged packets are accepted, while untagged or priority-tagged packets are dropped when entering the server TAP device.
untagged
Admit only untagged and prio-tagged frames. VLAN-tagged packets are not accepted, while untagged or priority-tagged packets entering the server TAP device are tagged with the value configured for the global --vlan-pvid setting.
all (default)
Admit all frames. All packets are admitted and then treated like untagged or tagged mode respectively.
Note:
Some vendors refer to switch ports running in tagged mode as "trunk ports" and switch ports running in untagged mode as "access ports".

Packets forwarded from clients to the server are VLAN-tagged with the originating client's PVID, unless the VID matches the global --vlan-pvid, in which case the tag is removed.

If no PVID is configured for a given client (see --vlan-pvid) packets are tagged with 1 by default.

--vlan-pvid v

Specifies which VLAN identifier a "port" is associated with. Only valid when --vlan-tagging is specified.

In the client context, the setting specifies which VLAN ID a client is associated with. In the global context, the VLAN ID of the server TAP device is set. The latter only makes sense for --vlan-accept untagged and --vlan-accept all modes.

Valid values for v go from 1 through to 4094. The global value defaults to 1. If no --vlan-pvid is specified in the client context, the global value is inherited.

In some switch implementations, the PVID is also referred to as "Native VLAN".

Encryption Options

SSL Library information

--show-ciphers (Standalone) Show all cipher algorithms to use with the --cipher option.
--show-digests (Standalone) Show all message digest algorithms to use with the --auth option.
--show-tls

(Standalone) Show all TLS ciphers supported by the crypto library. OpenVPN uses TLS to secure the control channel, over which the keys that are used to protect the actual VPN traffic are exchanged. The TLS ciphers will be sorted from highest preference (most secure) to lowest.

Be aware that whether a cipher suite in this list can actually work depends on the specific setup of both peers (e.g. both peers must support the cipher, and an ECDSA cipher suite will not work if you are using an RSA certificate, etc.).

--show-engines (Standalone) Show currently available hardware-based crypto acceleration engines supported by the OpenSSL library.
--show-groups (Standalone) Show all available elliptic curves/groups to use with the --ecdh-curve and tls-groups options.

Generating key material

--genkey args

(Standalone) Generate a key to be used of the type keytype. if keyfile is left out or empty the key will be output on stdout. See the following sections for the different keytypes.

Valid syntax:

--genkey keytype keyfile

Valid keytype arguments are:

secret Standard OpenVPN shared secret keys

tls-crypt Alias for secret

tls-auth Alias for secret

auth-token Key used for --auth-gen-token-key

tls-crypt-v2-server TLS Crypt v2 server key

tls-crypt-v2-client TLS Crypt v2 client key

Examples:

$ openvpn --genkey secret shared.key
$ openvpn --genkey tls-crypt shared.key
$ openvpn --genkey tls-auth shared.key
$ openvpn --genkey tls-crypt-v2-server v2crypt-server.key
$ openvpn --tls-crypt-v2 v2crypt-server.key --genkey tls-crypt-v2-client v2crypt-client-1.key
  • Generating Shared Secret Keys Generate a shared secret, for use with the --secret, --tls-auth or --tls-crypt options.

    Syntax:

    $ openvpn --genkey secret|tls-crypt|tls-auth keyfile
    

    The key is saved in keyfile. All three variants (--secret, tls-crypt and tls-auth) generate the same type of key. The aliases are added for convenience.

    If using this for --secret, this file must be shared with the peer over a pre-existing secure channel such as scp(1).

  • Generating TLS Crypt v2 Server key Generate a --tls-crypt-v2 key to be used by an OpenVPN server. The key is stored in keyfile.

    Syntax:

    --genkey tls-crypt-v2-server keyfile
    
  • Generating TLS Crypt v2 Client key Generate a --tls-crypt-v2 key to be used by OpenVPN clients. The key is stored in keyfile.

    Syntax

    --genkey tls-crypt-v2-client keyfile [metadata]
    

    If supplied, include the supplied metadata in the wrapped client key. This metadata must be supplied in base64-encoded form. The metadata must be at most 733 bytes long (980 characters in base64, though note that 980 base64 characters can encode more than 733 bytes).

    If no metadata is supplied, OpenVPN will use a 64-bit unix timestamp representing the current time in UTC, encoded in network order, as metadata for the generated key.

    A tls-crypt-v2 client key is wrapped using a server key. To generate a client key, the user must therefore supply the server key using the --tls-crypt-v2 option.

    Servers can use --tls-crypt-v2-verify to specify a metadata verification command.

  • Generate Authentication Token key Generate a new secret that can be used with --auth-gen-token-secret

    Syntax:

    --genkey auth-token [keyfile]
    
    Note:

    This file should be kept secret to the server as anyone that has access to this file will be able to generate auth tokens that the OpenVPN server will accept as valid.

Data Channel Renegotiation

When running OpenVPN in client/server mode, the data channel will use a separate ephemeral encryption key which is rotated at regular intervals.

--reneg-bytes n
 

Renegotiate data channel key after n bytes sent or received (disabled by default with an exception, see below). OpenVPN allows the lifetime of a key to be expressed as a number of bytes encrypted/decrypted, a number of packets, or a number of seconds. A key renegotiation will be forced if any of these three criteria are met by either peer.

If using ciphers with cipher block sizes less than 128-bits, --reneg-bytes is set to 64MB by default, unless it is explicitly disabled by setting the value to 0, but this is HIGHLY DISCOURAGED as this is designed to add some protection against the SWEET32 attack vector. For more information see the --cipher option.

--reneg-pkts n Renegotiate data channel key after n packets sent and received (disabled by default).
--reneg-sec args
 

Renegotiate data channel key after at most max seconds (default 3600) and at least min seconds (default is 90% of max for servers, and equal to max for clients).

reneg-sec max [min]

The effective --reneg-sec value used is per session pseudo-uniform-randomized between min and max.

With the default value of 3600 this results in an effective per session value in the range of 3240 .. 3600 seconds for servers, or just 3600 for clients.

When using dual-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.

Also, keep in mind that this option can be used on both the client and server, and whichever uses the lower value will be the one to trigger the renegotiation. A common mistake is to set --reneg-sec to a higher value on either the client or server, while the other side of the connection is still using the default value of 3600 seconds, meaning that the renegotiation will still occur once per 3600 seconds. The solution is to increase --reneg-sec on both the client and server, or set it to 0 on one side of the connection (to disable), and to your chosen value on the other side.

TLS Mode Options

TLS mode is the most powerful crypto mode of OpenVPN in both security and flexibility. TLS mode works by establishing control and data channels which are multiplexed over a single TCP/UDP port. OpenVPN initiates a TLS session over the control channel and uses it to exchange cipher and HMAC keys to protect the data channel. TLS mode uses a robust reliability layer over the UDP connection for all control channel communication, while the data channel, over which encrypted tunnel data passes, is forwarded without any mediation. The result is the best of both worlds: a fast data channel that forwards over UDP with only the overhead of encrypt, decrypt, and HMAC functions, and a control channel that provides all of the security features of TLS, including certificate-based authentication and Diffie Hellman forward secrecy.

To use TLS mode, each peer that runs OpenVPN should have its own local certificate/key pair (--cert and --key), signed by the root certificate which is specified in --ca.

When two OpenVPN peers connect, each presents its local certificate to the other. Each peer will then check that its partner peer presented a certificate which was signed by the master root certificate as specified in --ca.

If that check on both peers succeeds, then the TLS negotiation will succeed, both OpenVPN peers will exchange temporary session keys, and the tunnel will begin passing data.

The OpenVPN project provides a set of scripts for managing RSA certificates and keys: https://github.com/OpenVPN/easy-rsa

--askpass file

Get certificate password from console or file before we daemonize.

Valid syntaxes:

askpass
askpass file

For the extremely security conscious, it is possible to protect your private key with a password. Of course this means that every time the OpenVPN daemon is started you must be there to type the password. The --askpass option allows you to start OpenVPN from the command line. It will query you for a password before it daemonizes. To protect a private key with a password you should omit the -nodes option when you use the openssl command line tool to manage certificates and private keys.

If file is specified, read the password from the first line of file. Keep in mind that storing your password in a file to a certain extent invalidates the extra security provided by using an encrypted key.

--ca file

Certificate authority (CA) file in .pem format, also referred to as the root certificate. This file can have multiple certificates in .pem format, concatenated together. You can construct your own certificate authority certificate and private key by using a command such as:

openssl req -nodes -new -x509 -keyout ca.key -out ca.crt

Then edit your openssl.cnf file and edit the certificate variable to point to your new root certificate ca.crt.

For testing purposes only, the OpenVPN distribution includes a sample CA certificate (ca.crt). Of course you should never use the test certificates and test keys distributed with OpenVPN in a production environment, since by virtue of the fact that they are distributed with OpenVPN, they are totally insecure.

--capath dir

Directory containing trusted certificates (CAs and CRLs). Not available with mbed TLS.

CAs in the capath directory are expected to be named <hash>.<n>. CRLs are expected to be named <hash>.r<n>. See the -CApath option of openssl verify, and the -hash option of openssl x509, openssl crl and X509_LOOKUP_hash_dir()(3) for more information.

Similar to the --crl-verify option, CRLs are not mandatory - OpenVPN will log the usual warning in the logs if the relevant CRL is missing, but the connection will be allowed.

--cert file

Local peer's signed certificate in .pem format -- must be signed by a certificate authority whose certificate is in --ca file. Each peer in an OpenVPN link running in TLS mode should have its own certificate and private key file. In addition, each certificate should have been signed by the key of a certificate authority whose public key resides in the --ca certificate authority file. You can easily make your own certificate authority (see above) or pay money to use a commercial service such as thawte.com (in which case you will be helping to finance the world's second space tourist :). To generate a certificate, you can use a command such as:

openssl req -nodes -new -keyout mycert.key -out mycert.csr

If your certificate authority private key lives on another machine, copy the certificate signing request (mycert.csr) to this other machine (this can be done over an insecure channel such as email). Now sign the certificate with a command such as:

openssl ca -out mycert.crt -in mycert.csr

Now copy the certificate (mycert.crt) back to the peer which initially generated the .csr file (this can be over a public medium). Note that the openssl ca command reads the location of the certificate authority key from its configuration file such as /usr/share/ssl/openssl.cnf -- note also that for certificate authority functions, you must set up the files index.txt (may be empty) and serial (initialize to 01).

--crl-verify args
 

Check peer certificate against a Certificate Revocation List.

Valid syntax:

crl-verify file/directory flag

Examples:

crl-verify crl-file.pem
crl-verify /etc/openvpn/crls dir

A CRL (certificate revocation list) is used when a particular key is compromised but when the overall PKI is still intact.

Suppose you had a PKI consisting of a CA, root certificate, and a number of client certificates. Suppose a laptop computer containing a client key and certificate was stolen. By adding the stolen certificate to the CRL file, you could reject any connection which attempts to use it, while preserving the overall integrity of the PKI.

The only time when it would be necessary to rebuild the entire PKI from scratch would be if the root certificate key itself was compromised.

The option is not mandatory - if the relevant CRL is missing, OpenVPN will log a warning in the logs - e.g.

VERIFY WARNING: depth=0, unable to get certificate CRL

but the connection will be allowed. If the optional dir flag is specified, enable a different mode where the crl-verify is pointed at a directory containing files named as revoked serial numbers (the files may be empty, the contents are never read). If a client requests a connection, where the client certificate serial number (decimal string) is the name of a file present in the directory, it will be rejected.

Note:
As the crl file (or directory) is read every time a peer connects, if you are dropping root privileges with --user, make sure that this user has sufficient privileges to read the file.
--dh file

File containing Diffie Hellman parameters in .pem format (required for --tls-server only).

Set file to none to disable Diffie Hellman key exchange (and use ECDH only). Note that this requires peers to be using an SSL library that supports ECDH TLS cipher suites (e.g. OpenSSL 1.0.1+, or mbed TLS 2.0+).

Use openssl dhparam -out dh2048.pem 2048 to generate 2048-bit DH parameters. Diffie Hellman parameters may be considered public.

--ecdh-curve name
 

Specify the curve to use for elliptic curve Diffie Hellman. Available curves can be listed with --show-curves. The specified curve will only be used for ECDH TLS-ciphers.

This option is not supported in mbed TLS builds of OpenVPN.

--extra-certs file
 

Specify a file containing one or more PEM certs (concatenated together) that complete the local certificate chain.

This option is useful for "split" CAs, where the CA for server certs is different than the CA for client certs. Putting certs in this file allows them to be used to complete the local certificate chain without trusting them to verify the peer-submitted certificate, as would be the case if the certs were placed in the ca file.

--hand-window n
 

Handshake Window -- the TLS-based key exchange must finalize within n seconds of handshake initiation by any peer (default 60 seconds). If the handshake fails we will attempt to reset our connection with our peer and try again. Even in the event of handshake failure we will still use our expiring key for up to --tran-window seconds to maintain continuity of transmission of tunnel data.

The --hand-window parameter also controls the amount of time that the OpenVPN client repeats the pull request until it times out.

--key file Local peer's private key in .pem format. Use the private key which was generated when you built your peer's certificate (see --cert file above).
--pkcs12 file Specify a PKCS #12 file containing local private key, local certificate, and root CA certificate. This option can be used instead of --ca, --cert, and --key. Not available with mbed TLS.
--remote-cert-eku oid
 

Require that peer certificate was signed with an explicit extended key usage.

This is a useful security option for clients, to ensure that the host they connect to is a designated server.

The extended key usage should be encoded in oid notation, or OpenSSL symbolic representation.

--remote-cert-ku key-usage
 

Require that peer certificate was signed with an explicit key-usage.

If present in the certificate, the keyUsage value is validated by the TLS library during the TLS handshake. Specifying this option without arguments requires this extension to be present (so the TLS library will verify it).

If key-usage is a list of usage bits, the keyUsage field must have at least the same bits set as the bits in one of the values supplied in the key-usage list.

The key-usage values in the list must be encoded in hex, e.g.

remote-cert-ku a0
--remote-cert-tls type
 

Require that peer certificate was signed with an explicit key usage and extended key usage based on RFC3280 TLS rules.

Valid syntaxes:

remote-cert-tls server
remote-cert-tls client

This is a useful security option for clients, to ensure that the host they connect to is a designated server. Or the other way around; for a server to verify that only hosts with a client certificate can connect.

The --remote-cert-tls client option is equivalent to

remote-cert-ku
remote-cert-eku "TLS Web Client Authentication"

The --remote-cert-tls server option is equivalent to

remote-cert-ku
remote-cert-eku "TLS Web Server Authentication"

This is an important security precaution to protect against a man-in-the-middle attack where an authorized client attempts to connect to another client by impersonating the server. The attack is easily prevented by having clients verify the server certificate using any one of --remote-cert-tls, --verify-x509-name, --peer-fingerprint or --tls-verify.

--tls-auth args
 

Add an additional layer of HMAC authentication on top of the TLS control channel to mitigate DoS attacks and attacks on the TLS stack.

Valid syntaxes:

tls-auth file
tls-auth file 0
tls-auth file 1

In a nutshell, --tls-auth enables a kind of "HMAC firewall" on OpenVPN's TCP/UDP port, where TLS control channel packets bearing an incorrect HMAC signature can be dropped immediately without response.

file (required) is a file in OpenVPN static key format which can be generated by --genkey.

Older versions (up to OpenVPN 2.3) supported a freeform passphrase file. This is no longer supported in newer versions (v2.4+).

See the --secret option for more information on the optional direction parameter.

--tls-auth is recommended when you are running OpenVPN in a mode where it is listening for packets from any IP address, such as when --remote is not specified, or --remote is specified with --float.

The rationale for this feature is as follows. TLS requires a multi-packet exchange before it is able to authenticate a peer. During this time before authentication, OpenVPN is allocating resources (memory and CPU) to this potential peer. The potential peer is also exposing many parts of OpenVPN and the OpenSSL library to the packets it is sending. Most successful network attacks today seek to either exploit bugs in programs (such as buffer overflow attacks) or force a program to consume so many resources that it becomes unusable. Of course the first line of defense is always to produce clean, well-audited code. OpenVPN has been written with buffer overflow attack prevention as a top priority. But as history has shown, many of the most widely used network applications have, from time to time, fallen to buffer overflow attacks.

So as a second line of defense, OpenVPN offers this special layer of authentication on top of the TLS control channel so that every packet on the control channel is authenticated by an HMAC signature and a unique ID for replay protection. This signature will also help protect against DoS (Denial of Service) attacks. An important rule of thumb in reducing vulnerability to DoS attacks is to minimize the amount of resources a potential, but as yet unauthenticated, client is able to consume.

--tls-auth does this by signing every TLS control channel packet with an HMAC signature, including packets which are sent before the TLS level has had a chance to authenticate the peer. The result is that packets without the correct signature can be dropped immediately upon reception, before they have a chance to consume additional system resources such as by initiating a TLS handshake. --tls-auth can be strengthened by adding the --replay-persist option which will keep OpenVPN's replay protection state in a file so that it is not lost across restarts.

It should be emphasized that this feature is optional and that the key file used with --tls-auth gives a peer nothing more than the power to initiate a TLS handshake. It is not used to encrypt or authenticate any tunnel data.

Use --tls-crypt instead if you want to use the key file to not only authenticate, but also encrypt the TLS control channel.

--tls-groups list
 

A list of allowable groups/curves in order of preference.

Set the allowed elliptic curves/groups for the TLS session. These groups are allowed to be used in signatures and key exchange.

mbedTLS currently allows all known curves per default.

OpenSSL 1.1+ restricts the list per default to

"X25519:secp256r1:X448:secp521r1:secp384r1".

If you use certificates that use non-standard curves, you might need to add them here. If you do not force the ecdh curve by using --ecdh-curve, the groups for ecdh will also be picked from this list.

OpenVPN maps the curve name secp256r1 to prime256v1 to allow specifying the same tls-groups option for mbedTLS and OpenSSL.

Warning: this option not only affects elliptic curve certificates but also the key exchange in TLS 1.3 and using this option improperly will disable TLS 1.3.

--tls-cert-profile profile
 

Set the allowed cryptographic algorithms for certificates according to profile.

The following profiles are supported:

insecure
Identical for mbed TLS to legacy
legacy (default)
SHA1 and newer, RSA 2048-bit+, any elliptic curve.
preferred
SHA2 and newer, RSA 2048-bit+, any elliptic curve.
suiteb
SHA256/SHA384, ECDSA with P-256 or P-384.

This option is only fully supported for mbed TLS builds. OpenSSL builds use the following approximation:

insecure
sets "security level 0"
legacy (default)
sets "security level 1"
preferred
sets "security level 2"
suiteb
sets "security level 3" and --tls-cipher "SUITEB128".

OpenVPN will migrate to 'preferred' as default in the future. Please ensure that your keys already comply.

WARNING: --tls-ciphers, --tls-ciphersuites and tls-groups
These options are expert features, which - if used correctly - can improve the security of your VPN connection. But it is also easy to unwittingly use them to carefully align a gun with your foot, or just break your connection. Use with care!
--tls-cipher l

A list l of allowable TLS ciphers delimited by a colon (":").

These setting can be used to ensure that certain cipher suites are used (or not used) for the TLS connection. OpenVPN uses TLS to secure the control channel, over which the keys that are used to protect the actual VPN traffic are exchanged.

The supplied list of ciphers is (after potential OpenSSL/IANA name translation) simply supplied to the crypto library. Please see the OpenSSL and/or mbed TLS documentation for details on the cipher list interpretation.

For OpenSSL, the --tls-cipher is used for TLS 1.2 and below.

Use --show-tls to see a list of TLS ciphers supported by your crypto library.

The default for --tls-cipher is to use mbed TLS's default cipher list when using mbed TLS or DEFAULT:!EXP:!LOW:!MEDIUM:!kDH:!kECDH:!DSS:!PSK:!SRP:!kRSA when using OpenSSL.

--tls-ciphersuites l
 

Same as --tls-cipher but for TLS 1.3 and up. mbed TLS has no TLS 1.3 support yet and only the --tls-cipher setting is used.

The default for --tls-ciphersuites is to use the crypto library's default.

--tls-client Enable TLS and assume client role during TLS handshake.
--tls-crypt keyfile
 

Encrypt and authenticate all control channel packets with the key from keyfile. (See --tls-auth for more background.)

Encrypting (and authenticating) control channel packets:

  • provides more privacy by hiding the certificate used for the TLS connection,
  • makes it harder to identify OpenVPN traffic as such,
  • provides "poor-man's" post-quantum security, against attackers who will never know the pre-shared key (i.e. no forward secrecy).

In contrast to --tls-auth, --tls-crypt does not require the user to set --key-direction.

Security Considerations

All peers use the same --tls-crypt pre-shared group key to authenticate and encrypt control channel messages. To ensure that IV collisions remain unlikely, this key should not be used to encrypt more than 2^48 client-to-server or 2^48 server-to-client control channel messages. A typical initial negotiation is about 10 packets in each direction. Assuming both initial negotiation and renegotiations are at most 2^16 (65536) packets (to be conservative), and (re)negotiations happen each minute for each user (24/7), this limits the tls-crypt key lifetime to 8171 years divided by the number of users. So a setup with 1000 users should rotate the key at least once each eight years. (And a setup with 8000 users each year.)

If IV collisions were to occur, this could result in the security of --tls-crypt degrading to the same security as using --tls-auth. That is, the control channel still benefits from the extra protection against active man-in-the-middle-attacks and DoS attacks, but may no longer offer extra privacy and post-quantum security on top of what TLS itself offers.

For large setups or setups where clients are not trusted, consider using --tls-crypt-v2 instead. That uses per-client unique keys, and thereby improves the bounds to 'rotate a client key at least once per 8000 years'.

--tls-crypt-v2 keyfile
 

Valid syntax:

tls-crypt-v2 keyfile
tls-crypt-v2 keyfile force-cookie
tls-crypt-v2 keyfile allow-noncookie

Use client-specific tls-crypt keys.

For clients, keyfile is a client-specific tls-crypt key. Such a key can be generated using the --genkey tls-crypt-v2-client option.

For servers, keyfile is used to unwrap client-specific keys supplied by the client during connection setup. This key must be the same as the key used to generate the client-specific key (see --genkey tls-crypt-v2-client).

On servers, this option can be used together with the --tls-auth or --tls-crypt option. In that case, the server will detect whether the client is using client-specific keys, and automatically select the right mode.

The optional parameters force-cookie allows only tls-crypt-v2 clients that support a cookie based stateless three way handshake that avoids replay attacks and state exhaustion on the server side (OpenVPN 2.6 and later). The option allow-noncookie explicitly allows older tls-crypt-v2 clients. The default is (currently) allow-noncookie.

--tls-crypt-v2-verify cmd
 

Run command cmd to verify the metadata of the client-specific tls-crypt-v2 key of a connecting client. This allows server administrators to reject client connections, before exposing the TLS stack (including the notoriously dangerous X.509 and ASN.1 stacks) to the connecting client.

OpenVPN supplies the following environment variables to the command (and only these variables. The normal environment variables available for other scripts are NOT present):

  • script_type is set to tls-crypt-v2-verify
  • metadata_type is set to 0 if the metadata was user supplied, or 1 if it's a 64-bit unix timestamp representing the key creation time.
  • metadata_file contains the filename of a temporary file that contains the client metadata.

The command can reject the connection by exiting with a non-zero exit code.

--tls-exit Exit on TLS negotiation failure. This option can be useful when you only want to make one attempt at connecting, e.g. in a test or monitoring script. (OpenVPN's own test suite uses it this way.)
--tls-server Enable TLS and assume server role during TLS handshake. Note that OpenVPN is designed as a peer-to-peer application. The designation of client or server is only for the purpose of negotiating the TLS control channel.
--tls-timeout n
 Packet retransmit timeout on TLS control channel if no acknowledgment from remote within n seconds (default 2). When OpenVPN sends a control packet to its peer, it will expect to receive an acknowledgement within n seconds or it will retransmit the packet, subject to a TCP-like exponential backoff algorithm. This parameter only applies to control channel packets. Data channel packets (which carry encrypted tunnel data) are never acknowledged, sequenced, or retransmitted by OpenVPN because the higher level network protocols running on top of the tunnel such as TCP expect this role to be left to them.
--tls-version-min args
 

Sets the minimum TLS version we will accept from the peer (default in 2.6.0 and later is "1.2").

Valid syntax:

tls-version-min version ['or-highest']

Examples for version include 1.0, 1.1, or 1.2. If or-highest is specified and version is not recognized, we will only accept the highest TLS version supported by the local SSL implementation.

--tls-version-max version
 Set the maximum TLS version we will use (default is the highest version supported). Examples for version include 1.0, 1.1, or 1.2.
--verify-hash args
 

DEPRECATED Specify SHA1 or SHA256 fingerprint for level-1 cert.

Valid syntax:

verify-hash hash [algo]

The level-1 cert is the CA (or intermediate cert) that signs the leaf certificate, and is one removed from the leaf certificate in the direction of the root. When accepting a connection from a peer, the level-1 cert fingerprint must match hash or certificate verification will fail. Hash is specified as XX:XX:... For example:

AD:B0:95:D8:09:C8:36:45:12:A9:89:C8:90:09:CB:13:72:A6:AD:16

The algo flag can be either SHA1 or SHA256. If not provided, it defaults to SHA1.

This option can also be inlined

<verify-hash>
00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff
11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00
</verify-hash>

If the option is inlined, algo is always SHA256.

--peer-fingerprint args
 
Specify a SHA256 fingerprint or list of SHA256 fingerprints to verify the peer certificate against. The peer certificate must match one of the fingerprint or certificate verification will fail. The option can also be inlined

Valid syntax:

peer-fingerprint AD:B0:95:D8:09:...

or inline:

<peer-fingerprint>
00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff
11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00
</peer-fingerprint>

When the --peer-fingerprint option is used, specifying a CA with --ca or --capath is optional. This allows the he --peer-fingerprint to be used as alternative to a PKI with self-signed certificates for small setups. See the examples section for such a setup.

--verify-x509-name args
 

Accept connections only if a host's X.509 name is equal to name. The remote host must also pass all other tests of verification.

Valid syntax:

verify-x509 name type

Which X.509 name is compared to name depends on the setting of type. type can be subject to match the complete subject DN (default), name to match a subject RDN or name-prefix to match a subject RDN prefix. Which RDN is verified as name depends on the --x509-username-field option. But it defaults to the common name (CN), e.g. a certificate with a subject DN

C=KG, ST=NA, L=Bishkek, CN=Server-1

would be matched by:

verify-x509-name 'C=KG, ST=NA, L=Bishkek, CN=Server-1'
verify-x509-name Server-1 name
verify-x509-name Server- name-prefix

The last example is useful if you want a client