OpenVPN 2.4 Manual⁠

INTRODUCTION⁠

OpenVPN is an open-source VPN daemon by James Yonan. Because OpenVPN aims to be a universal VPN tool, offering a great deal of flexibility, this manual page presents numerous options. 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.

The OpenVPN website has more documentation and examples.

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

DESCRIPTION⁠

OpenVPN is a robust and highly flexible VPN daemon. OpenVPN supports:

  • SSL/TLS security.

  • Ethernet bridging.

  • TCP or UDP tunnel transport through proxies or Network Address Translation (NAT).

  • Dynamic IP addresses and DHCP.

  • Scalability to hundreds or thousands of users.

  • Portability to most major OS platforms.

OpenVPN is tightly integrated with the OpenSSL library and derives many of its cryptographic 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 and server certificates. OpenVPN also supports non-encrypted TCP and UDP tunnels.

OpenVPN is designed to work with the TUN/TAP virtual networking interface, which is available on most platforms.

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

OPTIONS⁠

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

--help

Show options.

--config file

Load additional config options from file where each line corresponds to one command line option, but with the leading '--' removed.If --config file is the only option to the openvpn command, the --config can be removed, and the command can be given as openvpn file Note that configuration files can be nested to a reasonable depth. Double quotation or single quotation characters ("", '') can be used to enclose single parameters containing whitespace, and "#" or ";" characters in the first column can be used to denote comments. Note that OpenVPN 2.0 and higher performs backslash-based shell escaping for characters not in single quotations, so the following mappings should be observed: \\ Maps to a single backslash character (\). \" Pass a literal doublequote character ("), don't interpret it as enclosing a parameter. \[SPACE] Pass a literal space or tab character, don't interpret it as a parameter delimiter. For example on Windows, use double backslashes to represent pathnames: secret "c:\\OpenVPN\\secret.key" For examples of configuration files, see https://www-dev.openvpn.in/community-resources/how-to/ Here is an example configuration file: # # Sample OpenVPN configuration file for # using a pre-shared static key. # # '#' or ';' may be used to delimit comments. # Use a dynamic tun device. dev tun # Our remote peer remote mypeer.mydomain # 10.1.0.1 is our local VPN endpoint # 10.1.0.2 is our remote VPN endpoint ifconfig 10.1.0.1 10.1.0.2 # Our pre-shared static key secret static.key

SCRIPTING AND ENVIRONMENTAL VARIABLES⁠

OpenVPN exports a series of environmental variables for use by user-defined scripts.

INLINE FILE SUPPORT⁠

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 and --tls-crypt options. 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 --pkcs12 the inline file has to be base64 encoded. Encoding of a .p12 file into base64 can be done for example with OpenSSL by running openssl base64 -in input.p12

SIGNALS⁠

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-ip, and --persist-remote-ip options respectively (see above).This signal may also be internally generated by a timeout condition, governed by the --ping-restart option. 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 --ipchange above for more information.

SIGUSR2

Causes OpenVPN to display its current statistics (to the syslog file if --daemon is used, or stdout otherwise).

SIGINT, SIGTERM

Causes OpenVPN to exit gracefully.

TUN/TAP DRIVER SETUP⁠

If you are running Linux 2.4.7 or higher, you probably have the TUN/TAP driver already installed. If so, there are still a few things you need to do: Make device: mknod /dev/net/tun c 10 200 Load driver: modprobe tun

EXAMPLES⁠

Prior to running these examples, you should have OpenVPN installed on two machines with network connectivity between them. If you haven't installed OpenVPN, consult the INSTALL file included in the OpenVPN distribution.

FIREWALLS⁠

OpenVPN's usage of a single UDP port makes it fairly firewall-friendly. You should add an entry to your firewall rules to allow incoming OpenVPN packets. On Linux 2.4+:

iptables -A INPUT -p udp -s 1.2.3.4 --dport 1194 -j ACCEPT

This will allow incoming packets on UDP port 1194 (OpenVPN's default UDP port) from an OpenVPN peer at 1.2.3.4.

If you are using HMAC-based packet authentication (the default in any of OpenVPN's secure modes), having the firewall filter on source address can be considered optional, since HMAC packet authentication is a much more secure method of verifying the authenticity of a packet source. In that case:

iptables -A INPUT -p udp --dport 1194 -j ACCEPT

would be adequate and would not render the host inflexible with respect to its peer having a dynamic IP address.

OpenVPN also works well on stateful firewalls. In some cases, you may not need to add any static rules to the firewall list if you are using a stateful firewall that knows how to track UDP connections. If you specify --ping n, OpenVPN will be guaranteed to send a packet to its peer at least once every n seconds. If n is less than the stateful firewall connection timeout, you can maintain an OpenVPN connection indefinitely without explicit firewall rules.

You should also add firewall rules to allow incoming IP traffic on TUN or TAP devices such as:

iptables -A INPUT -i tun+ -j ACCEPT

to allow input packets from tun devices,

iptables -A FORWARD -i tun+ -j ACCEPT

to allow input packets from tun devices to be forwarded to other hosts on the local network,

iptables -A INPUT -i tap+ -j ACCEPT

to allow input packets from tap devices, and

iptables -A FORWARD -i tap+ -j ACCEPT

to allow input packets from tap devices to be forwarded to other hosts on the local network.

These rules are secure if you use packet authentication, since no incoming packets will arrive on a TUN or TAP virtual device unless they first pass an HMAC authentication test.

FAQ⁠

https://community.openvpn.net/FAQ

HOWTO⁠

For a more comprehensive guide to setting up OpenVPN in a production setting, see the OpenVPN HOWTO.

PROTOCOL⁠

For a description of OpenVPN's underlying protocol, refer to OpenVPN Protocol.

WEB⁠

Refer to OpenVPN's website to download the latest version of OpenVPN, subscribe to the mailing lists, read the mailing list archives, or browse the Git repository.

BUGS⁠

Report all bugs to the OpenVPN team info@openvpn.net.

NOTES⁠

This product includes software developed by the OpenSSL Project .

For more information on the TLS protocol, see http://www.ietf.org/rfc/rfc2246.txt.

For more information on the LZO real-time compression library see http://www.oberhumer.com/opensource/lzo/.

AUTHOR⁠

James Yonan <jim@yonan.net>

Can't find what you're looking for?

Our support team will be happy to assist you.