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 runningopenvpnwithout any parameters.
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 theTUN/TAPvirtual 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.
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--askpassor--auth-user-passusername/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-nocachein combination with a user/password file and--chrootor--daemon, make sure to use an absolute path. This directive does not affect the--http-proxyusername/password. It is always cached. |
--cddir | Change directory todirprior to reading any files such as configuration files, key files, scripts, etc.dirshould be an absolute path, with a leading "/", and without any references to the current directory such as This option is useful when you are running OpenVPN in--daemonmode, and you want to consolidate all of your OpenVPN control files in one location. |
--chrootdir | Chroot todirafter initialization.--chrootessentially redefinesdiras 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, thedirparameter 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 directorydir. This is because SSL libraries occasionally need to collect fresh random. Newer linux kernels and some BSDs implement a getrandom() or getentropy() syscall that removes the need for /dev/urandom to be available. |
--configfile | Load additional config options fromfilewhere each line corresponds to one command line option, but with the leading '--' removed. If--configfileis the only option to the openvpn command, the--configcan be removed, and the command can be given asopenvpn 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, seehttps://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 peerremote mypeer.mydomain# 10.1.0.1 is our local VPN endpoint# 10.1.0.2 is our remote VPN endpointifconfig 10.1.0.1 10.1.0.2# Our pre-shared static keysecret static.key |
--daemonprogname | |
Become a daemon after all initialization functions are completed. This option will cause all message and error output to be sent to the syslog file (such as The optionalprognameparameter will cause OpenVPN to report its program name to the system logger asprogname. This can be useful in linking OpenVPN messages in the syslog file with specific tunnels. When unspecified,prognamedefaults to "openvpn". When OpenVPN is run with the--daemonoption, 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--askpassoption 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--daemontogether with--auth-user-pass(entered on console) and--auth-nocachewill fail as soon as key renegotiation (and reauthentication) occurs. | |
--disable-occ | 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--devtunwhile the other peer uses--devtap. 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. |
--engineengine-name | |
Enable OpenSSL hardware-based crypto engine functionality. Ifengine-nameis specified, use a specific crypto engine. Use the--show-enginesstandalone 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--protoudpis specified, and when--shaperis NOT specified. |
--groupgroup | Similar to the--useroption, this option changes the group ID of the OpenVPN process togroupafter initialization. |
--ignore-unknown-optionargs | |
Valid syntax: ignore-unknown-options opt1 opt2 opt3 ... optN When one of optionsopt1 ... optNis encountered in the configuration file the configuration file parsing does not fail if this OpenVPN version does not support the option. Multiple--ignore-unknown-optionoptions 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-optionis available since OpenVPN 2.3.3. | |
--iproutecmd | Set alternate command to execute instead of defaultiproute2command. May be used in order to execute OpenVPN in unprivileged environment. |
--keying-material-exporterargs | |
Save Exported Keying Material [RFC5705] of len bytes (must be between 16 and 4095 bytes) usinglabelin environment ( Valid syntax: keying-material-exporter label len Note that exporterlabelshave the potential to collide with existing PRF labels. In order to prevent this, labelsMUSTbegin with | |
--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--useroption). 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--renegoptions (see below), then are discarded. The downside of using--mlockis 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. |
--nicen | Change process priority after initialization (ngreater than 0 is lower priority,nless than zero is higher priority). |
--persist-key | Don't re-read key files across This option can be combined with--usernobodyto allow restarts triggered by the This option solves the problem by persisting keys across |
--providersproviders | |
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-usr1signal | |
Control whether internally or externally generated signalcan be set to | |
--script-securitylevel | |
This directive offers policy-level control over OpenVPN's usage of external programs and scripts. Lowerlevelvalues are more restrictive, higher values are more permissive. Settings forlevel:
OpenVPN releases before v2.3 also supported amethodflag which indicated how OpenVPN should call external commands and scripts. This could be either Some directives such as--upallow 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 thesystemflag 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 | |
--setconcontext | |
Apply SELinuxcontextafter initialization. This essentially provides the ability to restrict OpenVPN's rights to only network I/O operations, thanks to SELinux. This goes further than--userand--chrootin 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-keyand--persist-tunoptions. | |
--statusargs | Write operational status tofileeverynseconds. Valid syntaxes: status filestatus file n Status can also be written to the syslog by sending a 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-versionoption in that case. For clients or instances running in point-to-point mode, it will contain the traffic statistics. |
--status-versionn | |
Set the status file format version number ton. This only affects the status file on servers with multi-client capability enabled. Valid status version values:
| |
--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--devor--remote. The typical usage of--test-cryptowould 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-dirdir | Specify a directorydirfor 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:
|
--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. | |
--useruser | Change the user ID of the OpenVPN process touserafter 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 settinguserto |
--writepidfile | |
Write OpenVPN's main process ID tofile. |
Log options
--echoparms | Echoparmsto 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--logoptions. | |
--logfile | Output logging messages tofile, including output to stdout/stderr which is generated by called scripts. Iffilealready exists it will be truncated. This option takes effect immediately when it is parsed in the command line and will supersede syslog output if--daemonor--inetdis also specified. This option is persistent over the entire course of an OpenVPN instantiation and will not be reset by Note that on Windows, when OpenVPN is started as a service, logging occurs by default without the need to specify this option. |
--log-appendfile | |
Append logging messages tofile. Iffiledoes not exist, it will be created. This option behaves exactly like--logexcept 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. | |
--muten | Log at mostnconsecutive 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. | |
--syslogprogname | |
Direct log output to system logger, but do not become a daemon. See--daemondirective above for description ofprognameparameter. | |
--verbn | Set output verbosity ton(default
|
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-compressionmode | |
As described in the--compressoption, compression is a potentially dangerous option. This option allows controlling the behaviour of OpenVPN when compression is used and allowed. Valid syntaxes: allow-compressionallow-compression mode Themodeargument can be one of the following values:
| |
--authalg | Authenticate data channel packets and (if enabled)tls-authcontrol channel packets with HMAC using message digest algorithmalg. (The default isSHA1). 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--authalgorithm is ignored for the data channel and the authentication method of the AEAD cipher is used instead. Note thatalgstill specifies the digest used fortls-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. Setalg=noneto disable authentication. For more information on HMAC seehttp://www.cs.ucsd.edu/users/mihir/papers/hmac.html |
--cipheralg | This option is deprecated for server-client mode.--data-ciphersor possibly--data-ciphers-fallback`should be used instead. Encrypt data channel packets with cipher algorithmalg. The default is Using To see other ciphers that are available with OpenVPN, use the--show-ciphersoption. Setalgto |
--compressalgorithm | |
DEPRECATEDEnable a compression algorithm. Compression is generally not recommended. VPN tunnels which use compression are susceptible to the VORALCE attack vector. Thealgorithmparameter may be The If thealgorithmparameter is Note: the *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. theCRIMEandBREACHattacks on TLS andVORACLEon 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 tonotenable compression. | |
--comp-lzomode | |
DEPRECATEDEnable 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.modemay be 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-lzodirective, such as--comp-lzono. This will turn off compression by default, but allow a future directive push from the server to dynamically change the Next in a--client-config-dirfile, specify the compression setting for the client, for example: comp-lzo yespush "comp-lzo yes" The first line sets thecomp-lzosetting for the server side of the link, the second sets the client side. | |
--comp-noadapt | DEPRECATEDWhen 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-authand--secretoptions. Useful when using inline files (See section on inline files). | |
--keysizen | DEPRECATEDThis option will be removed in OpenVPN 2.6. Size of cipher key in bits (optional). If unspecified, defaults to cipher-specific default. The--show-ciphersoption (see below) shows all available OpenSSL ciphers, their default key sizes, and whether the key size can be changed. Use care in changing a cipher's default key size. Many ciphers have not been extensively cryptanalyzed with non-standard key lengths, and a larger key may offer no real guarantee of greater security, or may even reduce security. |
--data-cipherscipher-list | |
Restrict the allowed ciphers to be negotiated to the ciphers incipher-list.cipher-listis a colon-separated list of ciphers, and defaults to For servers, the first cipher fromcipher-listthat is also supported by the client will be pushed to clients that support cipher negotiation. Cipher negotiation is enabled in client-server mode only. I.e. if--modeis set to 'server' (server-side, implied by setting--server), or if--pullis 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. Additionally, to allow for more smooth transition, if NCP is enabled, OpenVPN will inherit the cipher of the peer if that cipher is different from the local--ciphersetting, but the peer cipher is one of the ciphers specified in--data-ciphers. E.g. a non-NCP client (<=v2.3, or with --ncp-disabled set) connecting to a NCP server (v2.4+) with--cipherBF-CBCand--data-ciphersAES-256-GCM:AES-256-CBCset can either specify--cipherBF-CBCor--cipherAES-256-CBCand both will work. Note for using NCP with an OpenVPN 2.4 peer: This list must include the This list is restricted to be 127 chars long after conversion to OpenVPN ciphers. This option was called--ncp-ciphersin OpenVPN 2.4 but has been renamed to--data-ciphersin OpenVPN 2.5 to more accurately reflect its meaning. | |
--data-ciphers-fallbackalg | |
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 and older version, and have been configured with--enable-small(typically used on routers or other embedded devices). | |
--ncp-disable | DEPRECATEDDisable "Negotiable Crypto Parameters". This completely disables cipher negotiation. |
--secretargs | Enable Static Key encryption mode (non-TLS). Use pre-shared secretfilewhich was generated with--genkey. Valid syntaxes: secret filesecret file direction The optionaldirectionparameter 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 thedirectionparameter is omitted, 2 keys are used bidirectionally, one for HMAC and the other for encryption/decryption. Thedirectionparameter should always be complementary on either side of the connection, i.e. one side should use Thedirectionparameter requires thatfilecontains a 2048 bit key. While pre-1.5 versions of OpenVPN generate 1024 bit key files, any version of OpenVPN which supports thedirectionparameter, will also support 2048 bit key file generation using the--genkeyoption. 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 asssh) 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-windown | |
Transition window -- our old key can live this many seconds after a new a key renegotiation begins (default3600 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. |
Client Options
The client options are used when connecting to an OpenVPN server configured to use--server,--server-bridge, or--modeserverin 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-tokentoken | |
This is not an option to be used directly in any configuration files, but rather push this option from a--client-connectscript or a--pluginwhich hooks into the Whenever the connection is renegotiated and the--auth-user-pass-verifyscript or--pluginmaking use of the 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-connectscript or--pluginneeds 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 theUNIQUE_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-userbase64username | |
Companion option to--auth-token. This options allows to override the username used by the client when reauthenticating with theauth-token. It also allows to use--auth-tokenin 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-passauth-user-pass up Ifupis present, it must be a file containing username/password on 2 lines. If the password line is missing, OpenVPN will prompt for one. Ifupis omitted, username/password will be prompted from the console. The server configuration must specify an--auth-user-pass-verifyscript to verify the username/password provided by the client. | |
--auth-retrytype | |
Controls how OpenVPN responds to username/password verification errors such as the client-side response to an Normally used to prevent auth errors from being fatal on the client side, and to permit username/password requeries in case of error. An typecan be one of:
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: pulltls-client |
--client-natargs | |
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.0client-nat dnat 10.64.0.0/255.255.0.0 network/netmask(for example Use Set--verb6for debugging info showing the transformation of src/dest addresses in packets. | |
--connect-retryn | |
Waitnseconds between connection attempts (default5 ). Repeated reconnection attempts are slowed down after 5 retries per remote by doubling the wait time after each unsuccessful attempt. An optional argumentmaxspecifies the maximum value of wait time in seconds at which it gets capped (default300 ). | |
--connect-retry-maxn | |
nspecifies the number of times each--remoteor<connection>entry is tried. Specifyingnas1 would try each entry exactly once. A successful connection resets the counter. (defaultunlimited). | |
--connect-timeoutn | |
See--server-poll-timeout. | |
--explicit-exit-notifyn | |
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. Thenparameter (default In UDP server mode, send OpenVPN will not send any exit notifications unless this option is enabled. | |
--inactiveargs | |
Causes OpenVPN to exit afternseconds 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 ninactive n bytes If the optionalbytesparameter is included, exit if less thanbytesof combined in/out traffic are produced on the tun/tap device innseconds. 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-forcep | |
When iterating through connection profiles, only consider profiles using protocolp( 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 | |
--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--pulloption is implied by--client). In particular,--pullallows the server to push routes to the client, so you should not use--pullor--clientin situations where you don't trust the server to have control over the client's routing table. |
--pull-filterargs | |
Filter options on the client pushed by the server to the client. Valid syntaxes: pull-filter accept textpull-filter ignore textpull-filter reject text Filter options received from the server if the option starts with Prefix comparison is used to match pull-filter ignore "route" would remove all pushed options starting withroutewhich would include, for example,route-gateway. Enclosetextin quotes to embed spaces. pull-filter accept "route 192.168.1."pull-filter ignore "route " would remove all routes that do not start with192.168.1. Notethat | |
--push-peer-info | |
Push additional information about the client to server. The following data is always pushed to the server:
When--push-peer-infois enabled the additional information consists of the following data:
| |
--remoteargs | Remote host name or IP address, port and protocol. Valid syntaxes: remote hostremote host portremote host port proto Theportandprotoarguments are optional. The OpenVPN client will try to connect to a server athost:port. Theprotoargument indicates the protocol to use when connecting with the remote, and may be On the client, multiple--remoteoptions may be specified for redundancy, each referring to a different OpenVPN server, in the order specified by the list of--remoteoptions. Specifying multiple--remoteoptions 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.netremote server1.example.net 1194remote server2.example.net 1194 tcp
If--remoteis 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,--remotewill act as a filter, rejecting connections from any host which does not matchhost. Ifhostis 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--remoteaddress/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-retryn | |
If hostname resolve fails for--remote, retry resolve fornseconds before failing. Setnto "infinite" to retry indefinitely. By default,--resolv-retryinfiniteis 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-sessioncan be used with--ping-exitor--inactiveto create a single dynamic session that will exit when finished. | |
--server-poll-timeoutn | |
When connecting to a remote server do not wait for more thannseconds for a response before trying the next server. The default value is 120s. This timeout includes proxy and TCP connect timeouts. | |
--static-challengeargs | |
Enable static challenge/response protocol Valid syntax: static-challenge text echo Thetextchallenge text is presented to the user which describes what information is requested. Theechoflag indicates if the user's input should be echoed on the screen. Validechovalues are See management-notes.txt in the OpenVPN distribution for a description of the OpenVPN challenge/response protocol. |
--show-proxy-settings | |
Show sensed HTTP or SOCKS proxy settings. Currently, only Windows clients support this option. | |
--http-proxyargs | |
Connect to remote host through an HTTP proxy. This requires at least an addressserverandportargument. If HTTP Proxy-Authenticate is required, a file name to anauthfilefile containing a username and password on 2 lines can be given, or The last optional argument is anauth-methodwhich should be one of HTTP Digest authentication is supported as well, but only via the The Theauto-nctflag (no clear-text auth) instructs OpenVPN to automatically determine the authentication method, but to reject weak authentication protocols such as HTTP Basic Authentication. Examples: http-proxy proxy.example.net 3128http-proxy proxy.example.net 3128 authfile.txthttp-proxy proxy.example.net 3128 stdinhttp-proxy proxy.example.net 3128 auto basichttp-proxy proxy.example.net 3128 auto-nct ntlm | |
--http-proxy-optionargs | |
Set extended HTTP proxy options. Requires an optiontypeas argument and an optionalparameterto the type. Repeat to set multiple options.
Examples: http-proxy-option VERSION 1.1http-proxy-option AGENT OpenVPN/2.4http-proxy-option X-Proxy-Flag some-flags | |
--socks-proxyargs | |
Connect to remote host through a Socks5 proxy. A requiredserverargument is needed. Optionally aport(default1080 ) andauthfilecan be given. Theauthfileis a file containing a username and password on 2 lines, orstdin 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--modeserveroption. 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-tokenargs | |
Returns an authentication token to successfully authenticated clients. Valid syntax: auth-gen-token [lifetime] [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. Thelifetimeargument defines how long the generated token is valid. The lifetime is defined in seconds. If lifetime is not set or it is set to The token will expire either after the configuredlifetimeof the token is reached or after not being renewed for more than 2 *reneg-secseconds. Clients will be sent renewed tokens on every TLS renogiation to keep the client's token updated. This is done to invalidate a token if a client is disconnected for a sufficently 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 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 asession_idvariable that holds the session id from auth-gen-token. Also an environment variablesession_stateis present. This variable indicates whether the auth-token has succeeded or not. It can have the following values:
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-secretfile | |
Specifies a file that holds a secret for the HMAC used in--auth-gen-tokenIffileis 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-verifyor--management-client-authare 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-dirfile. | |
--client-config-dirdir | |
Specify a directorydirfor 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-pvidand--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-clientflag 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. | |
--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-verifyoption). 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-diror dynamically generated using a--client-connectscript. |
--connect-freqargs | |
Allow a maximum ofnnew connections persecseconds 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 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--protoudpand either--tls-author--tls-crypt. | |
--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-poolargs | |
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 optionalnetmaskparameter will also be pushed to clients. | |
--ifconfig-ipv6-poolargs | |
Specify an IPv6 address pool for dynamic assignment to clients. Valid args: ifconfig-ipv6-pool ipv6addr/bits The pool starts atipv6addrand matches the offset determined from the start of the IPv4 pool. If the host part of the given IPv6 address is0, the pool starts atipv6addr+1. | |
--ifconfig-pool-persistargs | |
Persist/unpersist ifconfig-pool data tofile, atsecondsintervals (default 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-tunoption. fileis a comma-delimited ASCII file, formatted as Ifseconds= Note that the entries in this file are treated by OpenVPN assuggestionsonly, 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-pushargs | |
Push virtual IP endpoints for client tunnel, overriding the--ifconfig-pooldynamic allocation. Valid syntax: ifconfig-push local remote-netmask [alias] The parameterslocalandremote-netmaskare set according to the--ifconfigdirective which you want to execute on the client machine to configure the remote end of the tunnel. Note that the parameterslocalandremote-netmaskare 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 optionalaliasparameter may be used in cases where NAT causes the client view of its local endpoint to differ from the server view. In this caselocal/remote-netmaskwill refer to the server view whilealias/remote-netmaskwill 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-diror dynamically generated using a--client-connectscript. Remember also to include a--routedirective in the main OpenVPN config file which encloseslocal, 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:
| |
--ifconfig-ipv6-pushargs | |
for--client-config-dirper-client static IPv6 interface configuration, see--client-config-dirand--ifconfig-pushfor more details. Valid syntax: ifconfig-ipv6-push ipv6addr/bits ipv6remote | |
--inetdargs | Valid syntaxes: inetdinetd waitinetd nowaitinetd wait progname Use this option when OpenVPN is being run from the inetd orxinetd(8) server. The This option precludes the use of--daemon,--localor--remote. Note that this option causes message and error output to be handled in the same way as the--daemonoption. The optionalprognameparameter is also handled exactly as in--daemon. Also note that inwaitmode, each OpenVPN tunnel requires a separate TCP/UDP port and a separate inetd or xinetd entry. See the OpenVPN 1.x HOWTO for an example on using OpenVPN with xinetd:https://openvpn.net/community-resources/1xhowto/ |
--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--localto 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.
|
--irouteargs | Generate an internal route to a specific client. Thenetmaskparameter, if omitted, defaults to 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--routedirective). The reason why two routes are needed is that the--routedirective routes the packet from the kernel to OpenVPN. Once in OpenVPN, the--iroutedirective routes to the specific client. This option must be specified either in a client instance config file using--client-config-diror dynamically generated using a--client-connectscript. The--iroutedirective also has an important interaction with--push"route...".--irouteessentially defines a subnet which is owned by a particular client (we will call this clientA). If you would like other clients to be able to reachA's subnet, you can use--push"route..."together with--client-to-clientto effect this. In order for all clients to seeA's subnet, OpenVPN must push this route to all clients EXCEPT forA, since the subnet is already owned byA. OpenVPN accomplishes this by not not pushing a route to a client if it matches one of the client's iroutes. |
--iroute-ipv6args | |
for--client-config-dirper-client static IPv6 route configuration, see--iroutefor more details how to setup and use this, and how--irouteand--routeinteract. Valid syntax: iroute-ipv6 ipv6addr/bits | |
--max-clientsn | |
Limit server to a maximum ofnconcurrent clients. | |
--max-routes-per-clientn | |
Allow a maximum ofninternal routes per client (default Note that this directive affects OpenVPN's internal routing table, not the kernel routing table. | |
--opt-verify | Clients that connect with options that are incompatible with those of the server will be disconnected. Options that will be compared for compatibility includedev-type,link-mtu,tun-mtu,proto,ifconfig,comp-lzo,fragment,keydir,cipher,auth,keysize,secret,no-replay,tls-auth,key-method,tls-serverandtls-client. This option requires that--disable-occNOT be used. |
--port-shareargs | |
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 athost:port. Currently only designed to work with HTTP/HTTPS, though it would be theoretically possible to extend to other protocols such as ssh. dirspecifies 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. | |
--pushoption | Push a config file option back to the client for remote execution. Note thatoptionmust be enclosed in double quotes ( This is a partial list of options which can currently be pushed:--route,--route-gateway,--route-delay,--redirect-gateway,--ip-win32,--dhcp-option,--inactive,--ping,--ping-exit,--ping-restart,--setenv,--auth-token,--persist-key,--persist-tun,--echo,--comp-lzo,--socket-flags,--sndbuf,--rcvbuf |
--push-removeopt | |
Selectively remove all--pushoptions matching "opt" from the option list for a client.optis matched as a substring against the whole option string to-be-pushed to the client, so--push-removeroutewould remove all--pushroute ...and--pushroute-ipv6...statements, while--push-remove"route-ipv62001:"would only remove IPv6 routes for --push-removecan only be used in a client-specific context, like in a--client-config-dirfile, or--client-connectscript or plugin -- similar to--push-reset, just more selective. NOTE: tochangean option,--push-removecan be used to first remove the old value, and then add a new--pushoption 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-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-dirconfiguration file. This option will ignore--pushoptions at the global config file level. NOTE:--push-resetis 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,--topologysubnetand--route-gatewaywill get lost and this will break client configs in many cases. Thus, for most purposes,--push-removeis better suited to selectively remove push options for individual clients. |
--serverargs | 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 Valid syntax: server network netmask [nopool] For example,--server10.8.0.0 255.255.255.0expands as follows: mode servertls-serverpush "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--serverif you are ethernet bridging. Use--server-bridgeinstead. |
--server-bridgeargs | |
A helper directive similar to--serverwhich 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-IPserver-bridge [nogw] If--server-bridgeis 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 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 Next you you must manually set the IP/netmask on the bridge interface. Thegatewayandnetmaskparameters to--server-bridgecan 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 bypool-start-IPandpool-end-IP, for OpenVPN to allocate to connecting clients. For example,server-bridge10.8.0.4 255.255.255.0 10.8.0.128 10.8.0.254expands as follows: mode servertls-serverifconfig-pool 10.8.0.128 10.8.0.254 255.255.255.0push "route-gateway 10.8.0.4" In another example,--server-bridge(without parameters) expands as follows: mode servertls-serverpush "route-gateway dhcp" Or--server-bridgenogwexpands as follows: mode servertls-server | |
--server-ipv6args | |
Convenience-function to enable a number of IPv6 related options at once, namely--ifconfig-ipv6,--ifconfig-ipv6-pooland--pushtun-ipv6. Valid syntax: server-ipv6 ipv6addr/bits Pushing of the--tun-ipv6directive is done for older clients which require an explicit--tun-ipv6in their configuration. | |
--stale-routes-checkargs | |
Remove routes which haven't had activity fornseconds (i.e. the ageing time). This check is run everytseconds (i.e. check interval). Valid syntax: stale-routes-check n [t] Iftis not present it defaults ton. 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-passverification is in effect. As the replacement happens after--auth-user-passverification, 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-certmode | |
Specify whether the client is required to supply a valid certificate. Possiblemodeoptions are:
If you don't use this directive (or use--verify-client-certrequire) but you also specify an--auth-user-pass-verifyscript, then OpenVPN will perform double authentication. The client certificate verification AND the--auth-user-pass-verifyscript 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-acceptsetting. 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-pvidvoption 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-clientis activated. The packet filtering takes place in the OpenVPN server. Clients should not have any VLAN tagging configuration applied. The--vlan-taggingoption 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--devtap mode. |
--vlan-acceptargs | |
Configure the VLAN tagging policy for the server TAP device. Valid syntax: vlan-accept all|tagged|untagged The following modes are available:
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 noPVIDis configured for a given client (see --vlan-pvid) packets are tagged with 1 by default. | |
--vlan-pvidv | Specifies which VLAN identifier a "port" is associated with. Only valid when--vlan-taggingis speficied. 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-acceptuntaggedand--vlan-acceptallmodes. Valid values forvgo from In some switch implementations, thePVIDis also referred to as "Native VLAN". |
SSL Library information
--show-ciphers | (Standalone) Show all cipher algorithms to use with the--cipheroption. |
--show-digests | (Standalone) Show all message digest algorithms to use with the--authoption. |
--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-curveandtls-groupsoptions. |
Generating key material
--genkeyargs | (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:
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
|
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-bytesn | |
Renegotiate data channel key afternbytes 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-bytesis set to 64MB by default, unless it is explicitly disabled by setting the value to | |
--reneg-pktsn | Renegotiate data channel key afternpackets sent and received (disabled by default). |
--reneg-secargs | |
Renegotiate data channel key after at mostmaxseconds (default reneg-sec max [min] The effective--reneg-secvalue used is per session pseudo-uniform-randomized betweenminandmax. With the default value of 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-secto a higher value on either the client or server, while the other side of the connection is still using the default value of |
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 (--certand--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
--askpassfile | Get certificate password from console orfilebefore we daemonize. Valid syntaxes: askpassaskpass 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--askpassoption 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-nodesoption when you use theopensslcommand line tool to manage certificates and private keys. Iffileis specified, read the password from the first line offile. Keep in mind that storing your password in a file to a certain extent invalidates the extra security provided by using an encrypted key. |
--cafile | Certificate authority (CA) file in .pem format, also referred to as therootcertificate. 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 thecertificatevariable to point to your new root certificateca.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. |
--capathdir | 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-CApathoption ofopenssl verify, and the-hashoption ofopenssl x509,openssl crlandX509_LOOKUP_hash_dir()(3) for more information. Similar to the--crl-verifyoption, 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. |
--certfile | Local peer's signed certificate in .pem format -- must be signed by a certificate authority whose certificate is in--cafile. 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--cacertificate 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 theopenssl cacommand reads the location of the certificate authority key from its configuration file such as |
--crl-verifyargs | |
Check peer certificate against a Certificate Revocation List. Valid syntax: crl-verify file/directory flag Examples: crl-verify crl-file.pemcrl-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
| |
--dhfile | File containing Diffie Hellman parameters in .pem format (required for--tls-serveronly). Setfileto Useopenssl dhparam-outdh2048.pem 2048to generate 2048-bit DH parameters. Diffie Hellman parameters may be considered public. |
--ecdh-curvename | |
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-certsfile | |
Specify afilecontaining 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 thecafile. | |
--hand-windown | |
Handshake Window -- the TLS-based key exchange must finalize withinnseconds of handshake initiation by any peer (default60 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-windowseconds to maintain continuity of transmission of tunnel data. | |
--keyfile | Local peer's private key in .pem format. Use the private key which was generated when you built your peer's certificate (see--certfileabove). |
--pkcs12file | 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-ekuoid | |
Require that peer certificate was signed with an explicitextended 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 inoid notation, orOpenSSL symbolic representation. | |
--remote-cert-kukey-usage | |
Require that peer certificate was signed with an explicitkey-usage. If present in the certificate, the Ifkey-usageis a list of usage bits, the Thekey-usagevalues in the list must be encoded in hex, e.g. remote-cert-ku a0 | |
--remote-cert-tlstype | |
Require that peer certificate was signed with an explicitkey usageandextended key usagebased on RFC3280 TLS rules. Valid syntaxes: remote-cert-tls serverremote-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-tlsclientoption is equivalent to remote-cert-kuremote-cert-eku "TLS Web Client Authentication" The--remote-cert-tlsserveroption is equivalent to remote-cert-kuremote-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, or--tls-verify. | |
--tls-authargs | |
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 filetls-auth file 0tls-auth file 1 In a nutshell,--tls-authenables 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--secretoption for more information on the optionaldirectionparameter. --tls-authis recommended when you are running OpenVPN in a mode where it is listening for packets from any IP address, such as when--remoteis not specified, or--remoteis 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-authdoes 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-authcan be strengthened by adding the--replay-persistoption 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-authgives 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-cryptinstead if you want to use the key file to not only authenticate, but also encrypt the TLS control channel. | |
--tls-groupslist | |
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 namesecp256r1toprime256v1to 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-profileprofile | |
Set the allowed cryptographic algorithms for certificates according toprofile. The following profiles are supported:
This option is only fully supported for mbed TLS builds. OpenSSL builds use the following approximation:
OpenVPN will migrate to 'preferred' as default in the future. Please ensure that your keys already comply. |
- WARNING:--tls-ciphers,--tls-ciphersuitesandtls-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-cipherl | A listlof 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-cipheris used for TLS 1.2 and below. Use--show-tlsto see a list of TLS ciphers supported by your crypto library. The default for--tls-cipheris to use mbed TLS's default cipher list when using mbed TLS or |
--tls-ciphersuitesl | |
Same as--tls-cipherbut for TLS 1.3 and up. mbed TLS has no TLS 1.3 support yet and only the--tls-ciphersetting is used. The default for--tls-ciphersuitesis to use the crypto library's default. | |
--tls-client | Enable TLS and assume client role during TLS handshake. |
--tls-cryptkeyfile | |
Encrypt and authenticate all control channel packets with the key fromkeyfile. (See--tls-authfor more background.) Encrypting (and authenticating) control channel packets:
In contrast to--tls-auth,--tls-cryptdoesnotrequire the user to set--key-direction. Security Considerations All peers use the same--tls-cryptpre-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-cryptdegrading 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-v2instead. That uses per-client unique keys, and thereby improves the bounds to 'rotate a client key at least once per 8000 years'. | |
--tls-crypt-v2keyfile | |
Use client-specific tls-crypt keys. For clients,keyfileis a client-specific tls-crypt key. Such a key can be generated using the For servers,keyfileis 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 On servers, this option can be used together with the--tls-author--tls-cryptoption. In that case, the server will detect whether the client is using client-specific keys, and automatically select the right mode. | |
--tls-crypt-v2-verifycmd | |
Run commandcmdto 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:
The command can reject the connection by exiting with a non-zero exit code. | |
--tls-exit | Exit on TLS negotiation failure. |
--tls-export-certdirectory | |
Store the certificates the clients use upon connection to this directory. This will be done before--tls-verifyis called. The certificates will use a temporary name and will be deleted when the tls-verify script returns. The file name used for the certificate is available via thepeer_certenvironment variable. | |
--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-timeoutn | |
Packet retransmit timeout on TLS control channel if no acknowledgment from remote withinnseconds (default2 ). When OpenVPN sends a control packet to its peer, it will expect to receive an acknowledgement withinnseconds 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-minargs | |
Sets the minimum TLS version we will accept from the peer (default is "1.0"). Valid syntax: tls-version-min version ['or-highest'] Examples for version include | |
--tls-version-maxversion | |
Set the maximum TLS version we will use (default is the highest version supported). Examples for version include1.0 ,1.1 , or1.2 . | |
--verify-hashargs | |
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 matchhashor 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 Thealgoflag can be either | |
--verify-x509-nameargs | |
Accept connections only if a host's X.509 name is equal toname.The remote host must also pass all other tests of verification. Valid syntax: verify-x509 name type Which X.509 name is compared tonamedepends on the setting of type.typecan be 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 nameverify-x509-name Server- name-prefix The last example is useful if you want a client to only accept connections to --verify-x509-nameis a useful replacement for the--tls-verifyoption to verify the remote host, because--verify-x509-nameworks in a--chrootenvironment without any dependencies. Using a name prefix is a useful alternative to managing a CRL (Certificate Revocation List) on the client, since it allows the client to refuse all certificates except for those associated with designated servers.
| |
--x509-trackattribute | |
Save peer X509attributevalue in environment for use by plugins and management interface. Prepend a+ toattributeto save values from full cert chain. Values will be encoded asX509_<depth>_<attribute>=<value> . Multiple--x509-trackoptions can be defined to track multiple attributes. | |
--x509-username-fieldargs | |
Field in the X.509 certificate subject to be used as the username (default Valid syntax: x509-username-field [ext:]fieldname Typically, this option is specified withfieldnameas either of the following: x509-username-field emailAddressx509-username-field ext:subjectAltName The first example uses the value of the When this option is used, the--verify-x509-nameoption will match against the chosenfieldnameinstead of the Common Name. Only the Please note:This option has a feature which will convert an all-lowercasefieldnameto uppercase characters, e.g., |
PKCS#11 / SmartCard options
--pkcs11-cert-privateargs | |
Set if access to certificate object should be performed after login. Every provider has its own setting. Valid syntaxes: pkcs11-cert-private 0pkcs11-cert-private 1 | |
--pkcs11-idname | |
Specify the serialized certificate id to be used. The id can be gotten by the standalone--show-pkcs11-idsoption. | |
--pkcs11-id-management | |
Acquire PKCS#11 id from management interface. In this case aNEED-STR 'pkcs11-id-request' real-time message will be triggered, application may use pkcs11-id-count command to retrieve available number of certificates, and pkcs11-id-get command to retrieve certificate id and certificate body. | |
--pkcs11-pin-cacheseconds | |
Specify how many seconds the PIN can be cached, the default is until the token is removed. | |
--pkcs11-private-modemode | |
Specify which method to use in order to perform private key operations. A different mode can be specified for each provider. Mode is encoded as hex number, and can be a mask one of the following:
| |
--pkcs11-protected-authenticationargs | |
Use PKCS#11 protected authentication path, useful for biometric and external keypad devices. Every provider has its own setting. Valid syntaxes: pkcs11-protected-authentication 0pkcs11-protected-authentication 1 | |
--pkcs11-providersprovider | |
Specify an RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) providers to load. This option can be used instead of--cert,--keyand--pkcs12. If p11-kit is present on the system, its | |
--show-pkcs11-idsargs | |
(Standalone) Show PKCS#11 token object list. Valid syntax: show-pkcs11 [provider] [cert_private] Specifycert_privateas Ifp11-kitis present on the system, theproviderargument is optional; if omitted the default --verboption can be used BEFORE this option to produce debugging information. |
OpenVPN 2.4 and higher have the capability to negotiate the data cipher that is used to encrypt data packets. This section describes the mechanism in more detail and the different backwards compatibility mechanism with older server and clients.
OpenVPN 2.5 and higher behaviour
When both client and server are at least running OpenVPN 2.5, that the order of the ciphers of the server's--data-ciphersis used to pick the the data cipher. That means that the first cipher in that list that is also in the client's--data-cipherslist is chosen. If no common cipher is found the client is rejected with a AUTH_FAILED message (as seen in client log):
AUTH: Received control message: AUTH_FAILED,Data channel cipher negotiation failed (no shared cipher)
OpenVPN 2.5 will only allow the ciphers specified in--data-ciphers. To ensure backwards compatibility also if a cipher is specified using the--cipheroption it is automatically added to this list. If both options are unset the default isAES-256-GCM:AES-128-GCM
.
OpenVPN 2.4 clients
The negotiation support in OpenVPN 2.4 was the first iteration of the implementation and still had some quirks. Its main goal was "upgrade to AES-256-GCM when possible". An OpenVPN 2.4 client that is built against a crypto library that supports AES in GCM mode and does not have--ncp-disablewill always announce support forAES-256-GCMandAES-128-GCMto a server by sendingIV_NCP=2
.
This only causes a problem if--ncp-ciphersoption has been changed from the default ofAES-256-GCM:AES-128-GCM
to a value that does not include these two ciphers. When a OpenVPN servers try to useAES-256-GCMorAES-128-GCMthe connection will then fail. It is therefore recommended to always have theAES-256-GCMandAES-128-GCMciphers to the--ncp-ciphersoptions to avoid this behaviour.
OpenVPN 3 clients
Clients based on the OpenVPN 3.x library (https://github.com/openvpn/openvpn3/) do not have a configurable--ncp-ciphersor--data-ciphersoption. Instead these clients will announce support for all their supported AEAD ciphers (AES-256-GCM,AES-128-GCMand in newer versions alsoChacha20-Poly1305).
To support OpenVPN 3.x based clients at least one of these ciphers needs to be included in the server's--data-ciphersoption.
OpenVPN 2.3 and older clients (and clients with--ncp-disable)
When a client without cipher negotiation support connects to a server the cipher specified with the--cipheroption in the client configuration must be included in the--data-ciphersoption of the server to allow the client to connect. Otherwise the client will be sent theAUTH_FAILEDmessage that indicates no shared cipher.
If the client is 2.3 or older and has been configured with the--enable-small./configure
argument, usingdata-ciphers-fallbackcipherin the server config file with the explicit cipher used by the client is necessary.
OpenVPN 2.4 server
When a client indicates support forAES-128-GCMandAES-256-GCM(withIV_NCP=2) an OpenVPN 2.4 server will send the first cipher of the--ncp-ciphersto the OpenVPN client regardless of what the cipher is. To emulate the behaviour of an OpenVPN 2.4 client as close as possible and have compatibility to a setup that depends on this quirk, addingAES-128-GCMandAES-256-GCMto the client's--data-ciphersoption is required. OpenVPN 2.5+ will only announce theIV_NCP=2flag if those ciphers are present.
OpenVPN 2.3 and older servers (and servers with--ncp-disable)
The cipher used by the server must be included in--data-ciphersto allow the client connecting to a server without cipher negotiation support. (For compatibility OpenVPN 2.5 will also accept the cipher set with--cipher)
If the server is 2.3 or older and has been configured with the--enable-small./configure
argument, addingdata-ciphers-fallbackcipherto the client config with the explicit cipher used by the server is necessary.
Blowfish in CBC mode (BF-CBC) deprecation
The--cipheroption defaulted toBF-CBCin OpenVPN 2.4 and older version. The default was never changed to ensure backwards compatibility. In OpenVPN 2.5 this behaviour has now been changed so that if the--cipheris not explicitly set it does not allow the weakBF-CBCcipher any more and needs to explicitly added as--cipherBFC-CBCor added to--data-ciphers.
We strongly recommend to switching away from BF-CBC to a more secure cipher as soon as possible instead.
OpenVPN consists of two sides of network configuration. One side is thelinkbetween the local and remote side, the other side is thevirtual network adapter(tun/tap device).
Link Options
This link options section covers options related to the connection between the local and the remote host.
--bindkeywords | |
Bind to local address and port. This is the default unless any of--prototcp-client,--http-proxyor--socks-proxyare used. If the optional | |
--float | Allow remote peer to change its IP address and/or port number, such as due to DHCP (this is the default if--remoteis not used).--floatwhen specified with--remoteallows an OpenVPN session to initially connect to a peer at a known address, however if packets arrive from a new address and pass all authentication tests, the new address will take control of the session. This is useful when you are connecting to a peer which holds a dynamic address such as a dial-in user or DHCP client. Essentially,--floattells OpenVPN to accept authenticated packets from any address, not only the address which was specified in the--remoteoption. |
--fragmentmax | Enable internal datagram fragmentation so that no UDP datagrams are sent which are larger thanmaxbytes. Themaxparameter is interpreted in the same way as the--link-mtuparameter, i.e. the UDP packet size after encapsulation overhead has been added in, but not including the UDP header itself. The--fragmentoption only makes sense when you are using the UDP protocol (--protoudp). --fragmentadds 4 bytes of overhead per datagram. See the--mssfixoption below for an important related option to--fragment. It should also be noted that this option is not meant to replace UDP fragmentation at the IP stack level. It is only meant as a last resort when path MTU discovery is broken. Using this option is less efficient than fixing path MTU discovery for your IP link and using native IP fragmentation instead. Having said that, there are circumstances where using OpenVPN's internal fragmentation capability may be your only option, such as tunneling a UDP multicast stream which requires fragmentation. |
--keepaliveargs | |
A helper directive designed to simplify the expression of--pingand--ping-restart. Valid syntax: keepalive interval timeout This option can be used on both client and server side, but it is enough to add this on the server side as it will push appropriate--pingand--ping-restartoptions to the client. If used on both server and client, the values pushed from server will override the client local values. Thetimeoutargument will be twice as long on the server side. This ensures that a timeout is detected on client side before the server side drops the connection. For example,--keepalive10 60expands as follows: if mode server: ping 10 # Argument: interval ping-restart 120 # Argument: timeout*2 push "ping 10" # Argument: interval push "ping-restart 60" # Argument: timeoutelse ping 10 # Argument: interval ping-restart 60 # Argument: timeout | |
--link-mtun | Sets an upper bound on the size of UDP packets which are sent between OpenVPN peers.It's best not to set this parameter unless you know what you're doing. |
--localhost | Local host name or IP address for bind. If specified, OpenVPN will bind to this address only. If unspecified, OpenVPN will bind to all interfaces. |
--lportport | Set local TCP/UDP port number or name. Cannot be used together with--nobindoption. |
--markvalue | Mark encrypted packets being sent with value. The mark value can be matched in policy routing and packetfilter rules. This option is only supported in Linux and does nothing on other operating systems. |
--modem | Set OpenVPN major mode. By default, OpenVPN runs in point-to-point mode (p2p ). OpenVPN 2.0 introduces a new mode (server ) which implements a multi-client server capability. |
--mssfixmax | Announce to TCP sessions running over the tunnel that they should limit their send packet sizes such that after OpenVPN has encapsulated them, the resulting UDP packet size that OpenVPN sends to its peer will not exceedmaxbytes. The default value is Themaxparameter is interpreted in the same way as the--link-mtuparameter, i.e. the UDP packet size after encapsulation overhead has been added in, but not including the UDP header itself. Resulting packet would be at most 28 bytes larger for IPv4 and 48 bytes for IPv6 (20/40 bytes for IP header and 8 bytes for UDP header). Default value of 1450 allows IPv4 packets to be transmitted over a link with MTU 1473 or higher without IP level fragmentation. The--mssfixoption only makes sense when you are using the UDP protocol for OpenVPN peer-to-peer communication, i.e.--protoudp. --mssfixand--fragmentcan be ideally used together, where--mssfixwill try to keep TCP from needing packet fragmentation in the first place, and if big packets come through anyhow (from protocols other than TCP),--fragmentwill internally fragment them. Both--fragmentand--mssfixare designed to work around cases where Path MTU discovery is broken on the network path between OpenVPN peers. The usual symptom of such a breakdown is an OpenVPN connection which successfully starts, but then stalls during active usage. If--fragmentand--mssfixare used together,--mssfixwill take its defaultmaxparameter from the--fragmentmaxoption. Therefore, one could lower the maximum UDP packet size to 1300 (a good first try for solving MTU-related connection problems) with the following options: --tun-mtu 1500 --fragment 1300 --mssfix |
--mtu-disctype | |
Should we do Path MTU discovery on TCP/UDP channel? Only supported on OSes such as Linux that supports the necessary system call to set. Valid types:
| |
--mtu-test | To empirically measure MTU on connection startup, add the--mtu-testoption to your configuration. OpenVPN will send ping packets of various sizes to the remote peer and measure the largest packets which were successfully received. The--mtu-testprocess normally takes about 3 minutes to complete. |
--nobind | Do not bind to local address and port. The IP stack will allocate a dynamic port for returning packets. Since the value of the dynamic port could not be known in advance by a peer, this option is only suitable for peers which will be initiating connections by using the --remote option. |
--passtos | Set the TOS field of the tunnel packet to what the payload's TOS is. |
--pingn | Ping remote over the TCP/UDP control channel if no packets have been sent for at leastnseconds (specify--pingon both peers to cause ping packets to be sent in both directions since OpenVPN ping packets are not echoed like IP ping packets). When used in one of OpenVPN's secure modes (where--secret,--tls-serveror--tls-clientis specified), the ping packet will be cryptographically secure. This option has two intended uses:
|
--ping-exitn | Causes OpenVPN to exit afternseconds pass without reception of a ping or other packet from remote. This option can be combined with--inactive,--pingand--ping-exitto create a two-tiered inactivity disconnect. For example, openvpn [options...] --inactive 3600 --ping 10 --ping-exit 60 when used on both peers will cause OpenVPN to exit within 60 seconds if its peer disconnects, but will exit after one hour if no actual tunnel data is exchanged. |
--ping-restartn | |
Similar to--ping-exit, but trigger a This option is useful in cases where the remote peer has a dynamic IP address and a low-TTL DNS name is used to track the IP address using a service such ashttps://www.nsupdate.info/+ a dynamic DNS client such asddclient. If the peer cannot be reached, a restart will be triggered, causing the hostname used with--remoteto be re-resolved (if--resolv-retryis also specified). In server mode,--ping-restart,--inactiveor any other type of internally generated signal will always be applied to individual client instance objects, never to whole server itself. Note also in server mode that any internally generated signal which would normally cause a restart, will cause the deletion of the client instance object instead. In client mode, the--ping-restartparameter is set to 120 seconds by default. This default will hold until the client pulls a replacement value from the server, based on the--keepalivesetting in the server configuration. To disable the 120 second default, set--ping-restart0on the client. See the signals section below for more information on Note that the behavior ofSIGUSR1can be modified by the--persist-tun,--persist-key,--persist-local-ipand--persist-remote-ipoptions. Also note that--ping-exitand--ping-restartare mutually exclusive and cannot be used together. | |
--ping-timer-rem | |
Run the--ping-exit/--ping-restarttimer only if we have a remote address. Use this option if you are starting the daemon in listen mode (i.e. without an explicit--remotepeer), and you don't want to start clocking timeouts until a remote peer connects. | |
--protop | Use protocolpfor communicating with remote host.pcan be The default protocol is For UDP operation,--protoudpshould be specified on both peers. For TCP operation, one peer must use--prototcp-serverand the other must use--prototcp-client. A peer started with OpenVPN is designed to operate optimally over UDP, but TCP capability is provided for situations where UDP cannot be used. In comparison with UDP, TCP will usually be somewhat less efficient and less robust when used over unreliable or congested networks. This article outlines some of problems with tunneling IP over TCP:http://sites.inka.de/sites/bigred/devel/tcp-tcp.html There are certain cases, however, where using TCP may be advantageous from a security and robustness perspective, such as tunneling non-IP or application-level UDP protocols, or tunneling protocols which don't possess a built-in reliability layer. |
--portport | TCP/UDP port number or port name for both local and remote (sets both--lportand--rportoptions to given port). The current default of 1194 represents the official IANA port number assignment for OpenVPN and has been used since version 2.0-beta17. Previous versions used port 5000 as the default. |
--rportport | Set TCP/UDP port number or name used by the--remoteoption. The port can also be set directly using the--remoteoption. |
--replay-windowargs | |
Modify the replay protection sliding-window size and time window. Valid syntax: replay-window n [t] Use a replay protection sliding-window of sizenand a time window oftseconds. By defaultnis 64 (the IPSec default) andtis 15 seconds. This option is only relevant in UDP mode, i.e. when either--proto udpis specified, or no--protooption is specified. When OpenVPN tunnels IP packets over UDP, there is the possibility that packets might be dropped or delivered out of order. Because OpenVPN, like IPSec, is emulating the physical network layer, it will accept an out-of-order packet sequence, and will deliver such packets in the same order they were received to the TCP/IP protocol stack, provided they satisfy several constraints.
If you are using a network link with a large pipeline (meaning that the product of bandwidth and latency is high), you may want to use a larger value forn. Satellite links in particular often require this. If you run OpenVPN at--verb4, you will see the message "PID_ERR replay-window backtrack occurred [x]" every time the maximum sequence number backtrack seen thus far increases. This can be used to calibraten. There is some controversy on the appropriate method of handling packet reordering at the security layer. Namely, to what extent should the security layer protect the encapsulated protocol from attacks which masquerade as the kinds of normal packet loss and reordering that occur over IP networks? The IPSec and OpenVPN approach is to allow packet reordering within a certain fixed sequence number window. OpenVPN adds to the IPSec model by limiting the window size in time as well as sequence space. OpenVPN also adds TCP transport as an option (not offered by IPSec) in which case OpenVPN can adopt a very strict attitude towards message deletion and reordering: Don't allow it. Since TCP guarantees reliability, any packet loss or reordering event can be assumed to be an attack. In this sense, it could be argued that TCP tunnel transport is preferred when tunneling non-IP or UDP application protocols which might be vulnerable to a message deletion or reordering attack which falls within the normal operational parameters of IP networks. So I would make the statement that one should never tunnel a non-IP protocol or UDP application protocol over UDP, if the protocol might be vulnerable to a message deletion or reordering attack that falls within the normal operating parameters of what is to be expected from the physical IP layer. The problem is easily fixed by simply using TCP as the VPN transport layer. | |
--replay-persistfile | |
Persist replay-protection state across sessions usingfileto save and reload the state. This option will strengthen protection against replay attacks, especially when you are using OpenVPN in a dynamic context (such as with--inetd) when OpenVPN sessions are frequently started and stopped. This option will keep a disk copy of the current replay protection state (i.e. the most recent packet timestamp and sequence number received from the remote peer), so that if an OpenVPN session is stopped and restarted, it will reject any replays of packets which were already received by the prior session. This option only makes sense when replay protection is enabled (the default) and you are using either--secret(shared-secret key mode) or TLS mode with--tls-auth. | |
--socket-flagsflags | |
Apply the given flags to the OpenVPN transport socket. Currently, only The This option is pushable from server to client, and should be used on both client and server for maximum effect. | |
--tcp-nodelay | This macro sets the The macro expands as follows: if mode server: socket-flags TCP_NODELAY push "socket-flags TCP_NODELAY" |
Virtual Network Adapter (VPN interface)
Options in this section relates to configuration of the virtual tun/tap network interface, including setting the VPN IP address and network routing.
--bind-devdevice | |
(Linux only) Setdeviceto bind the server socket to aVirtual Routing and Forwardingdevice | |
--block-ipv6 | On the client, instead of sending IPv6 packets over the VPN tunnel, all IPv6 packets are answered with an ICMPv6 no route host message. On the server, all IPv6 packets from clients are answered with an ICMPv6 no route to host message. This options is intended for cases when IPv6 should be blocked and other options are not available.--block-ipv6will use the remote IPv6 as source address of the ICMPv6 packets if set, otherwise will use For this option to make sense you actually have to route traffic to the tun interface. The following example config block would send all IPv6 traffic to OpenVPN and answer all requests with no route to host, effectively blocking IPv6 (to avoid IPv6 connections from dual-stacked clients leaking around IPv4-only VPN services).
Note: this option does not influence traffic sent from the server towards the client (neither on the server nor on the client side). This is not seen as necessary, as such traffic can be most easily avoided by not configuring IPv6 on the server tun, or setting up a server-side firewall rule. |
--devdevice | TUN/TAP virtual network device which can be See examples section below for an example on setting up a TUN device. You must use either tun devices on both ends of the connection or tap devices on both ends. You cannot mix them, as they represent different underlying network layers:
Valid syntaxes: dev tun2dev tap4dev ovpn When the device name starts with |
--dev-nodenode | |
Explicitly set the device node rather than using Under Mac OS X this option can be used to specify the default tun implementation. Using--dev-nodeutunforces usage of the native Darwin tun kernel support. Use--dev-nodeutunNto select a specific utun instance. To force using the On Windows systems, select the TAP-Win32 adapter which is namednodein the Network Connections Control Panel or the raw GUID of the adapter enclosed by braces. The--show-adaptersoption under Windows can also be used to enumerate all available TAP-Win32 adapters and will show both the network connections control panel name and the GUID for each TAP-Win32 adapter. | |
--dev-typedevice-type | |
Which device type are we using?device-typeshould betun (OSI Layer 3) ortap (OSI Layer 2). Use this option only if the TUN/TAP device used with--devdoes not begin withtun ortap . | |
--dhcp-optionargs | |
Set additional network parameters on supported platforms. May be specified on the client or pushed from the server. On Windows these options are handled by thetap-windows6driver by default or directly by OpenVPN if dhcp is disabled or thewintundriver is in use. TheOpenVPN for Androidclient also handles them internally. On all other platforms these options are only saved in the client's environment under the name Valid syntax: dhcp-options type [parm]
| |
--ifconfigargs | |
Set TUN/TAP adapter parameters. It requires theIP addressof the local VPN endpoint. For TUN devices in point-to-point mode, the next argument must be the VPN IP address of the remote VPN endpoint. For TAP devices, or TUN devices used with--topologysubnet, the second argument is the subnet mask of the virtual network segment which is being created or connected to. For TUN devices, which facilitate virtual point-to-point IP connections (when used in--topologynet30orp2pmode), the proper usage of--ifconfigis to use two private IP addresses which are not a member of any existing subnet which is in use. The IP addresses may be consecutive and should have their order reversed on the remote peer. After the VPN is established, by pingingrn, you will be pinging across the VPN. For TAP devices, which provide the ability to create virtual ethernet segments, or TUN devices in--topologysubnetmode (which create virtual "multipoint networks"),--ifconfigis used to set an IP address and subnet mask just as a physical ethernet adapter would be similarly configured. If you are attempting to connect to a remote ethernet bridge, the IP address and subnet should be set to values which would be valid on the the bridged ethernet segment (note also that DHCP can be used for the same purpose). This option, while primarily a proxy for theifconfig(8) command, is designed to simplify TUN/TAP tunnel configuration by providing a standard interface to the different ifconfig implementations on different platforms. --ifconfigparameters which are IP addresses can also be specified as a DNS or /etc/hosts file resolvable name. For TAP devices,--ifconfigshould not be used if the TAP interface will be getting an IP address lease from a DHCP server. Examples: # tun device in net30/p2p modeifconfig 10.8.0.2 10.8.0.1# tun/tap device in subnet modeifconfig 10.8.0.2 255.255.255.0 | |
--ifconfig-ipv6args | |
Configure an IPv6 address on thetundevice. Valid syntax: ifconfig-ipv6 ipv6addr/bits [ipv6remote] Theipv6addr/bitsargument is the IPv6 address to use. The second parameter is used as route target for--route-ipv6if no gateway is specified. The--topologyoption has no influence with--ifconfig-ipv6 | |
--ifconfig-noexec | |
Don't actually execute ifconfig/netsh commands, instead pass--ifconfigparameters to scripts using environmental variables. | |
--ifconfig-nowarn | |
Don't output an options consistency check warning if the--ifconfigoption on this side of the connection doesn't match the remote side. This is useful when you want to retain the overall benefits of the options consistency check (also see--disable-occoption) while only disabling the ifconfig component of the check. For example, if you have a configuration where the local host uses--ifconfigbut the remote host does not, use--ifconfig-nowarnon the local host. This option will also silence warnings about potential address conflicts which occasionally annoy more experienced users by triggering "false positive" warnings. | |
--lladdraddress | |
Specify the link layer address, more commonly known as the MAC address. Only applied to TAP devices. | |
--persist-tun | Don't close and reopen TUN/TAP device or run up/down scripts across
|
--redirect-gatewayflags | |
Automatically execute routing commands to cause all outgoing IP traffic to be redirected over the VPN. This is a client-side option. This option performs three steps:
When the tunnel is torn down, all of the above steps are reversed so that the original default route is restored. Option flags:
| |
--redirect-privateflags | |
Like--redirect-gateway, but omit actually changing the default gateway. Useful when pushing private subnets. | |
--routeargs | Add route to routing table after connection is established. Multiple routes can be specified. Routes will be automatically torn down in reverse order prior to TUN/TAP device close. Valid syntaxes: route network/IProute network/IP netmaskroute network/IP netmask gatewayroute network/IP netmask gateway metric This option is intended as a convenience proxy for theroute(8) shell command, while at the same time providing portable semantics across OpenVPN's platform space.
The default can be specified by leaving an option blank or setting it to Thenetworkandgatewayparameters can also be specified as a DNS or
|
--route-delayargs | |
Valid syntaxes: route-delayroute-delay nroute-delay n m Delaynseconds (default This option is designed to be useful in scenarios where DHCP is used to set tap adapter addresses. The delay will give the DHCP handshake time to complete before routes are added. On Windows,--route-delaytries to be more intelligent by waitingwseconds (default | |
--route-ipv6args | |
Setup IPv6 routing in the system to send the specified IPv6 network into OpenVPN'stun. Valid syntax: route-ipv6 ipv6addr/bits [gateway] [metric] The gateway parameter is only used for IPv6 routes acrosstapdevices, and if missing, theipv6remotefield from--ifconfig-ipv6or--route-ipv6-gatewayis used. | |
--route-gatewayarg | |
Specify a defaultgatewayfor use with--route. If Valid syntaxes: route-gateway gatewayroute-gateway dhcp | |
--route-ipv6-gatewaygw | |
Specify a default gatewaygwfor use with--route-ipv6. | |
--route-metricm | |
Specify a default metricmfor use with--route. | |
--route-noexec | Don't add or remove routes automatically. Instead pass routes to--route-upscript using environmental variables. |
--route-nopull | When used with--clientor--pull, accept options pushed by server EXCEPT for routes, block-outside-dns and dhcp options like DNS servers. When used on the client, this option effectively bars the server from adding routes to the client's routing table, however note that this option still allows the server to set the TCP/IP properties of the client's TUN/TAP interface. |
--topologymode | |
Configure virtual addressing topology when running in--devtunmode. This directive has no meaning in--devtapmode, which always uses a If you set this directive on the server, the--serverand--server-bridgedirectives will automatically push your chosen topology setting to clients as well. This directive can also be manually pushed to clients. Like the--devdirective, this directive must always be compatible between client and server. modecan be one of:
Note:Using--topologysubnetchanges the interpretation of the arguments of--ifconfigto mean "address netmask", no longer "local remote". | |
--tun-mtun | Take the TUN device MTU to benand derive the link MTU from it (default The MTU (Maximum Transmission Units) is the maximum datagram size in bytes that can be sent unfragmented over a particular network path. OpenVPN requires that packets on the control and data channels be sent unfragmented. MTU problems often manifest themselves as connections which hang during periods of active usage. It's best to use the--fragmentand/or--mssfixoptions to deal with MTU sizing issues. |
--tun-mtu-extran | |
Assume that the TUN/TAP device might return as many asnbytes more than the--tun-mtusize on read. This parameter defaults to 0, which is sufficient for most TUN devices. TAP devices may introduce additional overhead in excess of the MTU size, and a setting of 32 is the default when TAP devices are used. This parameter only controls internal OpenVPN buffer sizing, so there is no transmission overhead associated with using a larger value. |
TUN/TAP standalone operations
These two standalone operations will require--devand optionally--userand/or--group.
--mktun | (Standalone) Create a persistent tunnel on platforms which support them such as Linux. Normally TUN/TAP tunnels exist only for the period of time that an application has them open. This option takes advantage of the TUN/TAP driver's ability to build persistent tunnels that live through multiple instantiations of OpenVPN and die only when they are deleted or the machine is rebooted. One of the advantages of persistent tunnels is that they eliminate the need for separate--upand--downscripts to run the appropriateifconfig(8) androute(8) commands. These commands can be placed in the the same shell script which starts or terminates an OpenVPN session. Another advantage is that open connections through the TUN/TAP-based tunnel will not be reset if the OpenVPN peer restarts. This can be useful to provide uninterrupted connectivity through the tunnel in the event of a DHCP reset of the peer's public IP address (see the--ipchangeoption above). One disadvantage of persistent tunnels is that it is harder to automatically configure their MTU value (see--link-mtuand--tun-mtuabove). On some platforms such as Windows, TAP-Win32 tunnels are persistent by default. |
--rmtun | (Standalone) Remove a persistent tunnel. |
Virtual Routing and Forwarding
Options in this section relates to configuration of virtual routing and forwarding in combination with the underlying operating system.
As of today this is only supported on Linux, a kernel >= 4.9 is recommended.
This could come in handy when for example the external network should be only used as a means to connect to some VPN endpoints and all regular traffic should only be routed through any tunnel(s). This could be achieved by setting up a VRF and configuring the interface connected to the external network to be part of the VRF. The examples below will cover this setup.
Another option would be to put the tun/tap interface into a VRF. This could be done by an up-script which uses theip link set
command shown below.
VRF setup with iproute2
Create VRFvrf_external
and map it to routing table1023
ip link add vrf_external type vrf table 1023
Moveeth0
intovrf_external
ip link set master vrf_external dev eth0
Any prefixes configured oneth0
will be moved from the :code`main` routing table into routing table1023
VRF setup with ifupdown
For Debian based Distributionsifupdown2
provides an almost drop-in replacement forifupdown
including VRFs and other features. A configuration for an interfaceeth0
being part of VRF code:vrf_externalcould look like this:
auto eth0iface eth0 address 192.0.2.42/24 address 2001:db8:08:15::42/64 gateway 192.0.2.1 gateway 2001:db8:08:15::1 vrf vrf_externalauto vrf_externaliface vrf_external vrf-table 1023
OpenVPN configuration
The OpenVPN configuration needs to contain this line:
bind-dev vrf_external
Further reading
Wikipedia has nice page one VRFs:https://en.wikipedia.org/wiki/Virtual_routing_and_forwarding
This talk from the Network Track of FrOSCon 2018 provides an overview about advanced layer 2 and layer 3 features of Linux
OpenVPN can execute external scripts in various phases of the lifetime of the OpenVPN process.
Script Order of Execution
--up
Executed after TCP/UDP socket bind and TUN/TAP open.
--tls-verify
Executed when we have a still untrusted remote peer.
--ipchange
Executed after connection authentication, or remote IP address change.
--client-connect
Executed in--mode servermode immediately after client authentication.
--route-up
Executed after connection authentication, either immediately after, or some number of seconds after as defined by the--route-delayoption.
--route-pre-down
Executed right before the routes are removed.
--client-disconnect
Executed in--modeservermode on client instance shutdown.
--down
Executed after TCP/UDP and TUN/TAP close.
--learn-address
Executed in--modeservermode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table.
--auth-user-pass-verify
Executed in--modeservermode on new client connections, when the client is still untrusted.
SCRIPT HOOKS
--auth-user-pass-verifyargs | |
Require the client to provide a username/password (possibly in addition to a client certificate) for authentication. Valid syntax: auth-user-pass-verify cmd method OpenVPN will run commandcmdto validate the username/password provided by the client. cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. Ifmethodis set to Ifmethodis set to The script should examine the username and password, returning a success exit code ( This directive is designed to enable a plugin-style interface for extending OpenVPN's authentication capabilities. To protect against a client passing a maliciously formed username or password string, the username string must consist only of these characters: alphanumeric, underbar (' Care must be taken by any user-defined scripts to avoid creating a security vulnerability in the way that these strings are handled. Never use these strings in such a way that they might be escaped or evaluated by a shell interpreter. For a sample script that performs PAM authentication, see | |
--client-connectcmd | |
Run commandcmdon client connection. cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. The command is passed the common name and IP address of the just-authenticated client as environmental variables (see environmental variable section below). The command is also passed the pathname of a freshly created temporary file as the last argument (after any arguments specified incmd), to be used by the command to pass dynamically generated config file directives back to OpenVPN. If the script wants to generate a dynamic config file to be applied on the server when the client connects, it should write it to the file named by the last argument. See the--client-config-diroption below for options which can be legally used in a dynamically generated config file. Note that the return value ofscriptis significant. Ifscriptreturns a non-zero error status, it will cause the client to be disconnected. If a--client-connectwants to defer the generating of the configuration then the script needs to use the | |
--client-disconnectcmd | |
Like--client-connectbut called on client instance shutdown. Will not be called unless the--client-connectscript and plugins (if defined) were previously called on this instance with successful (0) status returns. The exception to this rule is if the--client-disconnectcommand or plugins are cascaded, and at least one client-connect function succeeded, then ALL of the client-disconnect functions for scripts and plugins will be called on client instance object deletion, even in cases where some of the related client-connect functions returned an error status. The--client-disconnectcommand is not passed any extra arguments (only those arguments specified in cmd, if any). | |
--downcmd | Run commandcmdafter TUN/TAP device close (post--userUID change and/or--chroot).cmdconsists of a path to script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. Called with the same parameters and environmental variables as the--upoption above. Note that if you reduce privileges by using--userand/or--group, your--downscript will also run at reduced privilege. |
--down-pre | Call--downcmd/script before, rather than after, TUN/TAP close. |
--ipchangecmd | Run commandcmdwhen our remote ip-address is initially authenticated or changes. cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. Whencmdis executed two arguments are appended after any arguments specified incmd, as follows: cmd ip address port number Don't use--ipchangein--modeservermode. Use a--client-connectscript instead. See theEnvironmental Variablessection below for additional parameters passed as environmental variables. If you are running in a dynamic IP address environment where the IP addresses of either peer could change without notice, you can use this script, for example, to edit the Similarly ifourIP address changes due to DHCP, we should configure our IP address change script (see man page fordhcpcd(8)) to deliver aSIGHUPorSIGUSR1signal to OpenVPN. OpenVPN will then re-establish a connection with its most recently authenticated peer on its new IP address. |
--learn-addresscmd | |
Run commandcmdto validate client virtual addresses or routes. cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. Three arguments will be appended to any arguments incmdas follows:
On Normally, thecmdscript will use the information provided above to set appropriate firewall entries on the VPN TUN/TAP interface. Since OpenVPN provides the association between virtual IP or MAC address and the client's authenticated common name, it allows a user-defined script to configure firewall access policies with regard to the client's high-level common name, rather than the low level client virtual addresses. | |
--route-upcmd | Run commandcmdafter routes are added, subject to--route-delay. cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. See theEnvironmental Variablessection below for additional parameters passed as environmental variables. |
--route-pre-downcmd | |
Run commandcmdbefore routes are removed upon disconnection. cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. See theEnvironmental Variablessection below for additional parameters passed as environmental variables. | |
--setenvargs | Set a custom environmental variable Valid syntaxes: setenv name valuesetenv FORWARD_COMPATIBLE 1setenv opt config_option By setting 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. It is also possible to tag a single directive so as not to trigger a fatal error if the directive isn't recognized. To do this, prepend the following before the directive:setenv opt Versions prior to OpenVPN 2.3.3 will always ignore options set with thesetenv optdirective. See also--ignore-unknown-option |
--setenv-safeargs | |
Set a custom environmental variable Valid syntaxes: setenv-safe name value This directive is designed to be pushed by the server to clients, and the prepending of | |
--tls-verifycmd | |
Run commandcmdto verify the X509 name of a pending TLS connection that has otherwise passed all other tests of certification (except for revocation via--crl-verifydirective; the revocation test occurs after the--tls-verifytest). cmdshould return cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. Whencmdis executed two arguments are appended after any arguments specified incmd, as follows: cmd certificate_depth subject These arguments are, respectively, the current certificate depth and the X509 subject distinguished name (dn) of the peer. This feature is useful if the peer you want to trust has a certificate which was signed by a certificate authority who also signed many other certificates, where you don't necessarily want to trust all of them, but rather be selective about which peer certificate you will accept. This feature allows you to write a script which will test the X509 name on a certificate and decide whether or not it should be accepted. For a simple perl script which will test the common name field on the certificate, see the fileverify-cnin the OpenVPN distribution. See theEnvironmental Variablessection below for additional parameters passed as environmental variables. | |
--upcmd | Run commandcmdafter successful TUN/TAP device open (pre--userUID change). cmdconsists of a path to a script (or executable program), optionally followed by arguments. The path and arguments may be single- or double-quoted and/or escaped using a backslash, and should be separated by one or more spaces. The up command is useful for specifying route commands which route IP traffic destined for private subnets which exist at the other end of the VPN connection into the tunnel. For--devtunexecute as: cmd tun_dev tun_mtu link_mtu ifconfig_local_ip ifconfig_remote_ip [init | restart] For--devtapexecute as: cmd tap_dev tap_mtu link_mtu ifconfig_local_ip ifconfig_netmask [init | restart] See theEnvironmental Variablessection below for additional parameters passed as environmental variables. Note that ifcmdincludes arguments, all OpenVPN-generated arguments will be appended to them to build an argument list with which the executable will be called. Typically,cmdwill run a script to add routes to the tunnel. Normally the up script is called after the TUN/TAP device is opened. In this context, the last command line parameter passed to the script will beinit.If the--up-restartoption is also used, the up script will be called for restarts as well. A restart is considered to be a partial reinitialization of OpenVPN where the TUN/TAP instance is preserved (the--persist-tunoption will enable such preservation). A restart can be generated by a SIGUSR1 signal, a--ping-restarttimeout, or a connection reset when the TCP protocol is enabled with the--protooption. If a restart occurs, and--up-restarthas been specified, the up script will be called withrestartas the last parameter.
The following standalone example shows how the--upscript can be called in both an initialization and restart context. (NOTE:for security reasons, don't run the following example unless UDP port 9999 is blocked by your firewall. Also, the example will run indefinitely, so you should abort with control-c). openvpn --dev tun --port 9999 --verb 4 --ping-restart 10 \ --up 'echo up' --down 'echo down' --persist-tun \ --up-restart Note that OpenVPN also provides the--ifconfigoption to automatically ifconfig the TUN device, eliminating the need to define an--upscript, unless you also want to configure routes in the--upscript. If--ifconfigis also specified, OpenVPN will pass the ifconfig local and remote endpoints on the command line to the--upscript so that they can be used to configure routes such as: route add -net 10.0.0.0 netmask 255.255.255.0 gw $5 |
--up-delay | Delay TUN/TAP open and possible--upscript execution until after TCP/UDP connection establishment with peer. In--protoudpmode, this option normally requires the use of--pingto allow connection initiation to be sensed in the absence of tunnel data, since UDP is a "connectionless" protocol. On Windows, this option will delay the TAP-Win32 media state transitioning to "connected" until connection establishment, i.e. the receipt of the first authenticated packet from the peer. |
--up-restart | Enable the--upand--downscripts to be called for restarts as well as initial program start. This option is described more fully above in the--upoption documentation. |
String Types and Remapping
In certain cases, OpenVPN will perform remapping of characters in strings. Essentially, any characters outside the set of permitted characters for each string type will be converted to underbar ('_').
- Q: Why is string remapping necessary?
- It's an important security feature to prevent the malicious coding of strings from untrusted sources to be passed as parameters to scripts, saved in the environment, used as a common name, translated to a filename, etc.
- Q: Can string remapping be disabled?
- Yes, by using the--no-name-remappingoption, however this should be considered an advanced option.
Here is a brief rundown of OpenVPN's current string types and the permitted character class for each string:
- X509 Names
- Alphanumeric, underbar ('_'), dash ('-'), dot ('.'), at ('@'), colon (':'), slash ('/'), and equal ('='). Alphanumeric is defined as a character which will cause the C library isalnum() function to return true.
- Common Names
- Alphanumeric, underbar ('_'), dash ('-'), dot ('.'), and at ('@').
- --auth-user-pass username
- Same as Common Name, with one exception: starting with OpenVPN 2.0.1, the username is passed to the
OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY
plugin in its raw form, without string remapping. - --auth-user-pass password
- Any "printable" character except CR or LF. Printable is defined to be a character which will cause the C library isprint() function to return true.
- --client-config-dir filename as derived from common name or`username
- Alphanumeric, underbar ('_'), dash ('-'), and dot ('.') except for "." or ".." as standalone strings. As of v2.0.1-rc6, the at ('@') character has been added as well for compatibility with the common name character class.
- Environmental variable names
- Alphanumeric or underbar ('_').
- Environmental variable values
- Any printable character.
For all cases, characters in a string which are not members of the legal character class for that string type will be remapped to underbar ('_').
Environmental Variables
Once set, a variable is persisted indefinitely until it is reset by a new value or a restart,
As of OpenVPN 2.0-beta12, in server mode, environmental variables set by OpenVPN are scoped according to the client objects they are associated with, so there should not be any issues with scripts having access to stale, previously set variables which refer to different client instances.
bytes_received
- Total number of bytes received from client during VPN session. Set prior to execution of the--client-disconnectscript.
bytes_sent
- Total number of bytes sent to client during VPN session. Set prior to execution of the--client-disconnectscript.
client_connect_config_file
- The path to the configuration file that should be written to by the--client-connectscript (optional, if per-session configuration is desired). This is the same file name as passed via command line argument on the call to the--client-connectscript.
client_connect_deferred_file
This file can be optionally written to in order to to communicate a status code of the--client-connectscript or plgin. Only the first character in the file is relevant. It must be either
1
to indicate normal script execution,0
indicates an error (in the same way that a non zero exit status does) or2
to indicate that the script deferred returning the config file.For deferred (background) handling, the script or plugin MUST write
2
to the file to indicate the deferral and then return with exit code0
to signaldeferred handler started OK.A background process or similar must then take care of writing the configuration to the file indicated by the
client_connect_config_file
environment variable and when finished, write the a1
to this file (or0
in case of an error).The absence of any character in the file when the script finishes executing is interpreted the same as
1
. This allows scripts that are not written to support the defer mechanism to be used unmodified.common_name
- The X509 common name of an authenticated client. Set prior to execution of--client-connect,--client-disconnectand--auth-user-pass-verifyscripts.
config
- Name of first--configfile. Set on program initiation and reset on SIGHUP.
daemon
- Set to "1" if the--daemondirective is specified, or "0" otherwise. Set on program initiation and reset on SIGHUP.
daemon_log_redirect
- Set to "1" if the--logor--log-appenddirectives are specified, or "0" otherwise. Set on program initiation and reset on SIGHUP.
dev
- The actual name of the TUN/TAP device, including a unit number if it exists. Set prior to--upor--downscript execution.
dev_idx
- On Windows, the device index of the TUN/TAP adapter (to be used in netsh.exe calls which sometimes just do not work right with interface names). Set prior to--upor--downscript execution.
foreign_option_{n}
- An option pushed via--pushto a client which does not natively support it, such as--dhcp-optionon a non-Windows system, will be recorded to this environmental variable sequence prior to--upscript execution.
ifconfig_broadcast
- The broadcast address for the virtual ethernet segment which is derived from the--ifconfigoption when--devtapis used. Set prior to OpenVPN calling the
ifconfig
ornetsh
(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_ipv6_local
- The local VPN endpoint IPv6 address specified in the--ifconfig-ipv6option (first parameter). Set prior to OpenVPN calling the
ifconfig
or code:netsh(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_ipv6_netbits
- The prefix length of the IPv6 network on the VPN interface. Derived from the /nnn parameter of the IPv6 address in the--ifconfig-ipv6option (first parameter). Set prior to OpenVPN calling the
ifconfig
ornetsh
(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_ipv6_remote
- The remote VPN endpoint IPv6 address specified in the--ifconfig-ipv6option (second parameter). Set prior to OpenVPN calling the
ifconfig
ornetsh
(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_local
- The local VPN endpoint IP address specified in the--ifconfigoption (first parameter). Set prior to OpenVPN calling the
ifconfig
ornetsh
(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_remote
- The remote VPN endpoint IP address specified in the--ifconfigoption (second parameter) when--devtunis used. Set prior to OpenVPN calling the
ifconfig
ornetsh
(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_netmask
- The subnet mask of the virtual ethernet segment that is specified as the second parameter to--ifconfigwhen--devtapis being used. Set prior to OpenVPN calling the
ifconfig
ornetsh
(windows version of ifconfig) commands which normally occurs prior to--upscript execution. ifconfig_pool_local_ip
- The local virtual IP address for the TUN/TAP tunnel taken from an--ifconfig-pushdirective if specified, or otherwise from the ifconfig pool (controlled by the--ifconfig-poolconfig file directive). Only set for--devtuntunnels. This option is set on the server prior to execution of the--client-connectand--client-disconnectscripts.
ifconfig_pool_netmask
- The virtual IP netmask for the TUN/TAP tunnel taken from an--ifconfig-pushdirective if specified, or otherwise from the ifconfig pool (controlled by the--ifconfig-poolconfig file directive). Only set for--devtaptunnels. This option is set on the server prior to execution of the--client-connectand--client-disconnectscripts.
ifconfig_pool_remote_ip
- The remote virtual IP address for the TUN/TAP tunnel taken from an--ifconfig-pushdirective if specified, or otherwise from the ifconfig pool (controlled by the--ifconfig-poolconfig file directive). This option is set on the server prior to execution of the--client-connectand--client-disconnectscripts.
link_mtu
- The maximum packet size (not including the IP header) of tunnel data in UDP tunnel transport mode. Set prior to--upor--downscript execution.
local
- The--localparameter. Set on program initiation and reset on SIGHUP.
local_port
- The local port number or name, specified by--portor--lport. Set on program initiation and reset on SIGHUP.
password
- The password provided by a connecting client. Set prior to--auth-user-pass-verifyscript execution only when thevia-envmodifier is specified, and deleted from the environment after the script returns.
proto
- The--protoparameter. Set on program initiation and reset on SIGHUP.
remote_{n}
- The--remoteparameter. Set on program initiation and reset on SIGHUP.
remote_port_{n}
- The remote port number, specified by--portor--rport. Set on program initiation and reset on SIGHUP.
route_net_gateway
- The pre-existing default IP gateway in the system routing table. Set prior to--upscript execution.
route_vpn_gateway
- The default gateway used by--routeoptions, as specified in either the--route-gatewayoption or the second parameter to--ifconfigwhen--devtunis specified. Set prior to--upscript execution.
route_{parm}_{n}
A set of variables which define each route to be added, and are set prior to--upscript execution.
parmwill be one of
network
,netmask"
,gateway
, ormetric
.nis the OpenVPN route number, starting from 1.
If the network or gateway are resolvable DNS names, their IP address translations will be recorded rather than their names as denoted on the command line or configuration file.
route_ipv6_{parm}_{n}
A set of variables which define each IPv6 route to be added, and are set prior to--upscript execution.
parmwill be one of
network
,gateway
ormetric
.route_ipv6_network_{n}containsnetmask
as/nnn
, unlike IPv4 where it is passed in a separate environment variable.nis the OpenVPN route number, starting from 1.
If the network or gateway are resolvable DNS names, their IP address translations will be recorded rather than their names as denoted on the command line or configuration file.
peer_cert
- Temporary file name containing the client certificate upon connection. Useful in conjunction with--tls-verify.
script_context
- Set to "init" or "restart" prior to up/down script execution. For more information, see documentation for--up.
script_type
- Prior to execution of any script, this variable is set to the type of script being run. It can be one of the following:
up
,down
,ipchange
,route-up
,tls-verify
,auth-user-pass-verify
,client-connect
,client-disconnect
orlearn-address
. Set prior to execution of any script. signal
- The reason for exit or restart. Can be one of
sigusr1
,sighup
,sigterm
,sigint
,inactive
(controlled by--inactiveoption),ping-exit
(controlled by--ping-exitoption),ping-restart
(controlled by--ping-restartoption),connection-reset
(triggered on TCP connection reset),error
orunknown
(unknown signal). This variable is set just prior to down script execution. time_ascii
- Client connection timestamp, formatted as a human-readable time string. Set prior to execution of the--client-connectscript.
time_duration
- The duration (in seconds) of the client session which is now disconnecting. Set prior to execution of the--client-disconnectscript.
time_unix
- Client connection timestamp, formatted as a unix integer date/time value. Set prior to execution of the--client-connectscript.
tls_digest_{n}
/tls_digest_sha256_{n}
- Contains the certificate SHA1 / SHA256 fingerprint, wherenis the verification level. Only set for TLS connections. Set prior to execution of--tls-verifyscript.
tls_id_{n}
- A series of certificate fields from the remote peer, wherenis the verification level. Only set for TLS connections. Set prior to execution of--tls-verifyscript.
tls_serial_{n}
- The serial number of the certificate from the remote peer, wherenis the verification level. Only set for TLS connections. Set prior to execution of--tls-verifyscript. This is in the form of a decimal string like "933971680", which is suitable for doing serial-based OCSP queries (with OpenSSL, do not prepend "0x" to the string) If something goes wrong while reading the value from the certificate it will be an empty string, so your code should check that. See the
contrib/OCSP_check/OCSP_check.sh
script for an example. tls_serial_hex_{n}
- Like
tls_serial_{n}
, but in hex form (e.g.12:34:56:78:9A
). tun_mtu
- The MTU of the TUN/TAP device. Set prior to--upor--downscript execution.
trusted_ip
/trusted_ip6
)- Actual IP address of connecting client or peer which has been authenticated. Set prior to execution of--ipchange,--client-connectand--client-disconnectscripts. If using ipv6 endpoints (udp6, tcp6),
trusted_ip6
will be set instead. trusted_port
- Actual port number of connecting client or peer which has been authenticated. Set prior to execution of--ipchange,--client-connectand--client-disconnectscripts.
untrusted_ip
/untrusted_ip6
- Actual IP address of connecting client or peer which has not been authenticated yet. Sometimes used tonmapthe connecting host in a--tls-verifyscript to ensure it is firewalled properly. Set prior to execution of--tls-verifyand--auth-user-pass-verifyscripts. If using ipv6 endpoints (udp6, tcp6),
untrusted_ip6
will be set instead. untrusted_port
- Actual port number of connecting client or peer which has not been authenticated yet. Set prior to execution of--tls-verifyand--auth-user-pass-verifyscripts.
username
- The username provided by a connecting client. Set prior to--auth-user-pass-verifyscript execution only when the
via-env
modifier is specified. X509_{n}_{subject_field}
An X509 subject field from the remote peer certificate, wherenis the verification level. Only set for TLS connections. Set prior to execution of--tls-verifyscript. This variable is similar to
tls_id_{n}
except the component X509 subject fields are broken out, and no string remapping occurs on these field values (except for remapping of control characters to "_
"). For example, the following variables would be set on the OpenVPN server using the sample client certificate in sample-keys (client.crt). Note that the verification level is 0 for the client certificate and 1 for the CA certificate.X509_0_emailAddress=me@myhost.mydomainX509_0_CN=Test-ClientX509_0_O=OpenVPN-TESTX509_0_ST=NAX509_0_C=KGX509_1_emailAddress=me@myhost.mydomainX509_1_O=OpenVPN-TESTX509_1_L=BISHKEKX509_1_ST=NAX509_1_C=KG
Management Interface Options
OpenVPN provides a feature rich socket based management interface for both server and client mode operations.
--managementargs | |
Enable a management server on asocket-nameUnix socket on those platforms supporting it, or on a designated TCP port. Valid syntaxes: management socket-name unix #management socket-name unix pw-file # (recommended)management IP port # (INSECURE)management IP port pw-file # pw-file, if specified, is a password file where the password must be on first line. Instead of a filename it can use the keyword stdin which will prompt the user for a password to use when OpenVPN is starting. For unix sockets, the default behaviour is to create a unix domain socket that may be connected to by any process. Use the--management-client-userand--management-client-groupdirectives to restrict access. The management interface provides a special mode where the TCP management link can operate over the tunnel itself. To enable this mode, set IP totunnel. Tunnel mode will cause the management interface to listen for a TCP connection on the local VPN address of the TUN/TAP interface. *BEWARE*of enabling the management interface over TCP. In these cases you shouldALWAYSmake use ofpw-fileto password protect the management interface. Any user who can connect to this TCPIP:portwill be able to manage and control (and interfere with) the OpenVPN process. It is also strongly recommended to set IP to 127.0.0.1 (localhost) to restrict accessibility of the management server to local clients. While the management port is designed for programmatic control of OpenVPN by other applications, it is possible to telnet to the port, using a telnet client in "raw" mode. Once connected, type For detailed documentation on the management interface, see themanagement-notes.txtfile in the management folder of the OpenVPN source distribution. | |
--management-client | |
Management interface will connect as a TCP/unix domain client toIP:portspecified by--managementrather than listen as a TCP server or on a unix domain socket. If the client connection fails to connect or is disconnected, a SIGTERM signal will be generated causing OpenVPN to quit. | |
--management-client-auth | |
Gives management interface client the responsibility to authenticate clients after their client certificate has been verified. Seemanagement-notes.txt in OpenVPN distribution for detailed notes. | |
--management-client-groupg | |
When the management interface is listening on a unix domain socket, only allow connections from groupg. | |
--management-client-pf | |
Management interface clients must specify a packet filter file for each connecting client. Seemanagement-notes.txt in OpenVPN distribution for detailed notes. | |
--management-client-useru | |
When the management interface is listening on a unix domain socket, only allow connections from useru. | |
--management-external-certcertificate-hint | |
Allows usage for external certificate instead of--certoption (client-only).certificate-hintis an arbitrary string which is passed to a management interface client as an argument ofNEED-CERTIFICATEnotification. Requires--management-external-key. | |
--management-external-keyargs | |
Allows usage for external private key file instead of--keyoption (client-only). Valid syntaxes: management-external-keymanagement-external-key nopaddingmanagement-external-key pkcs1management-external-key nopadding pkcs1 The optional parameters | |
--management-forget-disconnect | |
Make OpenVPN forget passwords when management session disconnects. This directive does not affect the--http-proxyusername/password. It is always cached. | |
--management-hold | |
Start OpenVPN in a hibernating state, until a client of the management interface explicitly starts it with thehold release command. | |
--management-log-cachen | |
Cache the most recentnlines of log file history for usage by the management channel. | |
--management-query-passwords | |
Query management channel for private key password and--auth-user-passusername/password. Only query the management channel for inputs which ordinarily would have been queried from the console. | |
--management-query-proxy | |
Query management channel for proxy server information for a specific--remote(client-only). | |
--management-query-remote | |
Allow management interface to override--remotedirectives (client-only). | |
--management-signal | |
Send SIGUSR1 signal to OpenVPN if management session disconnects. This is useful when you wish to disconnect an OpenVPN session on user logoff. For--management-clientthis option is not needed since a disconnect will always generate aSIGTERM . | |
--management-up-down | |
Report tunnel up/down events to management interface. |
Plug-in Interface Options
OpenVPN can be extended by loading external plug-in modules at runtime. These plug-ins must be prebuilt and adhere to the OpenVPN Plug-In API.
--pluginargs | Loads an OpenVPN plug-in module. Valid syntax: plugin module-nameplugin module-name "arguments" Themodule-nameneeds to be the first argument, indicating the plug-in to load. The second argument is an optional init string which will be passed directly to the plug-in. If the init consists of multiple arguments it must be enclosed in double-quotes ("). Multiple plugin modules may be loaded into one OpenVPN process. Themodule-nameargument can be just a filename or a filename with a relative or absolute path. The format of the filename and path defines if the plug-in will be loaded from a default plug-in directory or outside this directory. --plugin path Effective directory used===================== ============================= myplug.so DEFAULT_DIR/myplug.so subdir/myplug.so DEFAULT_DIR/subdir/myplug.so ./subdir/myplug.so CWD/subdir/myplug.so /usr/lib/my/plug.so /usr/lib/my/plug.so DEFAULT_DIRis replaced by the default plug-in directory, which is configured at the build time of OpenVPN.CWDis the current directory where OpenVPN was started or the directory OpenVPN have switched into via the--cdoption before the--pluginoption. For more information and examples on how to build OpenVPN plug-in modules, see the README file in thepluginfolder of the OpenVPN source distribution. If you are using an RPM install of OpenVPN, see Multiple plugin modules can be cascaded, and modules can be used in tandem with scripts. The modules will be called by OpenVPN in the order that they are declared in the config file. If both a plugin and script are configured for the same callback, the script will be called last. If the return code of the module/script controls an authentication function (such as tls-verify, auth-user-pass-verify, or client-connect), then every module and script must return success (
|
Windows-Specific Options
--allow-nonadminTAP-adapter | |
(Standalone) SetTAP-adapterto allow access from non-administrative accounts. IfTAP-adapteris omitted, all TAP adapters on the system will be configured to allow non-admin access. The non-admin access setting will only persist for the length of time that the TAP-Win32 device object and driver remain loaded, and will need to be re-enabled after a reboot, or if the driver is unloaded and reloaded. This directive can only be used by an administrator. | |
--block-outside-dns | |
Block DNS servers on other network adapters to prevent DNS leaks. This option prevents any application from accessing TCP or UDP port 53 except one inside the tunnel. It uses Windows Filtering Platform (WFP) and works on Windows Vista or later. This option is considered unknown on non-Windows platforms and unsupported on Windows XP, resulting in fatal error. You may want to use--setenvoptor--ignore-unknown-option(not suitable for Windows XP) to ignore said error. Note that pushing unknown options from server does not trigger fatal errors. | |
--cryptoapicertselect-string | |
(Windows/OpenSSL Only)Load the certificate and private key from the Windows Certificate System Store. Use this option instead of--certand--key. This makes it possible to use any smart card, supported by Windows, but also any kind of certificate, residing in the Cert Store, where you have access to the private key. This option has been tested with a couple of different smart cards (GemSAFE, Cryptoflex, and Swedish Post Office eID) on the client side, and also an imported PKCS12 software certificate on the server side. To select a certificate, based on a substring search in the certificate's subject: cryptoapicert "SUBJ:Peter Runestig" To select a certificate, based on certificate's thumbprint: cryptoapicert "THUMB:f6 49 24 41 01 b4 ..." The thumbprint hex string can easily be copy-and-pasted from the Windows Certificate Store GUI. | |
--dhcp-release | Ask Windows to release the TAP adapter lease on shutdown. This option has no effect now, as it is enabled by default starting with OpenVPN 2.4.1. |
--dhcp-renew | Ask Windows to renew the TAP adapter lease on startup. This option is normally unnecessary, as Windows automatically triggers a DHCP renegotiation on the TAP adapter when it comes up, however if you set the TAP-Win32 adapter Media Status property to "Always Connected", you may need this flag. |
--ip-win32method | |
When using--ifconfigon Windows, set the TAP-Win32 adapter IP address and netmask usingmethod. Don't use this option unless you are also using--ifconfig.
| |
--pause-exit | Put up a "press any key to continue" message on the console prior to OpenVPN program exit. This option is automatically used by the Windows explorer when OpenVPN is run on a configuration file using the right-click explorer menu. |
--register-dns | Runipconfig /flushdns andipconfig /registerdns on connection initiation. This is known to kick Windows into recognizing pushed DNS servers. |
--route-methodm | |
Which methodmto use for adding routes on Windows?
| |
--serviceargs | Should be used when OpenVPN is being automatically executed by another program in such a context that no interaction with the user via display or keyboard is possible. Valid syntax: service exit-event [0|1] In general, end-users should never need to explicitly use this option, as it is automatically added by the OpenVPN service wrapper when a given OpenVPN configuration is being run as a service. exit-eventis the name of a Windows global event object, and OpenVPN will continuously monitor the state of this event object and exit when it becomes signaled. The second parameter indicates the initial state ofexit-eventand normally defaults to 0. Multiple OpenVPN processes can be simultaneously executed with the sameexit-eventparameter. In any case, the controlling process can signalexit-event, causing all such OpenVPN processes to exit. When executing an OpenVPN process using the--servicedirective, OpenVPN will probably not have a console window to output status/error messages, therefore it is useful to use--logor--log-appendto write these messages to a file. |
--show-adapters | |
(Standalone) Show available TAP-Win32 adapters which can be selected using the--dev-nodeoption. On non-Windows systems, theifconfig(8) command provides similar functionality. | |
--show-net | (Standalone) Show OpenVPN's view of the system routing table and network adapter list. |
--show-net-up | Output OpenVPN's view of the system routing table and network adapter list to the syslog or log file after the TUN/TAP adapter has been brought up and any routes have been added. |
--show-valid-subnets | |
(Standalone) Show valid subnets for--devtunemulation. Since the TAP-Win32 driver exports an ethernet interface to Windows, and since TUN devices are point-to-point in nature, it is necessary for the TAP-Win32 driver to impose certain constraints on TUN endpoint address selection. Namely, the point-to-point endpoints used in TUN device emulation must be the middle two addresses of a /30 subnet (netmask 255.255.255.252). | |
--tap-sleepn | Cause OpenVPN to sleep fornseconds immediately after the TAP-Win32 adapter state is set to "connected". This option is intended to be used to troubleshoot problems with the--ifconfigand--ip-win32options, and is used to give the TAP-Win32 adapter time to come up before Windows IP Helper API operations are applied to it. |
--win-syspath | Set the Windows system directory pathname to use when looking for system executables such asroute.exeandnetsh.exe. By default, if this directive is not specified, OpenVPN will use the SystemRoot environment variable. This option has changed behaviour since OpenVPN 2.3. Earlier you had to define--win-sysenvto use the SystemRoot environment variable, otherwise it defaulted to |
--windows-driverdrv | |
Specifies which tun driver to use. Values aretap-windows6 (default) andwintun . This is a Windows-only option.wintun " requires--devtunand the OpenVPN process to run elevated, or be invoked using the Interactive Service. |
Standalone Debug Options
--show-gatewayargs | |
(Standalone) Show current IPv4 and IPv6 default gateway and interface towards the gateway (if the protocol in question is enabled). Valid syntax: --show-gateway--show-gateway IPv6-target For IPv6 this queries the route towards ::/128, or the specified IPv6 target address if passed as argument. For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. If there are more specific routes, the result will not always be matching the route of the IPv4 packets to the VPN gateway. |
Advanced Expert Options
These are options only required when special tweaking is needed, often used when debugging or testing out special usage scenarios.
--hash-sizeargs | |
Set the size of the real address hash table torand the virtual address table tov. Valid syntax: hash-size r v By default, both tables are sized at 256 buckets. | |
--bcast-buffersn | |
Allocatenbuffers for broadcast datagrams (default256 ). | |
--persist-local-ip | |
Preserve initially resolved local IP address and port number acrossSIGUSR1or--ping-restartrestarts. | |
--persist-remote-ip | |
Preserve most recently authenticated remote IP address and port number acrossSIGUSR1 or--ping-restartrestarts. | |
--prngargs | (Advanced)Change the PRNG (Pseudo-random number generator) parameters Valid syntaxes: prng algprng alg nsl Changes the PRNG to use digest algorithmalg(default Setalgto |
--rcvbufsize | Set the TCP/UDP socket receive buffer size. Defaults to operating system default. |
--shapern | Limit bandwidth of outgoing tunnel data tonbytes per second on the TCP/UDP port. Note that this will only work if mode is set to OpenVPN uses the following algorithm to implement traffic shaping: Given a shaper rate ofnbytes per second, after a datagram write ofbbytes is queued on the TCP/UDP port, wait a minimum of(b / n)seconds before queuing the next write. It should be noted that OpenVPN supports multiple tunnels between the same two peers, allowing you to construct full-speed and reduced bandwidth tunnels at the same time, routing low-priority data such as off-site backups over the reduced bandwidth tunnel, and other data over the full-speed tunnel. Also note that for low bandwidth tunnels (under 1000 bytes per second), you should probably use lower MTU values as well (see above), otherwise the packet latency will grow so large as to trigger timeouts in the TLS layer and TCP connections running over the tunnel. OpenVPN allowsnto be between 100 bytes/sec and 100 Mbytes/sec. |
--sndbufsize | Set the TCP/UDP socket send buffer size. Defaults to operating system default. |
--tcp-queue-limitn | |
Maximum number of output packets queued before TCP (default When OpenVPN is tunneling data from a TUN/TAP device to a remote client over a TCP connection, it is possible that the TUN/TAP device might produce data at a faster rate than the TCP connection can support. When the number of output packets queued before sending to the TCP socket reaches this limit for a given client connection, OpenVPN will start to drop outgoing packets directed at this client. | |
--txqueuelenn | (Linux only)Set the TX queue length on the TUN/TAP interface. Currently defaults to operating system default. |
Options listed in this section have been removed from OpenVPN and are no longer supported
--client-cert-not-required | |
Removed in OpenVPN 2.5. This should be replaxed with--verify-client-certnone. | |
--ifconfig-pool-linear | |
Removed in OpenVPN 2.5. This should be replaced with--topologyp2p. | |
--key-method | Removed in OpenVPN 2.5. This option should not be used, as using the oldkey-methodweakens the VPN tunnel security. The oldkey-methodwas also only needed when the remote side was older than OpenVPN 2.0. |
--no-iv | Removed in OpenVPN 2.5. This option should not be used as it weakens the VPN tunnel security. This has been a NOOP option since OpenVPN 2.4. |
--no-replay | Removed in OpenVPN 2.5. This option should not be used as it weakens the VPN tunnel security. |
--ns-cert-type | Removed in OpenVPN 2.5. ThensCertTypefield is no longer supported in recent SSL/TLS libraries. If your certificates does not includekey usageandextended key usagefields, they must be upgraded and the--remote-cert-tlsoption should be used instead. |
Client configuration files may contain multiple remote servers which it will attempt to connect against. But there are some configuration options which are related to specific--remoteoptions. For these use cases, connection profiles are the solution.
By enacpulating the--remoteoption and related options within<connection>and</connection>, these options are handled as a group.
An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.
--remote-randomcan be used to initially "scramble" the connection list.
Here is an example of connection profile usage:
clientdev tun<connection>remote 198.19.34.56 1194 udp</connection><connection>remote 198.19.34.56 443 tcp</connection><connection>remote 198.19.34.56 443 tcphttp-proxy 192.168.0.8 8080</connection><connection>remote 198.19.36.99 443 tcphttp-proxy 192.168.0.8 8080</connection>persist-keypersist-tunpkcs12 client.p12remote-cert-tls serververb 3
First we try to connect to a server at 198.19.34.56:1194 using UDP. If that fails, we then try to connect to 198.19.34.56:443 using TCP. If that also fails, then try connecting through an HTTP proxy at 192.168.0.8:8080 to 198.19.34.56:443 using TCP. Finally, try to connect through the same proxy to a server at 198.19.36.99:443 using TCP.
The following OpenVPN options may be used inside of a<connection>block:
bind,connect-retry,connect-retry-max,connect-timeout,explicit-exit-notify,float,fragment,http-proxy,http-proxy-option,key-direction,link-mtu,local,lport,mssfix,mtu-disc,nobind,port,proto,remote,rport,socks-proxy,tls-auth,tls-crypt,tun-mtuand,tun-mtu-extra.
A defaulting mechanism exists for specifying options to apply to all<connection>profiles. If any of the above options (with the exception ofremote) appear outside of a<connection>block, but in a configuration file which has one or more<connection>blocks, the option setting will be used as a default for<connection>blocks which follow it in the configuration file.
For example, suppose thenobindoption were placed in the sample configuration file above, near the top of the file, before the first<connection>block. The effect would be as ifnobindwere declared in all<connection>blocks below it.
OpenVPN allows including files in the main configuration for the--ca,--cert,--dh,--extra-certs,--key,--pkcs12,--secret,--crl-verify,--http-proxy-user-pass,--tls-auth,--auth-gen-token-secret,--tls-cryptand--tls-crypt-v2options.
Each inline file started by the line<option>and ended by the line</option>
Here is an example of an inline file usage
<cert>-----BEGIN CERTIFICATE-----[...]-----END CERTIFICATE-----</cert>
When using the inline file feature with--pkcs12the inline file has to be base64 encoded. Encoding of a .p12 file into base64 can be done for example with OpenSSL by runningopenssl base64 -in input.p12
SIGHUP
- Cause OpenVPN to close all TUN/TAP and network connections, restart, re-read the configuration file (if any), and reopen TUN/TAP and network connections.
SIGUSR1
Like
SIGHUP`
, except don't re-read configuration file, and possibly don't close and reopen TUN/TAP device, re-read key files, preserve local IP address/port, or preserve most recently authenticated remote IP address/port based on--persist-tun,--persist-key,--persist-local-ipand--persist-remote-ipoptions respectively (see above).This signal may also be internally generated by a timeout condition, governed by the--ping-restartoption.
This signal, when combined with--persist-remote-ip, may be sent when the underlying parameters of the host's network interface change such as when the host is a DHCP client and is assigned a new IP address. See--ipchangefor more information.
SIGUSR2
- Causes OpenVPN to display its current statistics (to the syslog file if--daemonis used, or stdout otherwise).
SIGINT
,SIGTERM
- Causes OpenVPN to exit gracefully.
https://community.openvpn.net/openvpn/wiki/FAQ
For a more comprehensive guide to setting up OpenVPN in a production setting, see the OpenVPN HOWTO athttps://openvpn.net/community-resources/how-to/
For a description of OpenVPN's underlying protocol, seehttps://openvpn.net/community-resources/openvpn-protocol/
OpenVPN's web site is athttps://openvpn.net/
Go here to download the latest version of OpenVPN, subscribe to the mailing lists, read the mailing list archives, or browse the SVN repository.
Report all bugs to the OpenVPN teaminfo@openvpn.net
openvpn-examples(5),dhcpcd(8),ifconfig(8),openssl(1),route(8),scp(1)ssh(1)
This product includes software developed by the OpenSSL Project (https://www.openssl.org/)
For more information on the TLS protocol, seehttp://www.ietf.org/rfc/rfc2246.txt
For more information on the LZO real-time compression library seehttps://www.oberhumer.com/opensource/lzo/
Copyright (C) 2002-2020 OpenVPN Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
James Yonanjames@openvpn.net