Fdocuments - in Openvpn Man

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

Printed by root

May 07, 12 21:14 − Page 1/69 May 07, 12 21:14 − Page 2/69
openvpn(8) If −−config file is the only option to the openvpn command, the
openvpn(8) −−config can be removed, and the command
can be given as openvpn file
Note that configuration files can be nested to a reasonable depth.
NAME
openvpn − secure IP tunnel daemon. Double quotation or single quotation characters ("", ’’) can be us
ed to enclose single parameters containâM−^@M−^P
SYNOPSIS ing whitespace, and "#" or ";" characters in the first column can
openvpn [ options ... ] be used to denote comments.

INTRODUCTION Note that OpenVPN 2.0 and higher performs backslash−based shell e
OpenVPN is an open source VPN daemon by James Yonan. Because OpenVPN tr scaping for characters not in single quoâM−^@M−^P
ies to be a universal VPN tool offering a tations, so the following mappings should be observed:
great deal of flexibility, there are a lot of options on this manual page
. If you’re new to OpenVPN, you might \\ Maps to a single backslash character (\).
want to skip ahead to the examples section where you will see how to \" Pass a literal doublequote character ("), don’t
construct simple VPNs on the command line interpret it as enclosing a parameter.
without even needing a configuration file. \[SPACE] Pass a literal space or tab character, don’t
interpret it as a parameter delimiter.
Also note that there’s more documentation and examples on the OpenVPN web
site: http://openvpn.net/ For example on Windows, use double backslashes to represent pathna
mes:
And if you would like to see a shorter version of this manual, see the op
envpn usage message which can be obtained secret "c:\\OpenVPN\\secret.key"
by running openvpn without any parameters.
For examples of configuration files, see http://openvpn.net/exampl
DESCRIPTION es.html
OpenVPN is a robust and highly flexible VPN daemon. OpenVPN supports SS
L/TLS security, ethernet bridging, TCP or Here is an example configuration file:
UDP tunnel transport through proxies or NAT, support for dynamic IP addre
sses and DHCP, scalability to hundreds or #
thousands of users, and portability to most major OS platforms. # Sample OpenVPN configuration file for
# using a pre−shared static key.
OpenVPN is tightly bound to the OpenSSL library, and derives much of its #
crypto capabilities from it. # ’#’ or ’;’ may be used to delimit comments.

OpenVPN supports conventional encryption using a pre−shared secret key # Use a dynamic tun device.
(Static Key mode) or public key security dev tun
(SSL/TLS mode) using client & server certificates. OpenVPN also supports
non−encrypted TCP/UDP tunnels. # Our remote peer
remote mypeer.mydomain
OpenVPN is designed to work with the TUN/TAP virtual networking interface
that exists on most platforms. # 10.1.0.1 is our local VPN endpoint
# 10.1.0.2 is our remote VPN endpoint
Overall, OpenVPN aims to offer many of the key features of IPSec but with ifconfig 10.1.0.1 10.1.0.2
a relatively lightweight footprint.
# Our pre−shared static key
OPTIONS secret static.key
OpenVPN allows any option to be placed either on the command line or in a
configuration file. Though all command Tunnel Options:
line options are preceded by a double−leading−dash ("−−"), this prefix c −−mode m
an be removed when an option is placed in Set OpenVPN major mode. By default, OpenVPN runs in point−to−poin
a configuration file. t mode ("p2p"). OpenVPN 2.0 introduces a
new mode ("server") which implements a multi−client server capabil
−−help Show options. ity.

−−config file −−local host


Load additional config options from file where each line correspon Local host name or IP address for bind. If specified, OpenVPN wil
ds to one command line option, but with l bind to this address only. If unspeciâM−^@M−^P
the leading ’−−’ removed. fied, OpenVPN will bind to all interfaces.

Monday May 07, 2012 − 1/35


Printed by root

May 07, 12 21:14 − Page 3/69 May 07, 12 21:14 − Page 4/69
−−remote host [port] [proto] list.
Remote host name or IP address. On the client, multiple −−remote
options may be specified for redundancy, Here is an example of connection profile usage:
each referring to a different OpenVPN server. Specifying multip
le −−remote options for this purpose is a client
special case of the more general connection−profile feature. See dev tun
the <connection> documentation below.
<connection>
The OpenVPN client will try to connect to a server at host:port in remote 198.19.34.56 1194 udp
the order specified by the list of </connection>
−−remote options.
<connection>
proto indicates the protocol to use when connecting with the remot remote 198.19.34.56 443 tcp
e, and may be "tcp" or "udp". </connection>
The client will move on to the next host in the list, in the event <connection>
of connection failure. Note that at any remote 198.19.34.56 443 tcp
given time, the OpenVPN client will at most be connected to one se http−proxy 192.168.0.8 8080
rver. http−proxy−retry
</connection>
Note that since UDP is connectionless, connection failure is defi
ned by the −−ping and −−ping−restart <connection>
options. remote 198.19.36.99 443 tcp
http−proxy 192.168.0.8 8080
Note the following corner case: If you use multiple −−remote opti http−proxy−retry
ons, AND you are dropping root privileges </connection>
on the client with −−user and/or −−group, AND the client is runnin
g a non−Windows OS, if the client needs persist−key
to switch to a different server, and that server pushes back persist−tun
different TUN/TAP or route settings, the pkcs12 client.p12
client may lack the necessary privileges to close and reopen the T ns−cert−type server
UN/TAP interface. This could cause the verb 3
client to exit with a fatal error.
First we try to connect to a server at 198.19.34.56:1194 using UDP
If −−remote is unspecified, OpenVPN will listen for packets from . If that fails, we then try to connect
any IP address, but will not act on those to 198.19.34.56:443 using TCP. If that also fails, then
packets unless they pass all authentication tests. This requireme try connecting through an HTTP proxy at
nt for authentication is binding on all 192.168.0.8:8080 to 198.19.34.56:443 using TCP. Finally, try to c
potential peers, even those from known and supposedly trusted onnect through the same proxy to a server
IP addresses (it is very easy to forge a at 198.19.36.99:443 using TCP.
source IP address on a UDP packet).
The following OpenVPN options may be used inside of a <connection>
When used in TCP mode, −−remote will act as a filter, rejecting co block:
nnections from any host which does not
match host. bind, connect−retry, connect−retry−max, connect−timeout, float, h
ttp−proxy, http−proxy−option, http−proxy−
If host is a DNS name which resolves to multiple IP addresses, retry, http−proxy−timeout, local, lport, nobind, port, proto, remo
one will be randomly chosen, providing a te, rport, socks−proxy, and socks−proxy−
sort of basic load−balancing and failover capability. retry.

<connection> A defaulting mechanism exists for specifying options to apply to


Define a client connection profile. Client connection profiles ar all <connection> profiles. If any of the
e groups of OpenVPN options that describe above options (with the exception of remote ) appear outside of a
how to connect to a given OpenVPN server. Client connection prof <connection> block, but in a configuraâM−^@M−^P
iles are specified within an OpenVPN conâM−^@M−^P tion file which has one or more <connection> blocks, the option se
figuration file, and each profile is bracketed by <connection> and tting will be used as a default for <conâM−^@M−^P
</connection>. nection> blocks which follow it in the configuration file.

An OpenVPN client will try each connection profile sequentially un For example, suppose the nobind option were placed in the sample c
til it achieves a successful connection. onfiguration file above, near the top of
the file, before the first <connection> block. The effect would b
−−remote−random can be used to initially "scramble" the connection e as if nobind were declared in all <conâM−^@M−^P
Monday May 07, 2012 − 2/35
Printed by root

May 07, 12 21:14 − Page 5/69 May 07, 12 21:14 − Page 6/69
nection> blocks below it. ption API. This option exists in OpenVPN
2.1 or higher.

−−remote−random −−http−proxy server port [authfile|’auto’|’auto−nct’] [auth−method]


When multiple −−remote address/ports are specified, or if connecti Connect to remote host through an HTTP proxy at address server and
on profiles are being used, initially port port. If HTTP Proxy−Authenticate
randomize the order of the list as a kind of basic load−balancing is required, authfile is a file containing a username and passw
measure. ord on 2 lines, or "stdin" to prompt from
console.
−−proto p
Use protocol p for communicating with remote host. p can be udp, auth−method should be one of "none", "basic", or "ntlm".
tcp−client, or tcp−server.
HTTP Digest authentication is supported as well, but only via the
The default protocol is udp when −−proto is not specified. auto or auto−nct flags (below).

For UDP operation, −−proto udp should be specified on both peers. The auto flag causes OpenVPN to automatically determine the auth−m
ethod and query stdin or the management
For TCP operation, one peer must use −−proto tcp−server and the o interface for username/password credentials, if required. This fl
ther must use −−proto tcp−client. A peer ag exists on OpenVPN 2.1 or higher.
started with tcp−server will wait indefinitely for an incoming con
nection. A peer started with tcp−client The auto−nct flag (no clear−text auth) instructs OpenVPN to a
will attempt to connect, and if that fails, will sleep for 5 se utomatically determine the authentication
conds (adjustable via the −−connect−retry method, but to reject weak authentication protocols such as HTTP B
option) and try again infinite or up to N retries (adjustable via asic Authentication.
the −−connect−retry−max option). Both
TCP client and server will simulate a SIGUSR1 restart signal if ei −−http−proxy−retry
ther side resets the connection. Retry indefinitely on HTTP proxy errors. If an HTTP proxy error o
ccurs, simulate a SIGUSR1 reset.
OpenVPN is designed to operate optimally over UDP, but TCP capabi
lity is provided for situations where UDP −−http−proxy−timeout n
cannot be used. In comparison with UDP, TCP will usually be somew Set proxy timeout to n seconds, default=5.
hat less efficient and less robust when
used over unreliable or congested networks. −−http−proxy−option type [parm]
Set extended HTTP proxy options. Repeat to set multiple options.
This article outlines some of problems with tunneling IP over TCP:
VERSION version −− Set HTTP version number to version (default=1.0
http://sites.inka.de/sites/bigred/devel/tcp−tcp.html ).

There are certain cases, however, where using TCP may be advanta AGENT user−agent −− Set HTTP "User−Agent" string to user−agent.
geous from a security and robustness perâM−^@M−^P
spective, such as tunneling non−IP or application−level UDP protoc −−socks−proxy server [port]
ols, or tunneling protocols which don’t Connect to remote host through a Socks5 proxy at address server an
possess a built−in reliability layer. d port port (default=1080).

−−connect−retry n −−socks−proxy−retry
For −−proto tcp−client, take n as the number of seconds to wait be Retry indefinitely on Socks proxy errors. If a Socks proxy error
tween connection retries (default=5). occurs, simulate a SIGUSR1 reset.
−−connect−retry−max n −−resolv−retry n
For −−proto tcp−client, take n as the number of retries of connect If hostname resolve fails for −−remote, retry resolve for n second
ion attempt (default=infinite). s before failing.
−−auto−proxy Set n to "infinite" to retry indefinitely.
Try to sense HTTP or SOCKS proxy settings automatically. If no
settings are present, a direct connection By default, −−resolv−retry infinite is enabled. You can disable b
will be attempted. If both HTTP and SOCKS settings are present, H y setting n=0.
TTP will be preferred. If the HTTP proxy
server requires a password, it will be queried from stdin or the −−float
management interface. If the underlying Allow remote peer to change its IP address and/or port number, suc
OS doesn’t support an API for returning proxy settings, a direct c h as due to DHCP (this is the default if
onnection will be attempted. Currently, −−remote is not used). −−float when specified with −−remote allow
only Windows clients support this option via the InternetQueryO s an OpenVPN session to initially connect
Monday May 07, 2012 − 3/35
Printed by root

May 07, 12 21:14 − Page 7/69 May 07, 12 21:14 − Page 8/69
to a peer at a known address, however if packets arrive from a new −−nobind
address and pass all authentication Do not bind to local address and port. The IP stack will allocate
tests, the new address will take control of the session. This is a dynamic port for returning packets.
useful when you are connecting to a peer Since the value of the dynamic port could not be known in advanc
which holds a dynamic address such as a dial−in user or DHCP clien e by a peer, this option is only suitable
t. for peers which will be initiating connections by using the −−remo
te option.
Essentially, −−float tells OpenVPN to accept authenticated packets
from any address, not only the address −−dev tunX | tapX | null
which was specified in the −−remote option. TUN/TAP virtual network device ( X can be omitted for a dynamic de
vice.)
−−ipchange cmd
Execute shell command cmd when our remote ip−address is initially See examples section below for an example on setting up a TUN devi
authenticated or changes. ce.

Execute as: You must use either tun devices on both ends of the connection or
tap devices on both ends. You cannot mix
cmd ip_address port_number them, as they represent different underlying network layers.

Don’t use −−ipchange in −−mode server mode. Use a −−client−connec tun devices encapsulate IPv4 or IPv6 (OSI Layer 3) while tap devi
t script instead. ces encapsulate Ethernet 802.3 (OSI Layer
2).
See the "Environmental Variables" section below for additional
parameters passed as environmental variâM−^@M−^P −−dev−type device−type
ables. Which device type are we using? device−type should be tun (OSI La
yer 3) or tap (OSI Layer 2). Use this
Note that cmd can be a shell command with multiple arguments, in w option only if the TUN/TAP device used with −−dev does not begin w
hich case all OpenVPN−generated arguments ith tun or tap.
will be appended to cmd to build a command line which will be pass
ed to the script. −−topology mode
Configure virtual addressing topology when running in −−dev tu
If you are running in a dynamic IP address environment where the n mode. This directive has no meaning in
IP addresses of either peer could change −−dev tap mode, which always uses a subnet topology.
without notice, you can use this script, for example, to edit the
/etc/hosts file with the current address If you set this directive on the server, the −−server and −−serve
of the peer. The script will be run every time the remote peer ch r−bridge directives will automatically
anges its IP address. push your chosen topology setting to clients as well. This
directive can also be manually pushed to
Similarly if our IP address changes due to DHCP, we should config clients. Like the −−dev directive, this directive must always be
ure our IP address change script (see man compatible between client and server.
page for dhcpcd(8) ) to deliver a SIGHUP or SIGUSR1 signal to Open
VPN. OpenVPN will then reestablish a mode can be one of:
connection with its most recently authenticated peer on its new IP
address. net30 −− Use a point−to−point topology, by allocating one /30 subn
et per client. This is designed to allow
−−port port point−to−point semantics when some or all of the connecting clien
TCP/UDP port number for both local and remote. The current def ts might be Windows systems. This is the
ault of 1194 represents the official IANA default on OpenVPN 2.0.
port number assignment for OpenVPN and has been used since version
2.0−beta17. Previous versions used port p2p −− Use a point−to−point topology where the remote endpoint of
5000 as the default. the client’s tun interface always points
to the local endpoint of the server’s tun interface. This mode a
−−lport port llocates a single IP address per connectâM−^@M−^P
TCP/UDP port number for bind. ing client. Only use when none of the connecting clients are Wind
ows systems. This mode is functionally
−−rport port equivalent to the −−ifconfig−pool−linear directive which is availa
TCP/UDP port number for remote. ble in OpenVPN 2.0 and is now deprecated.
−−bind Bind to local address and port. This is the default unless an subnet −− Use a subnet rather than a point−to−point topology by c
y of −−proto tcp−client , −−http−proxy or onfiguring the tun interface with a local
−−socks−proxy are used. IP address and subnet mask, similar to the topology used in −−dev
tap and ethernet bridging mode. This
Monday May 07, 2012 − 4/35
Printed by root

May 07, 12 21:14 − Page 9/69 May 07, 12 21:14 − Page 10/69
mode allocates a single IP address per connecting client and works are attempting to connect to a remote ethernet bridge, the IP addr
on Windows as well. Only available when ess and subnet should be set to values
server and clients are OpenVPN 2.1 or higher, or OpenVPN 2.0.x whi which would be valid on the the bridged ethernet segment (note als
ch has been manually patched with the o that DHCP can be used for the same purâM−^@M−^P
−−topology directive code. When used on Windows, requires versi pose).
on 8.2 or higher of the TAP−Win32 driver.
When used on *nix, requires that the tun driver supports an ifconf This option, while primarily a proxy for the ifconfig(8) command,
ig(8) command which sets a subnet instead is designed to simplify TUN/TAP tunnel
of a remote endpoint IP address. configuration by providing a standard interface to the differ
ent ifconfig implementations on different
This option exists in OpenVPN 2.1 or higher. platforms.
−−tun−ipv6 −−ifconfig parameters which are IP addresses can also be specified
Build a tun link capable of forwarding IPv6 traffic. Should be us as a DNS or /etc/hosts file resolvable
ed in conjunction with −−dev tun or −−dev name.
tunX. A warning will be displayed if no specific IPv6 TUN support
for your OS has been compiled into OpenâM−^@M−^P For TAP devices, −−ifconfig should not be used if the TAP inte
VPN. rface will be getting an IP address lease
from a DHCP server.
−−dev−node node
Explicitly set the device node rather than using /dev/net/tun, /d −−ifconfig−noexec
ev/tun, /dev/tap, etc. If OpenVPN cannot Don’t actually execute ifconfig/netsh commands, instead pass −−ifc
figure out whether node is a TUN or TAP device based on the name, onfig parameters to scripts using enviâM−^@M−^P
you should also specify −−dev−type tun or ronmental variables.
−−dev−type tap.
−−ifconfig−nowarn
On Windows systems, select the TAP−Win32 adapter which is name Don’t output an options consistency check warning if the −−ifcon
d node in the Network Connections Control fig option on this side of the connection
Panel or the raw GUID of the adapter enclosed by braces. The −−sh doesn’t match the remote side. This is useful when you want to re
ow−adapters option under Windows can also tain the overall benefits of the options
be used to enumerate all available TAP−Win32 adapters and will consistency check (also see −−disable−occ option) while only disab
show both the network connections control ling the ifconfig component of the check.
panel name and the GUID for each TAP−Win32 adapter.
For example, if you have a configuration where the local host uses
−−lladdr address −−ifconfig but the remote host does not,
Specify the link layer address, more commonly known as the MAC add use −−ifconfig−nowarn on the local host.
ress. Only applied to TAP devices.
This option will also silence warnings about potential address co
−−iproute cmd nflicts which occasionally annoy more
Set alternate command to execute instead of default iproute2 comma experienced users by triggering "false positive" warnings.
nd. May be used in order to execute
OpenVPN in unprivileged environment. −−route network/IP [netmask] [gateway] [metric]
Add route to routing table after connection is established. Multi
−−ifconfig l rn ple routes can be specified. Routes will
Set TUN/TAP adapter parameters. l is the IP address of the local be automatically torn down in reverse order prior to TUN/TAP devic
VPN endpoint. For TUN devices, rn is the e close.
IP address of the remote VPN endpoint. For TAP devices, rn is the
subnet mask of the virtual ethernet segâM−^@M−^P This option is intended as a convenience proxy for the route(8) sh
ment which is being created or connected to. ell command, while at the same time proâM−^@M−^P
viding portable semantics across OpenVPN’s platform space.
For TUN devices, which facilitate virtual point−to−point IP conne
ctions, the proper usage of −−ifconfig is netmask default −− 255.255.255.255
to use two private IP addresses which are not a member of any exis
ting subnet which is in use. The IP gateway default −− taken from −−route−gateway or the second parame
addresses may be consecutive and should have their order rever ter to −−ifconfig when −−dev tun is specâM−^@M−^P
sed on the remote peer. After the VPN is ified.
established, by pinging rn, you will be pinging across the VPN.
metric default −− taken from −−route−metric otherwise 0.
For TAP devices, which provide the ability to create virtual ether
net segments, −−ifconfig is used to set The default can be specified by leaving an option blank or setting
an IP address and subnet mask just as a physical ethernet adapt it to "nil".
er would be similarly configured. If you
Monday May 07, 2012 − 5/35
Printed by root

May 07, 12 21:14 − Page 11/69 May 07, 12 21:14 − Page 12/69
The network and gateway parameters can also be specified as a DNS variables.
or /etc/hosts file resolvable name, or as
one of three special keywords: −−route−nopull
When used with −−client or −−pull, accept options pushed by server
vpn_gateway −− The remote VPN endpoint address (derived either fro EXCEPT for routes.
m −−route−gateway or the second parameter
to −−ifconfig when −−dev tun is specified). When used on the client, this option effectively bars the server f
rom adding routes to the client’s routing
net_gateway −− The pre−existing IP default gateway, read from the table, however note that this option still allows the server to se
routing table (not supported on all t the TCP/IP properties of the client’s
OSes). TUN/TAP interface.

remote_host −− The −−remote address if OpenVPN is being run i −−allow−pull−fqdn


n client mode, and is undefined in server Allow client to pull DNS names from server (rather than bei
mode. ng limited to IP address) for −−ifconfig,
−−route, and −−route−gateway.
−−max−routes n
Allow a maximum number of n −−route options to be specified, eithe −−redirect−gateway flags...
r in the local configuration file, or (Experimental) Automatically execute routing commands to cause all
pulled from an OpenVPN server. By default, n=100. outgoing IP traffic to be redirected
over the VPN.
−−route−gateway gw|’dhcp’
Specify a default gateway gw for use with −−route. This option performs three steps:

If dhcp is specified as the parameter, the gateway address will (1) Create a static route for the −−remote address which forw
be extracted from a DHCP negotiation with ards to the pre−existing default gateway.
the OpenVPN server−side LAN. This is done so that (3) will not create a routing loop.

−−route−metric m (2) Delete the default gateway route.


Specify a default metric m for use with −−route.
(3) Set the new default gateway to be the VPN endpoint address (de
−−route−delay [n] [w] rived either from −−route−gateway or the
Delay n seconds (default=0) after connection establishment, before second parameter to −−ifconfig when −−dev tun is specified).
adding routes. If n is 0, routes will be
added immediately upon connection establishment. If −−route−delay When the tunnel is torn down, all of the above steps are rever
is omitted, routes will be added immediâM−^@M−^P sed so that the original default route is
ately after TUN/TAP device open and −−up script execution, before restored.
any −−user or −−group privilege downgrade
(or −−chroot execution.) Option flags:
This option is designed to be useful in scenarios where DHCP i local −− Add the local flag if both OpenVPN servers are directly c
s used to set tap adapter addresses. The onnected via a common subnet, such as
delay will give the DHCP handshake time to complete before routes with wireless. The local flag will cause step 1 above to be omitt
are added. ed.
On Windows, −−route−delay tries to be more intelligent by waiting def1 −− Use this flag to override the default gateway by us
w seconds (w=30 by default) for the TAP− ing 0.0.0.0/1 and 128.0.0.0/1 rather than
Win32 adapter to come up before adding routes. 0.0.0.0/0. This has the benefit of overriding but not wiping out
the original default gateway.
−−route−up cmd
Execute shell command cmd after routes are added, subject to −−rou bypass−dhcp −− Add a direct route to the DHCP server (if it is non
te−delay. −local) which bypasses the tunnel (AvailâM−^@M−^P
able on Windows clients, may not be available on non−Windows clien
See the "Environmental Variables" section below for additional ts).
parameters passed as environmental variâM−^@M−^P
ables. bypass−dns −− Add a direct route to the DNS server(s) (if they
are non−local) which bypasses the tunnel
Note that cmd can be a shell command with multiple arguments. (Available on Windows clients, may not be available on non−Windows
clients).
−−route−noexec
Don’t add or remove routes automatically. Instead pass routes to Using the def1 flag is highly recommended.
−−route−up script using environmental
Monday May 07, 2012 − 6/35
Printed by root

May 07, 12 21:14 − Page 13/69 May 07, 12 21:14 − Page 14/69
−−link−mtu n −−fragment adds 4 bytes of overhead per datagram.
Sets an upper bound on the size of UDP packets which are sent betw
een OpenVPN peers. It’s best not to set See the −−mssfix option below for an important related option to −
this parameter unless you know what you’re doing. −fragment.
−−tun−mtu n It should also be noted that this option is not meant to replace U
Take the TUN device MTU to be n and derive the link MTU from it DP fragmentation at the IP stack level.
(default=1500). In most cases, you will It is only meant as a last resort when path MTU discovery is bro
probably want to leave this parameter set to its default value. ken. Using this option is less efficient
than fixing path MTU discovery for your IP link and using native I
The MTU (Maximum Transmission Units) is the maximum datagram size P fragmentation instead.
in bytes that can be sent unfragmented
over a particular network path. OpenVPN requires that packet Having said that, there are circumstances where using OpenVPN’s in
s on the control or data channels be sent ternal fragmentation capability may be
unfragmented. your only option, such as tunneling a UDP multicast stream which r
equires fragmentation.
MTU problems often manifest themselves as connections which hang d
uring periods of active usage. −−mssfix max
Announce to TCP sessions running over the tunnel that they shoul
It’s best to use the −−fragment and/or −−mssfix options to deal wi d limit their send packet sizes such that
th MTU sizing issues. after OpenVPN has encapsulated them, the resulting UDP packet size
that OpenVPN sends to its peer will not
−−tun−mtu−extra n exceed max bytes.
Assume that the TUN/TAP device might return as many as n bytes mor
e than the −−tun−mtu size on read. This The max parameter is interpreted in the same way as the −−lin
parameter defaults to 0, which is sufficient for most TUN devic k−mtu parameter, i.e. the UDP packet size
es. TAP devices may introduce additional after encapsulation overhead has been added in, but not including
overhead in excess of the MTU size, and a setting of 32 is the def the UDP header itself.
ault when TAP devices are used. This
parameter only controls internal OpenVPN buffer sizing, so the The −−mssfix option only makes sense when you are using the UDP pr
re is no transmission overhead associated otocol for OpenVPN peer−to−peer communiâM−^@M−^P
with using a larger value. cation, i.e. −−proto udp.
−−mtu−disc type −−mssfix and −−fragment can be ideally used together, where −
Should we do Path MTU discovery on TCP/UDP channel? Only supporte −mssfix will try to keep TCP from needing
d on OSes such as Linux that supports the packet fragmentation in the first place, and if big packets come t
necessary system call to set. hrough anyhow (from protocols other than
TCP), −−fragment will internally fragment them.
’no’ −− Never send DF (Don’t Fragment) frames
’maybe’ −− Use per−route hints Both −−fragment and −−mssfix are designed to work around cases
’yes’ −− Always DF (Don’t Fragment) where Path MTU discovery is broken on the
network path between OpenVPN peers.
−−mtu−test
To empirically measure MTU on connection startup, add the −−mtu−te The usual symptom of such a breakdown is an OpenVPN connection whi
st option to your configuration. OpenVPN ch successfully starts, but then stalls
will send ping packets of various sizes to the remote peer and mea during active usage.
sure the largest packets which were sucâM−^@M−^P
cessfully received. The −−mtu−test process normally takes about 3 If −−fragment and −−mssfix are used together, −−mssfix will take i
minutes to complete. ts default max parameter from the −−fragâM−^@M−^P
ment max option.
−−fragment max
Enable internal datagram fragmentation so that no UDP datagrams ar Therefore, one could lower the maximum UDP packet size to 1300 (a
e sent which are larger than max bytes. good first try for solving MTU−related
connection problems) with the following options:
The max parameter is interpreted in the same way as the −−lin
k−mtu parameter, i.e. the UDP packet size −−tun−mtu 1500 −−fragment 1300 −−mssfix
after encapsulation overhead has been added in, but not including
the UDP header itself. −−sndbuf size
Set the TCP/UDP socket send buffer size. Currently defaults to 65
The −−fragment option only makes sense when you are using the UDP 536 bytes.
protocol ( −−proto udp ).
−−rcvbuf size
Monday May 07, 2012 − 7/35
Printed by root

May 07, 12 21:14 − Page 15/69 May 07, 12 21:14 − Page 16/69
Set the TCP/UDP socket receive buffer size. Currently defaults to e modes (where −−secret, −−tls−server, or
65536 bytes. −−tls−client is specified), the ping packet will be cryptographica
lly secure.
−−socket−flags flags...
Apply the given flags to the OpenVPN transport socket. Currently, This option has two intended uses:
only TCP_NODELAY is supported.
(1) Compatibility with stateful firewalls. The periodic ping will
The TCP_NODELAY socket flag is useful in TCP mode, and causes the ensure that a stateful firewall rule
kernel to send tunnel packets immediately which allows OpenVPN UDP packets to pass will not time out.
over the TCP connection without trying to group several smaller pa
ckets into a larger packet. This can (2) To provide a basis for the remote to test the existence of its
result in a considerably improvement in latency. peer using the −−ping−exit option.

This option is pushable from server to client, and should be u −−ping−exit n


sed on both client and server for maximum Causes OpenVPN to exit after n seconds pass without reception of
effect. a ping or other packet from remote. This
option can be combined with −−inactive, −−ping, and −−ping−exit to
−−txqueuelen n create a two−tiered inactivity disconâM−^@M−^P
(Linux only) Set the TX queue length on the TUN/TAP interface. Cu nect.
rrently defaults to 100.
For example,
−−shaper n
Limit bandwidth of outgoing tunnel data to n bytes per second on t openvpn [options...] −−inactive 3600 −−ping 10 −−ping−exit 60
he TCP/UDP port. If you want to limit
the bandwidth in both directions, use this option on both peers. when used on both peers will cause OpenVPN to exit within 60 secon
ds if its peer disconnects, but will exit
OpenVPN uses the following algorithm to implement traffic shaping after one hour if no actual tunnel data is exchanged.
: Given a shaper rate of n bytes per secâM−^@M−^P
ond, after a datagram write of b bytes is queued on the TCP/UDP po −−ping−restart n
rt, wait a minimum of (b / n) seconds Similar to −−ping−exit, but trigger a SIGUSR1 restart after n seco
before queuing the next write. nds pass without reception of a ping or
other packet from remote.
It should be noted that OpenVPN supports multiple tunnels between
the same two peers, allowing you to conâM−^@M−^P This option is useful in cases where the remote peer has a dyn
struct full−speed and reduced bandwidth tunnels at the same time, amic IP address and a low−TTL DNS name is
routing low−priority data such as off− used to track the IP address using a service such as http://dyndns
site backups over the reduced bandwidth tunnel, and other data ove .org/ + a dynamic DNS client such as
r the full−speed tunnel. ddclient.

Also note that for low bandwidth tunnels (under 1000 bytes per s If the peer cannot be reached, a restart will be triggered, caus
econd), you should probably use lower MTU ing the hostname used with −−remote to be
values as well (see above), otherwise the packet latency will grow re−resolved (if −−resolv−retry is also specified).
so large as to trigger timeouts in the
TLS layer and TCP connections running over the tunnel. In server mode, −−ping−restart, −−inactive, or any other type of i
nternally generated signal will always be
OpenVPN allows n to be between 100 bytes/sec and 100 Mbytes/sec. applied to individual client instance objects, never to whole serv
er itself. Note also in server mode that
−−inactive n [bytes] any internally generated signal which would normally cause a resta
Causes OpenVPN to exit after n seconds of inactivity on the TUN/T rt, will cause the deletion of the client
AP device. The time length of inactivity instance object instead.
is measured since the last incoming tunnel packet.
In client mode, the −−ping−restart parameter is set to 120 se
If the optional bytes parameter is included, exit after n seconds conds by default. This default will hold
of activity on tun/tap device produces a until the client pulls a replacement value from the server, based
combined in/out byte count that is less than bytes. on the −−keepalive setting in the server
configuration. To disable the 120 second default, set −−ping−rest
−−ping n art 0 on the client.
Ping remote over the TCP/UDP control channel if no packets have
been sent for at least n seconds (specify See the signals section below for more information on SIGUSR1.
−−ping on both peers to cause ping packets to be sent in both dire
ctions since OpenVPN ping packets are not Note that the behavior of SIGUSR1 can be modified by the −−persis
echoed like IP ping packets). When used in one of OpenVPN’s secur t−tun, −−persist−key, −−persist−local−ip,
Monday May 07, 2012 − 8/35
Printed by root

May 07, 12 21:14 − Page 17/69 May 07, 12 21:14 − Page 18/69
and −−persist−remote−ip options. Using this option ensures that key material and tunnel data are ne
ver written to disk due to virtual memory
Also note that −−ping−exit and −−ping−restart are mutually exclusi paging operations which occur under most modern operating systems.
ve and cannot be used together. It ensures that even if an attacker was
able to crack the box running OpenVPN, he would not be able to sc
−−keepalive n m an the system swap file to recover previâM−^@M−^P
A helper directive designed to simplify the expression of −−ping a ously used ephemeral keys, which are used for a period of time gov
nd −−ping−restart in server mode configuâM−^@M−^P erned by the −−reneg options (see below),
rations. then are discarded.

For example, −−keepalive 10 60 expands as follows: The downside of using −−mlock is that it will reduce the amo
unt of physical memory available to other
if mode server: applications.
ping 10
ping−restart 120 −−up cmd
push "ping 10" Shell command to run after successful TUN/TAP device open (pre −−u
push "ping−restart 60" ser UID change). The up script is useful
else for specifying route commands which route IP traffic destined for
ping 10 private subnets which exist at the other
ping−restart 60 end of the VPN connection into the tunnel.
−−ping−timer−rem For −−dev tun execute as:
Run the −−ping−exit / −−ping−restart timer only if we have a re
mote address. Use this option if you are cmd tun_dev tun_mtu link_mtu ifconfig_local_ip ifconfig_remote_ip
starting the daemon in listen mode (i.e. without an explicit −−rem [ init | restart ]
ote peer), and you don’t want to start
clocking timeouts until a remote peer connects. For −−dev tap execute as:

−−persist−tun cmd tap_dev tap_mtu link_mtu ifconfig_local_ip ifconfig_netmask [


Don’t close and reopen TUN/TAP device or run up/down scripts acros init | restart ]
s SIGUSR1 or −−ping−restart restarts.
See the "Environmental Variables" section below for additional par
SIGUSR1 is a restart signal similar to SIGHUP, but which offers fi ameters passed as environmental variâM−^@M−^P
ner−grained control over reset options. ables.

−−persist−key Note that cmd can be a shell command with multiple arguments, in w
Don’t re−read key files across SIGUSR1 or −−ping−restart. hich case all OpenVPN−generated arguments
will be appended to cmd to build a command line which will be pass
This option can be combined with −−user nobody to allow restarts t ed to the shell.
riggered by the SIGUSR1 signal. Normally
if you drop root privileges in OpenVPN, the daemon cannot be resta Typically, cmd will run a script to add routes to the tunnel.
rted since it will now be unable to re−
read protected key files. Normally the up script is called after the TUN/TAP device is opene
d. In this context, the last command
This option solves the problem by persisting keys across SIGUSR1 r line parameter passed to the script will be init. If the −−up−r
esets, so they don’t need to be re−read. estart option is also used, the up script
will be called for restarts as well. A restart is considered to b
−−persist−local−ip e a partial reinitialization of OpenVPN
Preserve initially resolved local IP address and port number acros where the TUN/TAP instance is preserved (the −−persist−tun
s SIGUSR1 or −−ping−restart restarts. option will enable such preservation). A
restart can be generated by a SIGUSR1 signal, a −−ping−restart tim
−−persist−remote−ip eout, or a connection reset when the TCP
Preserve most recently authenticated remote IP address and por protocol is enabled with the −−proto option. If a restart occurs,
t number across SIGUSR1 or −−ping−restart and −−up−restart has been specified, the
restarts. up script will be called with restart as the last parameter.
−−mlock The following standalone example shows how the −−up script can be
Disable paging by calling the POSIX mlockall function. Requires t called inboth an initialization and
hat OpenVPN be initially run as root restart context. (NOTE: for security reasons, don’t run the
(though OpenVPN can subsequently downgrade its UID using the −−use following example unless UDP port 9999 is
r option). blocked by your firewall. Also, the example will run indefinitely
, so you should abort with control−c).
Monday May 07, 2012 − 9/35
Printed by root

May 07, 12 21:14 − Page 19/69 May 07, 12 21:14 − Page 20/69
lid reasons for wanting new software feaâM−^@M−^P
openvpn −−dev tun −−port 9999 −−verb 4 −−ping−restart 10 −−up ’ech tures to gracefully degrade when encountered by older software ver
o up’ −−down ’echo down’ −−persist−tun sions.
−−up−restart
−−setenv−safe name value
Note that OpenVPN also provides the −−ifconfig option to automatic Set a custom environmental variable OPENVPN_name=value to pass to
ally ifconfig the TUN device, eliminating script.
the need to define an −−up script, unless you also want to configu
re routes in the −−up script. This directive is designed to be pushed by the server to clients,
and the prepending of "OPENVPN_" to the
If −−ifconfig is also specified, OpenVPN will pass the ifconfig lo environmental variable is a safety precaution to prevent a LD_PREL
cal and remote endpoints on the command OAD style attack from a malicious or comâM−^@M−^P
line to the −−up script so that they can be used to configure rout promised server.
es such as:
−−script−security level [method]
route add −net 10.0.0.0 netmask 255.255.255.0 gw $5 This directive offers policy−level control over OpenVPN’s usage of
external programs and scripts. Lower
−−up−delay level values are more restrictive, higher values are more permissi
Delay TUN/TAP open and possible −−up script execution until af ve. Settings for level:
ter TCP/UDP connection establishment with
peer. 0 −− Strictly no calling of external programs.
1 −− (Default) Only call built−in executables such as ifconfig, ip
In −−proto udp mode, this option normally requires the use of −−pi , route, or netsh.
ng to allow connection initiation to be 2 −− Allow calling of built−in executables and user−defined script
sensed in the absence of tunnel data, since UDP is a "connectionle s.
ss" protocol. 3 −− Allow passwords to be passed to scripts via environmental var
iables (potentially unsafe).
On Windows, this option will delay the TAP−Win32 media state tran
sitioning to "connected" until connection The method parameter indicates how OpenVPN should call external co
establishment, i.e. the receipt of the first authenticated packet mmands and scripts. Settings for method:
from the peer.
execve −− (default) Use execve() function on Unix family OSes and
−−down cmd CreateProcess() on Windows.
Shell command to run after TUN/TAP device close (post −−user UID c system −− Use system() function (deprecated and less safe since
hange and/or −−chroot ). Called with the the external program command line is subâM−^@M−^P
same parameters and environmental variables as the −−up option abo ject to shell expansion).
ve.
The −−script−security option was introduced in OpenVPN 2.1_rc9. F
Note that if you reduce privileges by using −−user and/or −−g or configuration file compatibility with
roup, your −−down script will also run at previous OpenVPN versions, use: −−script−security 3 system
reduced privilege.
−−disable−occ
−−down−pre Don’t output a warning message if option inconsistencies are
Call −−down cmd/script before, rather than after, TUN/TAP close. detected between peers. An example of an
option inconsistency would be where one peer uses −−dev tun while
−−up−restart the other peer uses −−dev tap.
Enable the −−up and −−down scripts to be called for restarts as we
ll as initial program start. This option Use of this option is discouraged, but is provided as a temporary
is described more fully above in the −−up option documentation. fix in situations where a recent version
of OpenVPN must connect to an old version.
−−setenv name value
Set a custom environmental variable name=value to pass to script. −−user user
Change the user ID of the OpenVPN process to user after initializa
−−setenv FORWARD_COMPATIBLE 1 tion, dropping privileges in the process.
Relax config file syntax checking so that unknown directives will This option is useful to protect the system in the event that some
trigger a warning but not a fatal error, hostile party was able to gain control
on the assumption that a given unknown directive might be valid in of an OpenVPN session. Though OpenVPN’s security features make
future OpenVPN versions. this unlikely, it is provided as a second
line of defense.
This option should be used with caution, as there are good securit
y reasons for having OpenVPN fail if it By setting user to nobody or somebody similarly unprivileged, the
detects problems in a config file. Having said that, there are va hostile party would be limited in what
Monday May 07, 2012 − 10/35
Printed by root

May 07, 12 21:14 − Page 21/69 May 07, 12 21:14 − Page 22/69
damage they could cause. Of course once you take away privile s are executed after the setcon operaâM−^@M−^P
ges, you cannot return them to an OpenVPN tion, which is why you should really consider using the −−persist−
session. This means, for example, that if you want to reset an Op key and −−persist−tun options.
enVPN daemon with a SIGUSR1 signal (for
example in response to a DHCP reset), you should make use of one o −−daemon [progname]
r more of the −−persist options to ensure Become a daemon after all initialization functions are completed
that OpenVPN doesn’t need to execute any privileged operations in . This option will cause all message and
order to restart (such as re−reading key error output to be sent to the syslog file (such as /var/log/messa
files or running ifconfig on the TUN device). ges), except for the output of shell
scripts and ifconfig commands, which will go to /dev/null unles
−−group group s otherwise redirected. The syslog rediâM−^@M−^P
Similar to the −−user option, this option changes the group ID o rection occurs immediately at the point that −−daemon is parsed on
f the OpenVPN process to group after iniâM−^@M−^P the command line even though the daemoâM−^@M−^P
tialization. nization point occurs later. If one of the −−log options is prese
nt, it will supercede syslog redirection.
−−cd dir
Change directory to dir prior to reading any files such as configu The optional progname parameter will cause OpenVPN to report its p
ration files, key files, scripts, etc. rogram name to the system logger as progâM−^@M−^P
dir should be an absolute path, with a leading "/", and withou name. This can be useful in linking OpenVPN messages in the sysl
t any references to the current directory og file with specific tunnels. When
such as "." or "..". unspecified, progname defaults to "openvpn".
This option is useful when you are running OpenVPN in −−daemon mod When OpenVPN is run with the −−daemon option, it will try to delay
e, and you want to consolidate all of daemonization until the majority of iniâM−^@M−^P
your OpenVPN control files in one location. tialization functions which are capable of generating fatal errors
are complete. This means that initialâM−^@M−^P
−−chroot dir ization scripts can test the return status of the openvpn co
Chroot to dir after initialization. −−chroot essentially redef mmand for a fairly reliable indication of
ines dir as being the top level directory whether the command has correctly initialized and entered the pack
tree (/). OpenVPN will therefore be unable to access any files ou et forwarding event loop.
tside this tree. This can be desirable
from a security standpoint. In OpenVPN, the vast majority of errors which occur after initiali
zation are non−fatal.
Since the chroot operation is delayed until after initialization,
most OpenVPN options that reference files −−syslog [progname]
will operate in a pre−chroot context. Direct log output to system logger, but do not become a daemon. S
ee −−daemon directive above for descripâM−^@M−^P
In many cases, the dir parameter can point to an empty directory, tion of progname parameter.
however complications can result when
scripts or restarts are executed after the chroot operation. −−passtos
Set the TOS field of the tunnel packet to what the payload’s TOS i
−−setcon context s.
Apply SELinux context after initialization. This essentially p
rovides the ability to restrict OpenVPN’s −−inetd [wait|nowait] [progname]
rights to only network I/O operations, thanks to SELinux. This goe Use this option when OpenVPN is being run from the inetd or xinetd
s further than −−user and −−chroot in (8) server.
that those two, while being great security features, unfortunately
do not protect against privilege escalaâM−^@M−^P The wait/nowait option must match what is specified in the inetd
tion by exploitation of a vulnerable system call. You can of cours /xinetd config file. The nowait mode can
e combine all three, but please note that only be used with −−proto tcp−server. The default is wait. The n
since setcon requires access to /proc you will have to provide owait mode can be used to instantiate the
it inside the chroot directory (e.g. with OpenVPN daemon as a classic TCP server, where client connection re
mount −−bind). quests are serviced on a single port numâM−^@M−^P
ber. For additional information on this kind of configuratio
Since the setcon operation is delayed until after initialization, n, see the OpenVPN FAQ: http://openâM−^@M−^P
OpenVPN can be restricted to just netâM−^@M−^P vpn.net/faq.html#oneport
work−related system calls, whereas by applying the context before
startup (such as the OpenVPN one provided This option precludes the use of −−daemon, −−local, or −−remote.
in the SELinux Reference Policies) you will have to allow many thi Note that this option causes message and
ngs required only during initialization. error output to be handled in the same way as the −−daemon option.
The optional progname parameter is also
Like with chroot, complications can result when scripts or restart handled exactly as in −−daemon.
Monday May 07, 2012 − 11/35
Printed by root

May 07, 12 21:14 − Page 23/69 May 07, 12 21:14 − Page 24/69
terface. Note that this option is only
Also note that in wait mode, each OpenVPN tunnel requires a sepa relevant for UDP servers and currently is only implemented on Linu
rate TCP/UDP port and a separate inetd or x.
xinetd entry. See the OpenVPN 1.x HOWTO for an example on us
ing OpenVPN with xinetd: http://openâM−^@M−^P Note: clients connecting to a −−multihome server should always use
vpn.net/1xhowto.html the −−nobind option.

−−log file −−echo [parms...]


Output logging messages to file, including output to stdout/std Echo parms to log output.
err which is generated by called scripts.
If file already exists it will be truncated. This option takes ef Designed to be used to send messages to a controlling applicatio
fect immediately when it is parsed in the n which is receiving the OpenVPN log outâM−^@M−^P
command line and will supercede syslog output if −−daemon or − put.
−inetd is also specified. This option is
persistent over the entire course of an OpenVPN instantiation and −−remap−usr1 signal
will not be reset by SIGHUP, SIGUSR1, or Control whether internally or externally generated SIGUSR1 signals
−−ping−restart. are remapped to SIGHUP (restart without
persisting state) or SIGTERM (exit).
Note that on Windows, when OpenVPN is started as a service, logg
ing occurs by default without the need to signal can be set to "SIGHUP" or "SIGTERM". By default, no remapp
specify this option. ing occurs.

−−log−append file −−verb n


Append logging messages to file. If file does not exist, it will Set output verbosity to n (default=1). Each level shows all i
be created. This option behaves exactly nfo from the previous levels. Level 3 is
like −−log except that it appends to rather than truncating the lo recommended if you want a good summary of what’s happening without
g file. being swamped by output.

−−suppress−timestamps 0 −− No output except fatal errors.


Avoid writing timestamps to log messages, even when they otherwis 1 to 4 −− Normal usage range.
e would be prepended. In particular, this 5 −− Output R and W characters to the console for each packet read
applies to log messages sent to stdout. and write, uppercase is used for TCP/UDP
packets and lowercase is used for TUN/TAP packets.
−−writepid file 6 to 11 −− Debug info range (see errlevel.h for additional informa
Write OpenVPN’s main process ID to file. tion on debug levels).

−−nice n −−status file [n]


Change process priority after initialization ( n greater than 0 is Write operational status to file every n seconds.
lower priority, n less than zero is
higher priority). Status can also be written to the syslog by sending a SIGUSR2 sign
al.
−−fast−io
(Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a cal −−status−version [n]
l to poll/epoll/select prior to the write Choose the status file format version number. Currently n can be
operation. The purpose of such a call would normally be to block 1, 2, or 3 and defaults to 1.
until the device or socket is ready to
accept the write. Such blocking is unnecessary on some platforms −−mute n
which don’t support write blocking on UDP Log at most n consecutive messages in the same category. This
sockets or TUN/TAP devices. In such cases, one can optim is useful to limit repetitive logging of
ize the event loop by avoiding the similar message types.
poll/epoll/select call, improving CPU efficiency by 5% to 10%.
−−comp−lzo [mode]
This option can only be used on non−Windows systems, when −−pro Use fast LZO compression −− may add up to 1 byte per packet for in
to udp is specified, and when −−shaper is compressible data. mode may be "yes",
NOT specified. "no", or "adaptive" (default).

−−multihome In a server mode setup, it is possible to selectively turn compres


Configure a multi−homed UDP server. This option can be used when sion on or off for individual clients.
OpenVPN has been configured to listen on
all interfaces, and will attempt to bind client sessions to First, make sure the client−side config file enables selective c
the interface on which packets are being ompression by having at least one −−comp−
received, so that outgoing packets will be sent out of the same in lzo directive, such as −−comp−lzo no. This will turn off compress
Monday May 07, 2012 − 12/35
Printed by root

May 07, 12 21:14 − Page 25/69 May 07, 12 21:14 − Page 26/69
ion by default, but allow a future direcâM−^@M−^P folder of the OpenVPN source distribution.
tive push from the server to dynamically change the on/off/adaptiv
e setting. It is strongly recommended that IP be set to 127.0.0.1 (localhost)
to restrict accessibility of the manageâM−^@M−^P
Next in a −−client−config−dir file, specify the compression settin ment server to local clients.
g for the client, for example:
−−management−query−passwords
comp−lzo yes Query management channel for private key password and −−auth−user−
push "comp−lzo yes" pass username/password. Only query the
management channel for inputs which ordinarily would have been que
The first line sets the comp−lzo setting for the server side of th ried from the console.
e link, the second sets the client side.
−−management−forget−disconnect
−−comp−noadapt Make OpenVPN forget passwords when management session disconnects.
When used in conjunction with −−comp−lzo, this option will dis
able OpenVPN’s adaptive compression algoâM−^@M−^P This directive does not affect the −−http−proxy username/password.
rithm. Normally, adaptive compression is enabled with −−comp−lzo. It is always cached.

Adaptive compression tries to optimize the case where you have com −−management−hold
pression enabled, but you are sending Start OpenVPN in a hibernating state, until a client of the manag
predominantly uncompressible (or pre−compressed) packets over the ement interface explicitly starts it with
tunnel, such as an FTP or rsync transfer the hold release command.
of a large, compressed file. With adaptive compression, OpenVPN w
ill periodically sample the compression −−management−signal
process to measure its efficiency. If the data being sent over t Send SIGUSR1 signal to OpenVPN if management session disconnects.
he tunnel is already compressed, the comâM−^@M−^P This is useful when you wish to disconâM−^@M−^P
pression efficiency will be very low, triggering openvpn to disabl nect an OpenVPN session on user logoff.
e compression for a period of time until
the next re−sample test. −−management−log−cache n
Cache the most recent n lines of log file history for usage by the
−−management IP port [pw−file] management channel.
Enable a TCP server on IP:port to handle daemon management functio
ns. pw−file, if specified, is a password −−management−client−auth
file (password on first line) or "stdin" to prompt from standard i Gives management interface client the responsibility to authentica
nput. The password provided will set the te clients after their client certificate
password which TCP clients will need to provide in order to access has been verified. See management−notes.txt in OpenVPN distributi
management functions. on for detailed notes.

The management interface can also listen on a unix domain socket, −−management−client−pf
for those platforms that support it. To Management interface clients must specify a packet filter file for
use a unix domain socket, specify the unix socket pathname in plac each connecting client. See management−
e of IP and set port to ’unix’. While notes.txt in OpenVPN distribution for detailed notes.
the default behavior is to create a unix domain socket that may b
e connected to by any process, the −−manâM−^@M−^P −−management−client−user u
agement−client−user and −−management−client−group directives can b When the management interface is listening on a unix domain socket
e used to restrict access. , only allow connections from user u.

The management interface provides a special mode where the TCP man −−management−client−group g
agement link can operate over the tunnel When the management interface is listening on a unix domain socket
itself. To enable this mode, set IP = "tunnel". Tunnel mode will , only allow connections from group g.
cause the management interface to listen
for a TCP connection on the local VPN address of the TUN/TAP inter −−plugin module−pathname [init−string]
face. Load plug−in module from the file module−pathname, passing init
−string as an argument to the module iniâM−^@M−^P
While the management port is designed for programmatic control of tialization function. Multiple plugin modules may be loaded into
OpenVPN by other applications, it is posâM−^@M−^P one OpenVPN process.
sible to telnet to the port, using a telnet client in "raw" mode
. Once connected, type "help" for a list For more information and examples on how to build OpenVPN plug−in
of commands. modules, see the README file in the plugâM−^@M−^P
in folder of the OpenVPN source distribution.
For detailed documentation on the management interface, see the ma
nagement−notes.txt file in the management If you are using an RPM install of OpenVPN, see /usr/share/openvpn
Monday May 07, 2012 − 13/35
Printed by root

May 07, 12 21:14 − Page 27/69 May 07, 12 21:14 − Page 28/69
/plugin. The documentation is in doc and −−server−bridge [’nogw’]
the actual plugin modules are in lib.
A helper directive similar to −−server which is designed to simpli
Multiple plugin modules can be cascaded, and modules can be used i fy the configuration of OpenVPN’s server
n tandem with scripts. The modules will mode in ethernet bridging configurations.
be called by OpenVPN in the order that they are declared in the
config file. If both a plugin and script If −−server−bridge is used without any parameters, it will enable
are configured for the same callback, the script will be called la a DHCP−proxy mode, where connecting OpenâM−^@M−^P
st. If the return code of the modâM−^@M−^P VPN clients will receive an IP address for their TAP adapter from
ule/script controls an authentication function (such as tls−veri the DHCP server running on the OpenVPN
fy, auth−user−pass−verify, or client−conâM−^@M−^P server−side LAN. Note that only clients that support the bind
nect), then every module and script must return success (0) in ord ing of a DHCP client with the TAP adapter
er for the connection to be authentiâM−^@M−^P (such as Windows) can support this mode. The optional nogw flag (
cated. advanced) indicates that gateway informaâM−^@M−^P
tion should not be pushed to the client.
Server Mode
Starting with OpenVPN 2.0, a multi−client TCP/UDP server mode is supp To configure ethernet bridging, you must first use your OS’s bri
orted, and can be enabled with the −−mode dging capability to bridge the TAP interâM−^@M−^P
server option. In server mode, OpenVPN will listen on a single port for face with the ethernet NIC interface. For example, on Linux this
incoming client connections. All client is done with the brctl tool, and with
connections will be routed through a single tun or tap interface. Windows XP it is done in the Network Connections Panel by se
This mode is designed for scalability and lecting the ethernet and TAP adapters and
should be able to support hundreds or even thousands of clients on suffic right−clicking on "Bridge Connections".
iently fast hardware. SSL/TLS authentiâM−^@M−^P
cation must be used in this mode. Next you you must manually set the IP/netmask on the bridge interf
ace. The gateway and netmask parameters
−−server network netmask to −−server−bridge can be set to either the IP/netmask of the b
A helper directive designed to simplify the configuration of Op ridge interface, or the IP/netmask of the
enVPN’s server mode. This directive will default gateway/router on the bridged subnet.
set up an OpenVPN server which will allocate addresses to clients
out of the given network/netmask. The Finally, set aside a IP range in the bridged subnet, denoted by po
server itself will take the ".1" address of the given network f ol−start−IP and pool−end−IP, for OpenVPN
or use as the server−side endpoint of the to allocate to connecting clients.
local TUN/TAP interface.
For example, server−bridge 10.8.0.4 255.255.255.0 10.8.0.128 10.8.
For example, −−server 10.8.0.0 255.255.255.0 expands as follows: 0.254 expands as follows:
mode server mode server
tls−server tls−server
push "topology [topology]"
ifconfig−pool 10.8.0.128 10.8.0.254 255.255.255.0
if dev tun AND (topology == net30 OR topology == p2p): push "route−gateway 10.8.0.4"
ifconfig 10.8.0.1 10.8.0.2
if !nopool: In another example, −−server−bridge (without parameters) expands a
ifconfig−pool 10.8.0.4 10.8.0.251 s follows:
route 10.8.0.0 255.255.255.0
if client−to−client: mode server
push "route 10.8.0.0 255.255.255.0" tls−server
else if topology == net30:
push "route 10.8.0.1" push "route−gateway dhcp"
if dev tap OR (dev tun AND topology == subnet): Or −−server−bridge nogw expands as follows:
ifconfig 10.8.0.1 255.255.255.0
if !nopool: mode server
ifconfig−pool 10.8.0.2 10.8.0.254 255.255.255.0 tls−server
push "route−gateway 10.8.0.1"
−−push option
Don’t use −−server if you are ethernet bridging. Use −−server−bri Push a config file option back to the client for remote executi
dge instead. on. Note that option must be enclosed in
double quotes (""). The client must specify −−pull in its config
−−server−bridge gateway netmask pool−start−IP pool−end−IP file. The set of options which can be
pushed is limited by both feasibility and security. Some options
Monday May 07, 2012 − 14/35
Printed by root

May 07, 12 21:14 − Page 29/69 May 07, 12 21:14 − Page 30/69
such as those which would execute scripts
are banned, since they would effectively allow a compromised serv Note that the entries in this file are treated by OpenVPN as sug
er to execute arbitrary code on the gestions only, based on past associations
client. Other options such as TLS or MTU parameters cannot be pus between a common name and IP address. They do not guarantee that
hed because the client needs to know them the given common name will always receive
before the connection to the server can be initiated. the given IP address. If you want guaranteed assignment, use −−if
config−push
This is a partial list of options which can currently be pushed: −
−route, −−route−gateway, −−route−delay, −−ifconfig−pool−linear
−−redirect−gateway, −−ip−win32, −−dhcp−option, −−inactive, −−pin Modifies the −−ifconfig−pool directive to allocate individual T
g, −−ping−exit, −−ping−restart, −−setenv, UN interface addresses for clients rather
−−persist−key, −−persist−tun, −−echo, −−comp−lzo, −−socket−flags, than /30 subnets. NOTE: This option is incompatible with Windows
−−sndbuf, −−rcvbuf clients.
−−push−reset This option is deprecated, and should be replaced with −−topology
Don’t inherit the global push list for a specific client instance. p2p which is functionally equivalent.
Specify this option in a client−speâM−^@M−^P
cific context such as with a −−client−config−dir configurat −−ifconfig−push local remote−netmask
ion file. This option will ignore −−push Push virtual IP endpoints for client tunnel, overriding the −−ifco
options at the global config file level. nfig−pool dynamic allocation.
−−disable The parameters local and remote−netmask are set according to the −
Disable a particular client (based on the common name) from connec −ifconfig directive which you want to
ting. Don’t use this option to disable a execute on the client machine to configure the remote end of th
client due to key or password compromise. Use a CRL (certificate e tunnel. Note that the parameters local
revocation list) instead (see the −−crl− and remote−netmask are from the perspective of the client, not the
verify option). server. They may be DNS names rather
than IP addresses, in which case they will be resolved on the serv
This option must be associated with a specific client instance, wh er at the time of client connection.
ich means that it must be specified
either in a client instance config file using −−client−con This option must be associated with a specific client instan
fig−dir or dynamically generated using a ce, which means that it must be specified
−−client−connect script. either in a client instance config file using −−client−config−
dir or dynamically generated using a
−−ifconfig−pool start−IP end−IP [netmask] −−client−connect script.
Set aside a pool of subnets to be dynamically allocated to connect
ing clients, similar to a DHCP server. Remember also to include a −−route directive in the main OpenVPN
For tun−style tunnels, each client will be given a /30 subnet (fo config file which encloses local, so that
r interoperability with Windows clients). the kernel will know to route it to the server’s TUN/TAP interface
For tap−style tunnels, individual addresses will be allocated, and .
the optional netmask parameter will also
be pushed to clients. OpenVPN’s internal client IP address selection algorithm works as
follows:
−−ifconfig−pool−persist file [seconds] 1 −− Use −−client−connect script generated file for static IP (fir
Persist/unpersist ifconfig−pool data to file, at seconds inter st choice).
vals (default=600), as well as on program 2 −− Use −−client−config−dir file for static IP (next choice).
startup and shutdown. 3 −− Use −−ifconfig−pool allocation for dynamic IP (last choice).
The goal of this option is to provide a long−term association betw −−iroute network [netmask]
een clients (denoted by their common Generate an internal route to a specific client. The netmas
name) and the virtual IP address assigned to them from the ifconfi k parameter, if omitted, defaults to
g−pool. Maintaining a long−term associaâM−^@M−^P 255.255.255.255.
tion is good for clients because it allows them to effectively use
the −−persist−tun option. This directive can be used to route a fixed subnet from the ser
ver to a particular client, regardless of
file is a comma−delimited ASCII file, formatted as <Common−Name>,< where the client is connecting from. Remember that you must also
IP−address>. add the route to the system routing table
as well (such as by using the −−route directive). The reason why
If seconds = 0, file will be treated as read−only. This is useful two routes are needed is that the −−route
if you would like to treat file as a directive routes the packet from the kernel to OpenVPN. Once in O
configuration file. penVPN, the −−iroute directive routes to
Monday May 07, 2012 − 15/35
Printed by root

May 07, 12 21:14 − Page 31/69 May 07, 12 21:14 − Page 32/69
the specific client. l not be called unless the −−client−conâM−^@M−^P
nect script and plugins (if defined) were previously called on
This option must be specified either in a client instance config this instance with successful (0) status
file using −−client−config−dir or dynamiâM−^@M−^P returns.
cally generated using a −−client−connect script.
The exception to this rule is if the −−client−disconnect script or
The −−iroute directive also has an important interaction with −−pu plugins are cascaded, and at least one
sh "route ...". −−iroute essentially client−connect function succeeded, then ALL of the client−disconne
defines a subnet which is owned by a particular client (we wil ct functions for scripts and plugins will
l call this client A). If you would like be called on client instance object deletion, even in cases where
other clients to be able to reach A’s subnet, you can use −−push " some of the related client−connect funcâM−^@M−^P
route ..." together with −−client−to− tions returned an error status.
client to effect this. In order for all clients to see A’s su
bnet, OpenVPN must push this route to all −−client−config−dir dir
clients EXCEPT for A, since the subnet is already owned by A. Ope Specify a directory dir for custom client config files. After a
nVPN accomplishes this by not not pushing connecting client has been authenticated,
a route to a client if it matches one of the client’s iroutes. OpenVPN will look in this directory for a file having the same nam
e as the client’s X509 common name. If a
−−client−to−client matching file exists, it will be opened and parsed for client−spec
Because the OpenVPN server mode handles multiple clients thr ific configuration options. If no matchâM−^@M−^P
ough a single tun or tap interface, it is ing file is found, OpenVPN will instead try to open and parse a de
effectively a router. The −−client−to−client flag tells OpenVPN t fault file called "DEFAULT", which may be
o internally route client−to−client trafâM−^@M−^P provided but is not required.
fic rather than pushing all client−originating traffic to the TUN/
TAP interface. This file can specify a fixed IP address for a given client using
−−ifconfig−push, as well as fixed subnets
When this option is used, each client will "see" the other clien owned by the client using −−iroute.
ts which are currently connected. OtherâM−^@M−^P
wise, each client will only see the server. Don’t use this option One of the useful properties of this option is that it allows clie
if you want to firewall tunnel traffic nt configuration files to be conveniently
using custom, per−client rules. created, edited, or removed while the server is live, without need
ing to restart the server.
−−duplicate−cn
Allow multiple clients with the same common name to concurrently The following options are legal in a client−specific context: −−
connect. In the absence of this option, push, −−push−reset, −−iroute, −−ifconfig−
OpenVPN will disconnect a client instance upon connection of a new push, and −−config.
client having the same common name.
−−ccd−exclusive
−−client−connect script Require, as a condition of authentication, that a connecting clien
Run script on client connection. The script is passed the common t has a −−client−config−dir file.
name and IP address of the just−authentiâM−^@M−^P
cated client as environmental variables (see environmental var −−tmp−dir dir
iable section below). The script is also Specify a directory dir for temporary files. This directory will
passed the pathname of a not−yet−created temporary file as $1 (i.e be used by −−client−connect scripts to
. the first command line argument), to be dynamically generate client−specific configuration files.
used by the script to pass dynamically generated config file direc
tives back to OpenVPN. −−hash−size r v
Set the size of the real address hash table to r and the virt
If the script wants to generate a dynamic config file to be applie ual address table to v. By default, both
d on the server when the client connects, tables are sized at 256 buckets.
it should write it to the file named by $1.
−−bcast−buffers n
See the −−client−config−dir option below for options which can be Allocate n buffers for broadcast datagrams (default=256).
legally used in a dynamically generated
config file. −−tcp−queue−limit n
Maximum number of output packets queued before TCP (default=64).
Note that the return value of script is significant. If script
returns a non−zero error status, it will When OpenVPN is tunneling data from a TUN/TAP device to a remote c
cause the client to be disconnected. lient over a TCP connection, it is possiâM−^@M−^P
ble that the TUN/TAP device might produce data at a faster rate t
−−client−disconnect han the TCP connection can support. When
Like −−client−connect but called on client instance shutdown. Wil the number of output packets queued before sending to the TCP sock
Monday May 07, 2012 − 16/35
Printed by root

May 07, 12 21:14 − Page 33/69 May 07, 12 21:14 − Page 34/69
et reaches this limit for a given client his can bean IPv4 address such as
connection, OpenVPN will start to drop outgoing packets directed a "198.162.10.14", an IPv4 subnet such as "198.162.10.0/24", or an e
t this client. thernet MAC address (when −−dev tap is
being used) such as "00:FF:01:02:03:04".
−−tcp−nodelay [3] common name −− The common name on the certificate associate
This macro sets the TCP_NODELAY socket flag on the server as well d with the client linked to this address.
as pushes it to connecting clients. The Only present for "add" or "update" operations, not "delete".
TCP_NODELAY flag disables the Nagle algorithm on TCP sockets causi
ng packets to be transmitted immediately On "add" or "update" methods, if the script returns a failure code
with low latency, rather than waiting a short period of time in (non−zero), OpenVPN will reject the
order to aggregate several packets into a address and will not modify its internal routing table.
larger containing packet. In VPN applications over TCP, TCP_NODEL
AY is generally a good latency optimizaâM−^@M−^P Normally, the cmd script will use the information provided above t
tion. o set appropriate firewall entries on the
VPN TUN/TAP interface. Since OpenVPN provides the association bet
The macro expands as follows: ween virtual IP or MAC address and the
client’s authenticated common name, it allows a user−defined scr
if mode server: ipt to configure firewall access policies
socket−flags TCP_NODELAY with regard to the client’s high−level common name, rather than th
push "socket−flags TCP_NODELAY" e low level client virtual addresses.

−−max−clients n −−auth−user−pass−verify script method


Limit server to a maximum of n concurrent clients. Require the client to provide a username/password (possibly in a
ddition to a client certificate) for
−−max−routes−per−client n authentication.
Allow a maximum of n internal routes per client (default=25
6). This is designed to help contain DoS OpenVPN will execute script as a shell command to validate the use
attacks where an authenticated client floods the server with packe rname/password provided by the client.
ts appearing to come from many unique MAC
addresses, forcing the server to deplete virtual memory as its int If method is set to "via−env", OpenVPN will call script with the e
ernal routing table expands. This direcâM−^@M−^P nvironmental variables username and passâM−^@M−^P
tive can be used in a −−client−config−dir file or auto−generated b word set to the username/password strings provided by the client.
y a −−client−connect script to override Be aware that this method is insecure on
the global value for a particular client. some platforms which make the environment of a process publicly vi
sible to other unprivileged processes.
Note that this directive affects OpenVPN’s internal routing table,
not the kernel routing table. If method is set to "via−file", OpenVPN will write the username
and password to the first two lines of a
−−connect−freq n sec temporary file. The filename will be passed as an argument to scr
Allow a maximum of n new connections per sec seconds from clients. ipt, and the file will be automatically
This is designed to contain DoS attacks deleted by OpenVPN after the script returns. The location o
which flood the server with connection requests using certificates f the temporary file is controlled by the
which will ultimately fail to authentiâM−^@M−^P −−tmp−dir option, and will default to the current directory if uns
cate. pecified. For security, consider setting
−−tmp−dir to a volatile storage medium such as /dev/shm (if av
This is an imperfect solution however, because in a real DoS scena ailable) to prevent the username/password
rio, legitimate connections might also be file from touching the hard drive.
refused.
The script should examine the username and password, returning a s
For the best protection against DoS attacks in server mode, use −− uccess exit code (0) if the client’s
proto udp and −−tls−auth. authentication request is to be accepted, or a failure code (1) to
reject the client.
−−learn−address cmd
Run script or shell command cmd to validate client virtual address This directive is designed to enable a plugin−style interface for
es or routes. extending OpenVPN’s authentication capaâM−^@M−^P
bilities.
cmd will be executed with 3 parameters:
To protect against a client passing a maliciously formed username
[1] operation −− "add", "update", or "delete" based on whether or or password string, the username string
not the address is being added to, modiâM−^@M−^P must consist only of these characters: alphanumeric, underbar (
fied, or deleted from OpenVPN’s internal routing table. ’_’), dash (’−’), dot (’.’), or at (’@’).
[2] address −− The address being learned or unlearned. T The password string can consist of any printable characters except
Monday May 07, 2012 − 17/35
Printed by root

May 07, 12 21:14 − Page 35/69 May 07, 12 21:14 − Page 36/69
for CR or LF. Any illegal characters in
either the username or password string will be converted to underb −−username−as−common−name
ar (’_’). For −−auth−user−pass−verify authentication, use the authenticated
username as the common name, rather than
Care must be taken by any user−defined scripts to avoid creating the common name from the client cert.
a security vulnerability in the way that
these strings are handled. Never use these strings in such a way −−no−name−remapping
that they might be escaped or evaluated Allow Common Name, X509 Subject, and username strings to include
by a shell interpreter. any printable character including space,
but excluding control characters such as tab, newline, and carriag
For a sample script that performs PAM authentication, see sample− e−return.
scripts/auth−pam.pl in the OpenVPN source
distribution. By default, OpenVPN will remap any character other than alphanume
ric, underbar (’_’), dash (’−’), dot
−−opt−verify (’.’), and slash (’/’) to underbar (’_’). The X509 Subject strin
Clients that connect with options that are incompatible with those g as returned by the tls_id environmental
of the server will be disconnected. variable, can additionally contain colon (’:’) or equal (’=’).

Options that will be compared for compatibility include dev−type While name remapping is performed for security reasons to reduce
, link−mtu,
tun−mtu, proto, tun−ipv6, the possibility of introducing string
ifconfig, comp−lzo, fragment, keydir, cipher, auth, keysize, expansion security vulnerabilities in user−defined authentica
secret, no−replay, no−iv, tls−auth, key− tion scripts, this option is provided for
method, tls−server, and tls−client. those cases where it is desirable to disable the remapping feature
. Don’t use this option unless you know
This option requires that −−disable−occ NOT be used. what you are doing!

−−auth−user−pass−optional −−port−share host port


Allow connections by clients that do not specify a username/passwo When run in TCP server mode, share the OpenVPN port with another
rd. Normally, when −−auth−user−pass−verâM−^@M−^P application, such as an HTTPS server. If
ify or −−management−client−auth is specified (or an authenticatio OpenVPN senses a connection to its port which is using a non−OpenV
n plugin module), the OpenVPN server daeâM−^@M−^P PN protocol, it will proxy the connection
mon will require connecting clients to specify a username and pass to the server at host:port. Currently only designed to work with
word. This option makes the submission HTTP/HTTPS, though it would be theoretiâM−^@M−^P
of a username/password by clients optional, passing the responsi cally possible to extend to other protocols such as ssh.
bility to the user−defined authentication
module/script to accept or deny the client based on other factors Not implemented on Windows.
(such as the setting of X509 certificate
fields). When this option is used, and a connecting client does Client Mode
not submit a username/password, the user− Use client mode when connecting to an OpenVPN server which has −−server,
defined authentication module/script will see the username and pas −−server−bridge, or −−mode server in it’s
sword as being set to empty strings (""). configuration.
The authentication module/script MUST have logic to detect this co
ndition and respond accordingly. −−client
A helper directive designed to simplify the configuration of
−−client−cert−not−required OpenVPN’s client mode. This directive is
Don’t require client certificate, client will authenticate usi equivalent to:
ng username/password only. Be aware that
using this directive is less secure than requiring certificates fr pull
om all clients. tls−client

If you use this directive, the entire responsibility of authentica −−pull This option must be used on a client which is connecting to a mult
tion will rest on your −−auth−user−pass− i−client server. It indicates to OpenVPN
verify script, so keep in mind that bugs in your script could po that it should accept options pushed by the server, provided t
tentially compromise the security of your hey are part of the legal set of pushable
VPN. options (note that the −−pull option is implied by −−client ).

If you don’t use this directive, but you also specify an −−auth−us In particular, −−pull allows the server to push routes to the clie
er−pass−verify script, then OpenVPN will nt, so youshould not use −−pull or
perform double authentication. The client certificate verificati −−client in situations where you don’t trust the server to have co
on AND the −−auth−user−pass−verify script ntrol over the client’s routing table.
will need to succeed in order for a client to be authenticated and
accepted onto the VPN. −−auth−user−pass [up]
Monday May 07, 2012 − 18/35
Printed by root

May 07, 12 21:14 − Page 37/69 May 07, 12 21:14 − Page 38/69
Authenticate with server using username/password. up is a fil Enable Static Key encryption mode (non−TLS). Use pre−shared secre
e containing username/password on 2 lines t file which was generated with −−genkey.
(Note: OpenVPN will only read passwords from a file if it has been
built with the −−enable−password−save The optional direction parameter enables the use of 4 distin
configure option, or on Windows by defining ENABLE_PASSWORD_SAVE i ct keys (HMAC−send, cipher−encrypt, HMAC−
n config−win32.h). receive, cipher−decrypt), so that each data flow direction has a d
ifferent set of HMAC and cipher keys.
If up is omitted, username/password will be prompted from the cons This has a number of desirable security properties including eli
ole. minating certain kinds of DoS and message
replay attacks.
The server configuration must specify an −−auth−user−pass−veri
fy script to verify the username/password When the direction parameter is omitted, 2 keys are used bidirecti
provided by the client. onally, one for HMAC and the other for
encryption/decryption.
−−auth−retry type
Controls how OpenVPN responds to username/password verification er The direction parameter should always be complementary on eit
rors such as the client−side response to her side of the connection, i.e. one side
an AUTH_FAILED message from the server or verification failure of should use "0" and the other should use "1", or both sides should
the private key password. omit it altogether.

Normally used to prevent auth errors from being fatal on the cli The direction parameter requires that file contains a 2048 bit key
ent side, and to permit username/password . While pre−1.5 versions of OpenVPN genâM−^@M−^P
requeries in case of error. erate 1024 bit key files, any version of OpenVPN which supports t
he direction parameter, will also support
An AUTH_FAILED message is generated by the server if the client fa 2048 bit key file generation using the −−genkey option.
ils −−auth−user−pass authentication, or
if the server−side −−client−connect script returns an error status Static key encryption mode has certain advantages, the primary bei
when the client tries to connect. ng ease of configuration.

type can be one of: There are no certificates or certificate authorities or complicate
d negotiation handshakes and protocols.
none −− Client will exit with a fatal error (this is the default). The only requirement is that you have a pre−existing secure chan
nointeract −− Client will retry the connection without requeryi nel with your peer (such as ssh ) to iniâM−^@M−^P
ng for an −−auth−user−pass username/passâM−^@M−^P tially copy the key. This requirement, along with the fact that y
word. Use this option for unattended clients. our key never changes unless you manually
interact −− Client will requery for an −−auth−user−pass username generate a new one, makes it somewhat less secure than TLS mod
/password and/or private key password e (see below). If an attacker manages to
before attempting a reconnection. steal your key, everything that was ever encrypted with it is comp
romised. Contrast that to the perfect
Note that while this option cannot be pushed, it can be controlled forward secrecy features of TLS mode (using Diffie Hellman key
from the management interface. exchange), where even if an attacker was
able to steal your private key, he would gain no information to he
−−server−poll−timeout n lp him decrypt past sessions.
when polling possible remote servers to connect to in a round−ro
bin fashion, spend no more than n seconds Another advantageous aspect of Static Key encryption mode is that
waiting for a response before trying the next server. it is a handshake−free protocol without
any distinguishing signature or feature (such as a header or pro
−−explicit−exit−notify [n] tocol handshake sequence) that would mark
In UDP client mode or point−to−point mode, send server/peer an exi the ciphertext packets as being generated by OpenVPN. Anyone eave
t notification if tunnel is restarted or sdropping on the wire would see nothing
OpenVPN process is exited. In client mode, on exit/restart, th but random−looking data.
is option will tell the server to immediâM−^@M−^P
ately close its client instance object rather than waiting for a t −−auth alg
imeout. The n parameter (default=1) conâM−^@M−^P Authenticate packets with HMAC using message digest algorithm alg.
trols the maximum number of retries that the client will attempt t (The default is SHA1 ). HMAC is a comâM−^@M−^P
o resend the exit notification message. monly used message authentication algorithm (MAC) that uses a data
string, a secure hash algorithm, and a
Data Channel Encryption Options: key, to produce a digital signature.
These options are meaningful for both Static & TLS−negotiated key modes (
must be compatible between peers). OpenVPN’s usage of HMAC is to first encrypt a packet, then HMAC th
e resulting ciphertext.
−−secret file [direction]
Monday May 07, 2012 − 19/35
Printed by root

May 07, 12 21:14 − Page 39/69 May 07, 12 21:14 − Page 40/69
In static−key encryption mode, the HMAC key is included in th pared to make a tradeoff of greater efficiency in exchange for les
e key file generated by −−genkey. In TLS s security.
mode, the HMAC key is dynamically generated and shared between pee
rs via the TLS control channel. If OpenâM−^@M−^P OpenVPN provides datagram replay protection by default.
VPN receives a packet with a bad HMAC it will drop the pack
et. HMAC usually adds 16 or 20 bytes per Replay protection is accomplished by tagging each outgoing datag
packet. Set alg=none to disable authentication. ram with an identifier that is guaranteed
to be unique for the key being used. The peer that receives the d
For more information on HMAC see http://www.cs.ucsd.edu/users/mihi atagram will check for the uniqueness of
r/papers/hmac.html the identifier. If the identifier was already received in a
previous datagram, OpenVPN will drop the
−−cipher alg packet. Replay protection is important to defeat attacks such as
Encrypt packets with cipher algorithm alg. The default is BF−CBC, a SYN flood attack, where the attacker
an abbreviation for Blowfish in Cipher listens in the wire, intercepts a TCP SYN packet (identifying it b
Block Chaining mode. Blowfish has the advantages of being fast, y the context in which it occurs in relaâM−^@M−^P
very secure, and allowing key sizes of up tion to other packets), then floods the receiving peer with copies
to 448 bits. Blowfish is designed to be used in situations where of this packet.
keys are changed infrequently.
OpenVPN’s replay protection is implemented in slightly different w
For more information on blowfish, see http://www.counterpane.com/b ays, depending on the key management mode
lowfish.html you have selected.
To see other ciphers that are available with OpenVPN, use the −−sh In Static Key mode or when using an CFB or OFB mode cipher, Ope
ow−ciphers option. nVPN uses a 64 bit unique identifier that
combines a time stamp with an incrementing sequence number.
OpenVPN supports the CBC, CFB, and OFB cipher modes, however CBC i
s recommended and CFB and OFB should be When using TLS mode for key exchange and a CBC cipher mode, OpenVP
considered advanced modes. N uses only a
32 bit sequence number
without a time stamp, since OpenVPN can guarantee the uniqueness
Set alg=none to disable encryption. of this value for each key. As in IPSec,
if the sequence number is close to wrapping back to zero, OpenVPN
−−keysize n will trigger a new key exchange.
Size of cipher key in bits (optional). If unspecified, defaults
to cipher−specific default. The −−show− To check for replays, OpenVPN uses the sliding window algorithm us
ciphers option (see below) shows all available OpenSSL ciphers, th ed by IPSec.
eir default key sizes, and whether the
key size can be changed. Use care in changing a cipher’s defa −−replay−window n [t]
ult key size. Many ciphers have not been Use a replay protection sliding−window of size n and a time window
extensively cryptanalyzed with non−standard key lengths, and a lar of t seconds.
ger key may offer no real guarantee of
greater security, or may even reduce security. By default n is 64 (the IPSec default) and t is 15 seconds.
−−prng alg [nsl] This option is only relevant in UDP mode, i.e. when either −−prot
(Advanced) For PRNG (Pseudo−random number generator), use digest o udp is specifed, or no −−proto option
algorithm alg (default=sha1), and set nsl is specified.
(default=16) to the size in bytes of the nonce secret length (betw
een 16 and 64). When OpenVPN tunnels IP packets over UDP, there is the possibilit
y that packets might be dropped or delivâM−^@M−^P
Set alg=none to disable the PRNG and use the OpenSSL RAND_bytes f ered out of order. Because OpenVPN, like IPSec, is emulating the
unction instead for all of OpenVPN’s physical network layer, it will accept an
pseudo−random number needs. out−of−order packet sequence, and will deliver such packets in
the same order they were received to the
−−engine [engine−name] TCP/IP protocol stack, provided they satisfy several constraints.
Enable OpenSSL hardware−based crypto engine functionality.
(a) The packet cannot be a replay (unless −−no−replay is specified
If engine−name is specified, use a specific crypto engine. Us , which disables replay protection altoâM−^@M−^P
e the −−show−engines standalone option to gether).
list the crypto engines which are supported by OpenSSL.
(b) If a packet arrives out of order, it will only be accepted if
−−no−replay the difference between its sequence numâM−^@M−^P
(Advanced) Disable OpenVPN’s protection against replay attacks. D ber and the highest sequence number received so far is less than n
on’t use this option unless you are preâM−^@M−^P .
Monday May 07, 2012 − 20/35
Printed by root

May 07, 12 21:14 − Page 41/69 May 07, 12 21:14 − Page 42/69
specially when you are using OpenVPN in a
(c) If a packet arrives out of order, it will only be accepted if dynamic context (such as with −−inetd) when OpenVPN sessions are f
it arrives no later than t seconds after requently started and stopped.
any packet containing a higher sequence number.
This option will keep a disk copy of the current replay protection
If you are using a network link with a large pipeline (meaning tha state (i.e. the most recent packet timeâM−^@M−^P
t the product of bandwidth and latency is stamp and sequence number received from the remote peer), so
high), you may want to use a larger value for n. Satellite links that if an OpenVPN session is stopped and
in particular often require this. restarted, it will reject any replays of packets which were alread
y received by the prior session.
If you run OpenVPN at −−verb 4, you will see the message "Replay−w
indow backtrack occurred [x]" every time This option only makes sense when replay protection is enabled (th
the maximum sequence number backtrack seen thus far increases. Th e default) and you are using either
is can be used to calibrate n. −−secret (shared−secret key mode) or TLS mode with −−tls−auth.

There is some controversy on the appropriate method of handling pa −−no−iv


cket reordering at the security layer. (Advanced) Disable OpenVPN’s use of IV (cipher initialization v
ector). Don’t use this option unless you
Namely, to what extent should the security layer protect the enca are prepared to make a tradeoff of greater efficiency in exchange
psulated protocol from attacks which masâM−^@M−^P for less security.
querade as the kinds of normal packet loss and reordering that occ
ur over IP networks? OpenVPN uses an IV by default, and requires it for CFB and OFB cip
her modes (which are totally insecure
The IPSec and OpenVPN approach is to allow packet reordering withi without it). Using an IV is important for security when multip
n a certain fixed sequence number window. le messages are being encrypted/decrypted
with the same key.
OpenVPN adds to the IPSec model by limiting the window size in tim
e as well as sequence space. IV is implemented differently depending on the cipher mode used.

OpenVPN also adds TCP transport as an option (not offered by IPSec In CBC mode, OpenVPN uses a pseudo−random IV for each packet.
) in which case OpenVPN can adopt a very
strict attitude towards message deletion and reordering: Don’t In CFB/OFB mode, OpenVPN uses a unique sequence number and time st
allow it. Since TCP guarantees reliabilâM−^@M−^P amp as the IV. In fact, in CFB/OFB mode,
ity, any packet loss or reordering event can be assumed to be an a OpenVPN uses a datagram space−saving optimization that uses the u
ttack. nique identifier for datagram replay proâM−^@M−^P
tection as the IV.
In this sense, it could be argued that TCP tunnel transport is pr
eferred when tunneling non−IP or UDP −−test−crypto
application protocols which might be vulnerable to a message Do a self−test of OpenVPN’s crypto options by encrypting and decry
deletion or reordering attack which falls pting test packets using the data channel
within the normal operational parameters of IP networks. encryption options specified above. This option does not require
a peer to function, and therefore can be
So I would make the statement that one should never tunnel a non−I specified without −−dev or −−remote.
P protocol or UDP application protocol
over UDP, if the protocol might be vulnerable to a message deleti The typical usage of −−test−crypto would be something like this:
on or reordering attack that falls within
the normal operating parameters of what is to be expected from the openvpn −−test−crypto −−secret key
physical IP layer. The problem is easâM−^@M−^P
ily fixed by simply using TCP as the VPN transport layer. or

−−mute−replay−warnings openvpn −−test−crypto −−secret key −−verb 9


Silence the output of replay warnings, which are a common false
alarm on WiFi networks. This option preâM−^@M−^P This option is very useful to test OpenVPN after it has been porte
serves the security of the replay protection code without the ver d to a new platform, or to isolate probâM−^@M−^P
bosity associated with warnings about lems in the compiler, OpenSSL crypto library, or OpenVPN’s cr
duplicate packets. ypto code. Since it is a self−test mode,
problems with encryption and authentication can be debugged indepe
−−replay−persist file ndently of network and tunnel issues.
Persist replay−protection state across sessions using file to save
and reload the state. TLS Mode Options:
TLS mode is the most powerful crypto mode of OpenVPN in both security and
This option will strengthen protection against replay attacks, e flexibility. TLS mode works by estabâM−^@M−^P
Monday May 07, 2012 − 21/35
Printed by root

May 07, 12 21:14 − Page 43/69 May 07, 12 21:14 − Page 44/69
lishing control and data channels which are multiplexed over a single TC penVPN, they are totally insecure.
P/UDP port. OpenVPN initiates a TLS sesâM−^@M−^P
sion over the control channel and uses it to exchange cipher and HMAC key −−dh file
s to protect the data channel. TLS mode File containing Diffie Hellman parameters in .pem format (required
uses a robust reliability layer over the UDP connection for all cont for −−tls−server only). Use
rol channel communication, while the data
channel, over which encrypted tunnel data passes, is forwarded without an openssl dhparam −out dh1024.pem 1024
y mediation. The result is the best of
both worlds: a fast data channel that forwards over UDP with only the ove to generate your own, or use the existing dh1024.pem file included
rhead of encrypt, decrypt, and HMAC funcâM−^@M−^P with the OpenVPN distribution. Diffie
tions, and a control channel that provides all of the security feature Hellman parameters may be considered public.
s of TLS, including certificate−based
authentication and Diffie Hellman forward secrecy. −−cert file
Local peer’s signed certificate in .pem format −− must be signed
To use TLS mode, each peer that runs OpenVPN should have its own local c by a certificate authority whose certifiâM−^@M−^P
ertificate/key pair ( −−cert and −−key ), cate is in −−ca file. Each peer in an OpenVPN link running in TLS
signed by the root certificate which is specified in −−ca. mode should have its own certificate and
private key file. In addition, each certificate should hav
When two OpenVPN peers connect, each presents its local certificate to th e been signed by the key of a certificate
e other. Each peer will then check that authority whose public key resides in the −−ca certificate authori
its partner peer presented a certificate which was signed by the master r ty file. You can easily make your own
oot certificate as specified in −−ca. certificate authority (see above) or pay money to use a commer
cial service such as thawte.com (in which
If that check on both peers succeeds, then the TLS negotiation will succe case you will be helping to finance the world’s second space touri
ed, both OpenVPN peers will exchange temâM−^@M−^P st :). To generate a certificate, you
porary session keys, and the tunnel will begin passing data. can use a command such as:
The OpenVPN distribution contains a set of scripts for managing RSA certi openssl req −nodes −new −keyout mycert.key −out mycert.csr
ficates & keys, located in the easy−rsa
subdirectory. If your certificate authority private key lives on another mach
ine, copy the certificate signing request
The easy−rsa package is also rendered in web form here: http://openvpn.ne (mycert.csr) to this other machine (this can be done over an insec
t/easyrsa.html ure channel such as email). Now sign the
certificate with a command such as:
−−tls−server
Enable TLS and assume server role during TLS handshake. Note t openssl ca −out mycert.crt −in mycert.csr
hat OpenVPN is designed as a peer−to−peer
application. The designation of client or server is only for the Now copy the certificate (mycert.crt) back to the peer which initi
purpose of negotiating the TLS control ally generated the .csr file (this can be
channel. over a public medium). Note that the openssl ca command reads the
location of the certificate authority
−−tls−client key from its configuration file such as /usr/share/ssl/open
Enable TLS and assume client role during TLS handshake. ssl.cnf −− note also that for certificate
authority functions, you must set up the files index.txt (may be e
−−ca file mpty) and serial (initialize to 01 ).
Certificate authority (CA) file in .pem format, also referred t
o as the root certificate. This file can −−key file
have multiple certificates in .pem format, concatenated together. Local peer’s private key in .pem format. Use the private key whic
You can construct your own certificate h was generated when you built your
authority certificate and private key by using a command such as: peer’s certificate (see −cert file above).
openssl req −nodes −new −x509 −keyout ca.key −out ca.crt −−pkcs12 file
Specify a PKCS #12 file containing local private key, local ce
Then edit your openssl.cnf file and edit the certificate varia rtificate, and root CA certificate. This
ble to point to your new root certificate option can be used instead of −−ca, −−cert, and −−key.
ca.crt.
−−pkcs11−cert−private [0|1]...
For testing purposes only, the OpenVPN distribution includes a sam Set if access to certificate object should be performed after logi
ple CA certificate (ca.crt). Of course n. Every provider has its own setting.
you should never use the test certificates and test keys distribu
ted with OpenVPN in a production environâM−^@M−^P −−pkcs11−id name
ment, since by virtue of the fact that they are distributed with O Specify the serialized certificate id to be used. The id can be go
Monday May 07, 2012 − 22/35
Printed by root

May 07, 12 21:14 − Page 45/69 May 07, 12 21:14 − Page 46/69
tten by the standalone −−show−pkcs11−ids
option.
−−key−method m
−−pkcs11−id−management Use data channel key negotiation method m. The key method must ma
Acquire PKCS#11 id from management interface. In this case a NEED− tch on both sides of the connection.
STR ’pkcs11−id−request’ real−time message
will be triggered, application may use pkcs11−id−count command to After OpenVPN negotiates a TLS session, a new set of keys for pro
retrieve available number of certifiâM−^@M−^P tecting the tunnel data channel is generâM−^@M−^P
cates, and pkcs11−id−get command to retrieve certificate id and ce ated and exchanged over the TLS session.
rtificate body.
In method 1 (the default for OpenVPN 1.x), both sides generate ran
−−pkcs11−pin−cache seconds dom encrypt and HMAC−send keys which are
Specify how many seconds the PIN can be cached, the default is unt forwarded to the other host over the TLS channel.
il the token is removed.
In method 2, (the default for OpenVPN 2.0) the client generates a
−−pkcs11−protected−authentication [0|1]... random key. Both client and server also
Use PKCS#11 protected authentication path, useful for biome generate some random seed material. All key source material is ex
tric and external keypad devices. Every changed over the TLS channel. The actual
provider has its own setting. keys are generated using the TLS PRF function, taking source entro
py from both client and server. Method 2
−−pkcs11−providers provider... is designed to closely parallel the key generation process used by
Specify a RSA Security Inc. PKCS #11 Cryptographic Token Interface TLS 1.0.
(Cryptoki) providers to load. This
option can be used instead of −−cert, −−key, and −−pkcs12. Note that in TLS mode, two separate levels of keying occur:
−−pkcs11−private−mode mode... (1) The TLS connection is initially negotiated, with both sides of
Specify which method to use in order to perform private key opera the connection producing certificates
tions. A different mode can be specified and verifying the certificate (or other authentication info provi
for each provider. Mode is encoded as hex number, and can be a ma ded) of the other side. The −−key−method
sk one of the following: parameter has no effect on this process.
0 (default) −− Try to determind automatically. (2) After the TLS connection is established, the tunnel session ke
1 −− Use sign. ys are separately negotiated over the
2 −− Use sign recover. existing secure TLS channel. Here, −−key−method determines the de
4 −− Use decrypt. rivation of the tunnel session keys.
8 −− Use unwrap.
−−tls−cipher l
−−cryptoapicert select−string A list l of allowable TLS ciphers delimited by a colon (":"). If
Load the certificate and private key from the Windows Certificate you require a high level of security, you
System Store (Windows Only). may want to set this parameter manually, to prevent a version roll
back attack where a man−in−the−middle
Use this option instead of −−cert and −−key. attacker tries to force two peers to negotiate to the lowest
level of security they both support. Use
This makes it possible to use any smart card, supported by Windows −−show−tls to see a list of supported TLS ciphers.
, but also
any kind of certificate,
residing in the Cert Store, where you have access to the private −−tls−timeout n
key. This option has been tested with a Packet retransmit timeout on TLS control channel if no acknowl
couple of different smart cards (GemSAFE, Cryptoflex, and Swedish edgment from remote within n seconds
Post Office eID) on the client side, and (default=2). When OpenVPN sends a control packet to its peer, it
also an imported PKCS12 software certificate on the server side. will expect to receive an acknowledgement
within n seconds or it will retransmit the packet, subject to a T
To select a certificate, based on a substring search in the certif CP−like exponential backoff algorithm.
icate’s subject: This parameter only applies to control channel packets. Data chan
nel packets (which carry encrypted tunnel
cryptoapicert "SUBJ:Peter Runestig" data) are never acknowledged, sequenced, or retransmitted by OpenV
PN because the higher level network proâM−^@M−^P
To select a certificate, based on certificate’s thumbprint: tocols running on top of the tunnel such as TCP expect this role t
o be left to them.
cryptoapicert "THUMB:f6 49 24 41 01 b4 ..."
−−reneg−bytes n
The thumbprint hex string can easily be copy−and−pasted from the W Renegotiate data channel key after n bytes sent or received (
indows Certificate Store GUI. disabled by default). OpenVPN allows the
Monday May 07, 2012 − 23/35
Printed by root

May 07, 12 21:14 − Page 47/69 May 07, 12 21:14 − Page 48/69
lifetime of a key to be expressed as a number of bytes encrypted/d Add an additional layer of HMAC authentication on top of the TLS c
ecrypted, a number of packets, or a numâM−^@M−^P ontrol channel to protect against DoS
ber of seconds. A key renegotiation will be forced if any of thes attacks.
e three criteria are met by either peer.
In a nutshell, −−tls−auth enables a kind of "HMAC firewall" on
−−reneg−pkts n OpenVPN’s TCP/UDP port, where TLS control
Renegotiate data channel key after n packets sent and received (di channel packets bearing an incorrect HMAC signature can be dropped
sabled by default). immediately without response.
−−reneg−sec n file (required) is a key file which can be in one of two formats:
Renegotiate data channel key after n seconds (default=3600).
(1) An OpenVPN static key file generated by −−genkey (required if
When using dual−factor authentication, note that this default valu direction parameter is used).
e may cause the end user to be challenged
to reauthorize once per hour. (2) A freeform passphrase file. In this case the HMAC key will be
derived by taking a secure hash of this
Also, keep in mind that this option can be used on both the client file, similar to the md5sum(1) or sha1sum(1) commands.
and server, and whichever uses the lower
value will be the one to trigger the renegotiation. A common OpenVPN will first try format (1), and if the file fails to parse
mistake is to set −−reneg−sec to a higher as a static key file, format (2) will be
value on either the client or server, while the other side of the used.
connection is still using the default
value of 3600 seconds, meaning that the renegotiation will still o See the −−secret option for more information on the optional direc
ccur once per 3600 seconds. The solution tion parameter.
is to increase −−reneg−sec on both the client and server, or set i
t to 0 on one side of the connection (to −−tls−auth is recommended when you are running OpenVPN in a mode w
disable), and to your chosen value on the other side. here it is listening for packets from any
IP address, such as when −−remote is not specified, or −−remote is
−−hand−window n specified with −−float.
Handshake Window −− the TLS−based key exchange must finalize wi
thin n seconds of handshake initiation by The rationale for this feature is as follows. TLS requires a m
any peer (default = 60 seconds). If the handshake fails we will a ulti−packet exchange before it is able to
ttempt to reset our connection with our authenticate a peer. During this time before authentication, Open
peer and try again. Even in the event of handshake failure we VPN is allocating resources (memory and
will still use our expiring key for up to CPU) to this potential peer. The potential peer is also expos
−−tran−window seconds to maintain continuity of transmission of tu ing many parts of OpenVPN and the OpenSSL
nnel data. library to the packets it is sending. Most successful network att
acks today seek to either exploit bugs in
−−tran−window n programs (such as buffer overflow attacks) or force a program to
Transition window −− our old key can live this many seconds after consume so many resources that it becomes
a new a key renegotiation begins (default unusable. Of course the first line of defense is always to produc
= 3600 seconds). This feature allows for a graceful transition e clean, well−audited code. OpenVPN has
from old to new key, and removes the key been written with buffer overflow attack prevention as a top pri
renegotiation sequence from the critical path of tunnel data forwa ority. But as history has shown, many of
rding. the most widely used network applications have, from time to time,
fallen to buffer overflow attacks.
−−single−session
After initially connecting to a remote peer, disallow any new conn So as a second line of defense, OpenVPN offers this special layer
ections. Using this option means that a of authentication on top of the TLS conâM−^@M−^P
remote peer cannot connect, disconnect, and then reconnect. trol channel so that every packet on the control channel is authen
ticated by an HMAC signature and a unique
If the daemon is reset by a signal or −−ping−restart, it will allo ID for replay protection. This signature will also help protect a
w one new connection. gainst DoS (Denial of Service) attacks.
An important rule of thumb in reducing vulnerability to DoS attac
−−single−session can be used with −−ping−exit or −−inactive to ks is to minimize the amount of resources
create a single dynamic session that will a potential, but as yet unauthenticated, client is able to consume
exit when finished. .
−−tls−exit −−tls−auth does this by signing every TLS control channel packet w
Exit on TLS negotiation failure. ith an HMAC signature, including packets
which are sent before the TLS level has had a chance to authentic
−−tls−auth file [direction] ate the peer. The result is that packets
Monday May 07, 2012 − 24/35
Printed by root

May 07, 12 21:14 − Page 49/69 May 07, 12 21:14 − Page 50/69
without the correct signature can be dropped immediately upon rece This feature is useful if the peer you want to trust has a certifi
ption, before they have a chance to conâM−^@M−^P cate which was signed by a certificate
sume additional system resources such as by initiating a TLS hand authority who also signed many other certificates, where you don
shake. −−tls−auth can be strengthened by ’t necessarily want to trust all of them,
adding the −−replay−persist option which will keep OpenVPN’s repla but rather be selective about which peer certificate you will acce
y protection state in a file so that it pt. This feature allows you to write a
is not lost across restarts. script which will test the X509 name on a certificate and decide w
hether or not it should be accepted. For
It should be emphasized that this feature is optional and that the a simple perl script which will test the common name field on the
passphrase/key file used with −−tls−auth certificate, see the file verify−cn in
gives a peer nothing more than the power to initiate a TLS handsha the OpenVPN distribution.
ke. It is not used to encrypt or authenâM−^@M−^P
ticate any tunnel data. See the "Environmental Variables" section below for additional
parameters passed as environmental variâM−^@M−^P
−−askpass [file] ables.
Get certificate password from console or file before we daemonize.
Note that cmd can be a shell command with multiple arguments, in w
For the extremely security conscious, it is possible to prot hich case all OpenVPN−generated arguments
ect your private key with a password. Of will be appended to cmd to build a command line which will be pass
course this means that every time the OpenVPN daemon is started yo ed to the script.
u must be there to type the password.
The −−askpass option allows you to start OpenVPN from the comman −−tls−remote name
d line. It will query you for a password Accept connections only from a host with X509 name or common name
before it daemonizes. To protect a private key with a password yo equal to name. The remote host must also
u should omit the −nodes option when you pass all other tests of verification.
use the openssl command line tool to manage certificates and priva
te keys. NOTE: Because tls−remote may test against a common name prefix, on
ly use this option when you are using
If file is specified, read the password from the first line of fi OpenVPN with a custom CA certificate that is under your control
le. Keep in mind that storing your passâM−^@M−^P . Never use this option when your client
word in a file to a certain extent invalidates the extra security certificates are signed by a third party, such as a commercial web
provided by using an encrypted key (Note: CA.
OpenVPN will only read passwords from a file if it has been built
with the −−enable−password−save configure Name can also be a common name prefix, for example if you want a
option, or on Windows by defining ENABLE_PASSWORD_SAVE in config−w client to only accept connections to
in32.h). "Server−1", "Server−2", etc., you can simply use −−tls−remote Serv
er
−−auth−nocache
Don’t cache −−askpass or −−auth−user−pass username/passwords in vi Using a common name prefix is a useful alternative to managing a
rtual memory. CRL (Certificate Revocation List) on the
client, since it allows the client to refuse all certificates exce
If specified, this directive will cause OpenVPN to immediately for pt for those associated with designated
get username/password inputs after they servers.
are used. As a result, when OpenVPN needs a username/password, i
t will prompt for input from stdin, which −−tls−remote is a useful replacement for the −−tls−verify option
may be multiple times during the duration of an OpenVPN session. to verify the remote host, because −−tls−
remote works in a −−chroot environment too.
This directive does not affect the −−http−proxy username/password.
It is always cached. −−ns−cert−type client|server
Require that peer certificate was signed with an explicit nsCertTy
−−tls−verify cmd pe designation of "client" or "server".
Execute shell command cmd to verify the X509 name of a pending TLS
connection that has otherwise passed all This is a useful security option for clients, to ensure that the h
other tests of certification (except for revocation via −−crl−ver ost they connect with is a designated
ify directive; the revocation test occurs server.
after the −−tls−verify test).
See the easy−rsa/build−key−server script for an example of how t
cmd should return 0 to allow the TLS handshake to proceed, or 1 to o generate a certificate with the nsCertâM−^@M−^P
fail. cmd is executed as Type field set to "server".
cmd certificate_depth X509_NAME_oneline If the server certificate’s nsCertType field is set to "server", t
hen the clients can verify this with
Monday May 07, 2012 − 25/35
Printed by root

May 07, 12 21:14 − Page 51/69 May 07, 12 21:14 − Page 52/69
−−ns−cert−type server. −−crl−verify crl
Check peer certificate against the file crl in PEM format.
This is an important security precaution to protect against a man
−in−the−middle attack where an authorized A CRL (certificate revocation list) is used when a particular ke
client attempts to connect to another client by impersonating the y is compromised but when the overall PKI
server. The attack is easily prevented is still intact.
by having clients verify the server certificate using any one o
f −−ns−cert−type, −−tls−remote, or −−tls− Suppose you had a PKI consisting of a CA, root certificate, and a
verify. number of client certificates. Suppose a
laptop computer containing a client key and certificate was sto
−−remote−cert−ku v... len. By adding the stolen certificate to
Require that peer certificate was signed with an explicit key usag the CRL file, you could reject any connection which attempts to
e. use it, while preserving the overall
integrity of the PKI.
This is a useful security option for clients, to ensure that the h
ost they connect to is a designated The only time when it would be necessary to rebuild the entire P
server. KI from scratch would be if the root cerâM−^@M−^P
tificate key itself was compromised.
The key usage should be encoded in hex, more than one key usage ca
n be specified. SSL Library information:
−−show−ciphers
−−remote−cert−eku oid (Standalone) Show all cipher algorithms to use with the −−cipher o
Require that peer certificate was signed with an explicit extended ption.
key usage.
−−show−digests
This is a useful security option for clients, to ensure that (Standalone) Show all message digest algorithms to use with the −−
the host they connect to is a designated auth option.
server.
−−show−tls
The extended key usage should be encoded in oid notation, or OpenS (Standalone) Show all TLS ciphers (TLS used only as a control chan
SL symbolic representation. nel). The TLS ciphers will be sorted
from highest preference (most secure) to lowest.
−−remote−cert−tls client|server
Require that peer certificate was signed with an explicit key usag −−show−engines
e and extended key usage based on RFC3280 (Standalone) Show currently available hardware−based crypto acce
TLS rules. leration engines supported by the OpenSSL
library.
This is a useful security option for clients, to ensure that
the host they connect to is a designated Generate a random key:
server. Used only for non−TLS static key encryption mode.

The −−remote−cert−tls client option is equivalent to −−remote−cert −−genkey


−ku 80 08 88 −−remote−cert−eku "TLS Web (Standalone) Generate a random key to be used as a shared secret,
Client Authentication" for use with the −−secret option. This
file must be shared with the peer over a pre−existing secure chann
The key usage is digitalSignature and/or keyAgreement. el such as scp(1)

The −−remote−cert−tls server option is equivalent to −−remote −−secret file


−cert−ku a0 88 −−remote−cert−eku "TLS Web Write key to file.
Server Authentication"
TUN/TAP persistent tunnel config mode:
The key usage is digitalSignature and ( keyEncipherment or keyAgre Available with linux 2.4.7+. These options comprise a standalone mode o
ement ). f OpenVPN which can be used to create and
delete persistent tunnels.
This is an important security precaution to protect against a man−
in−the−middle attack where an authorized −−mktun
client attempts to connect to another client by impersonating th (Standalone) Create a persistent tunnel on platforms which support
e server. The attack is easily prevented them such as Linux. Normally TUN/TAP
by having clients verify the server certificate using any one of − tunnels exist only for the period of time that an application ha
−remote−cert−tls, −−tls−remote, or −−tls− s them open. This option takes advantage
verify. of the TUN/TAP driver’s ability to build persistent tunnels that l
ive through multiple instantiations of
Monday May 07, 2012 − 26/35
Printed by root

May 07, 12 21:14 − Page 53/69 May 07, 12 21:14 − Page 54/69
OpenVPN and die only when they are deleted or the machine is reboo are, however, two prerequisites for using
ted. this mode: (1) The TCP/IP properties for the TAP−Win32 adapter mus
t be set to "Obtain an IP address autoâM−^@M−^P
One of the advantages of persistent tunnels is that they elimin matically," and (2) OpenVPN needs to claim an IP address in the
ate the need for separate −−up and −−down subnet for use as the virtual DHCP server
scripts to run the appropriate ifconfig(8) and route(8) commands. address. By default in −−dev tap mode, OpenVPN will take the norm
These commands can be placed in the the ally unused first address in the subnet.
same shell script which starts or terminates an OpenVPN session. For example, if your subnet is 192.168.4.0 netmask 255.255.255
.0, then OpenVPN will take the IP address
Another advantage is that open connections through the TUN/TAP−ba 192.168.4.0 to use as the virtual DHCP server address. In −−dev t
sed tunnel will not be reset if the OpenâM−^@M−^P un mode, OpenVPN will cause the DHCP
VPN peer restarts. This can be useful to provide uninterrupted co server to masquerade as if it were coming from the remote endpo
nnectivity through the tunnel in the int. The optional offset parameter is an
event of a DHCP reset of the peer’s public IP address (see the −−i integer which is > −256 and < 256 and which defaults to 0. If off
pchange option above). set is positive, the DHCP server will
masquerade as the IP address at network address + offset. If offs
One disadvantage of persistent tunnels is that it is harder to aut et is negative, the DHCP server will masâM−^@M−^P
omatically configure their MTU value (see querade as the IP address at broadcast address + offset. The Wind
−−link−mtu and −−tun−mtu above). ows ipconfig /all command can be used to
show what Windows thinks the DHCP server address is. OpenVPN w
On some platforms such as Windows, TAP−Win32 tunnels are persisten ill "claim" this address, so make sure to
t by default. use a free address. Having said that, different OpenVPN instantia
tions, including different ends of the
−−rmtun same connection, can share the same virtual DHCP server addres
(Standalone) Remove a persistent tunnel. s. The lease−time parameter controls the
lease time of the DHCP assignment given to the TAP−Win32 adapter,
−−dev tunX | tapX and is denoted in seconds. Normally a
TUN/TAP device very long lease time is preferred because it prevents routes i
nvolving the TAP−Win32 adapter from being
−−user user lost when the system goes to sleep. The default lease time is one
Optional user to be owner of this tunnel. year.

−−group group netsh −− Automatically set the IP address and netmask using the Wi
Optional group to be owner of this tunnel. ndows command−line "netsh" command. This
method appears to work correctly on Windows XP but not Windows 200
Windows−Specific Options: 0.
−−win−sys path|’env’
Set the Windows system directory pathname to use when looking for ipapi −− Automatically set the IP address and netmask using the W
system executables such as route.exe and indows IP Helper API. This approach does
netsh.exe. By default, if this directive is not specified, the pa not have ideal semantics, though testing has indicated that it wor
thname will be set to "C:\WINDOWS" ks okay in practice. If you use this
option, it is best to leave the TCP/IP properties for the TAP−W
The special string ’env’ indicates that the pathname should be rea in32 adapter in their default state, i.e.
d from the SystemRoot environmental variâM−^@M−^P "Obtain an IP address automatically."
able.
adaptive −− (Default) Try dynamic method initially and fail over t
−−ip−win32 method o netsh if the DHCP negotiation with the
When using −−ifconfig on Windows, set the TAP−Win32 adapter IP add TAP−Win32 adapter does not succeed in 20 seconds. Such failu
ress and netmask using method. Don’t use res have been known to occur when certain
this option unless you are also using −−ifconfig. third−party firewall packages installed on the client machine bloc
k the DHCP negotiation used by the TAP−
manual −− Don’t set the IP address or netmask automatically. Win32 adapter. Note that if the netsh failover occurs, the TA
Instead output a message to the console P−Win32 adapter TCP/IP properties will be
telling the user to configure the adapter manually and indicating reset from DHCP to static, and this will cause future OpenVPN star
the IP/netmask which OpenVPN expects the tups using the adaptive mode to use netsh
adapter to be set to. immediately, rather than trying dynamic first. To "unstick" the
adaptive mode from using netsh, run OpenâM−^@M−^P
dynamic [offset] [lease−time] −− Automatically set the IP addr VPN at least once using the dynamic mode to restore the TAP−Win32
ess and netmask by replying to DHCP query adapter TCP/IP properties to a DHCP conâM−^@M−^P
messages generated by the kernel. This mode is probably the "clea figuration.
nest" solution for setting the TCP/IP
properties since it uses the well−known DHCP protocol. There −−route−method m
Monday May 07, 2012 − 27/35
Printed by root

May 07, 12 21:14 − Page 55/69 May 07, 12 21:14 − Page 56/69
Which method m to use for adding routes on Windows? Cause OpenVPN to sleep for n seconds immediately after the TAP−Win
32 adapter state is set to "connected".
adaptive (default) −− Try IP helper API first. If that fails, fal
l back to the route.exe shell command. This option is intended to be used to troubleshoot problems with t
ipapi −− Use IP helper API. he −−ifconfig and −−ip−win32 options, and
exe −− Call the route.exe shell command. is used to give the TAP−Win32 adapter time to come up before Win
dows IP Helper API operations are applied
−−dhcp−option type [parm] to it.
Set extended TAP−Win32 TCP/IP properties, must be used with −
−ip−win32 dynamic or −−ip−win32 adaptive. −−show−net−up
This option can be used to set additional TCP/IP properties on the Output OpenVPN’s view of the system routing table and network adap
TAP−Win32 adapter, and is particularly ter list to the syslog or log file after
useful for configuring an OpenVPN client to access a Samba server the TUN/TAP adapter has been brought up and any routes have been a
across the VPN. dded.

DOMAIN name −− Set Connection−specific DNS Suffix. −−dhcp−renew


Ask Windows to renew the TAP adapter lease on startup. This o
DNS addr −− Set primary domain name server address. Repea ption is normally unnecessary, as Windows
t this option to set secondary DNS server automatically triggers a DHCP renegotiation on the TAP adapter whe
addresses. n it comes up, however if you set the
TAP−Win32 adapter Media Status property to "Always Connected", you
WINS addr −− Set primary WINS server address (NetBIOS over TCP/IP may need this flag.
Name Server). Repeat this option to set
secondary WINS server addresses. −−dhcp−release
Ask Windows to release the TAP adapter lease on shutdown. This op
NBDD addr −− Set primary NBDD server address (NetBIOS over TCP/IP tion has the same caveats as −−dhcp−renew
Datagram Distribution Server) Repeat this above.
option to set secondary NBDD server addresses.
−−register−dns
NTP addr −− Set primary NTP server address (Network Time Protocol) Run net stop dnscache, net start dnscache, ipconfig /flushdns and
. Repeat this option to set secondary ipconfig /registerdns on connection iniâM−^@M−^P
NTP server addresses. tiation. This is known to kick Windows into recognizing pushed DN
S servers.
NBT type −− Set NetBIOS over TCP/IP Node type. Possible opt
ions: 1 = b−node (broadcasts), 2 = p−node −−pause−exit
(point−to−point name queries to a WINS server), 4 = m−node (broadc Put up a "press any key to continue" message on the console prior
ast then query name server), and 8 = h− to OpenVPN program exit. This option is
node (query name server, then broadcast). automatically used by the Windows explorer when OpenVPN is run on
a configuration file using the right−
NBS scope−id −− Set NetBIOS over TCP/IP Scope. A NetBIOS Scope I click explorer menu.
D provides an extended naming service for
the NetBIOS over TCP/IP (Known as NBT) module. The primary purpose −−service exit−event [0|1]
of a NetBIOS scope ID is to isolate NetâM−^@M−^P Should be used when OpenVPN is being automatically executed by
BIOS traffic on a single network to only those nodes with the sam another program in such a context that no
e NetBIOS scope ID. The NetBIOS scope ID interaction with the user via display or keyboard is possible. In
is a character string that is appended to the NetBIOS name. The Ne general, end−users should never need to
tBIOS scope ID on two hosts must match, explicitly use this option, as it is automatically added by the O
or the two hosts will not be able to communicate. The NetBIOS penVPN service wrapper when a given OpenâM−^@M−^P
Scope ID also allows computers to use the VPN configuration is being run as a service.
same computer name, as they have different scope IDs. The Scope ID
becomes a part of the NetBIOS name, makâM−^@M−^P exit−event is the name of a Windows global event object, and OpenV
ing the name unique. (This description of NetBIOS scopes courtesy PN will continuously monitor the state of
of NeonSurge@abyss.com) this event object and exit when it becomes signaled.

DISABLE−NBT −− Disable Netbios−over−TCP/IP. The second parameter indicates the initial state of exit−event and
normally defaults to 0.
Note that if −−dhcp−option is pushed via −−push to a non−window
s client, the option will be saved in the Multiple OpenVPN processes can be simultaneously executed with the
client’s environment before the up script is called, under the nam same exit−event parameter. In any case,
e "foreign_option_{n}". the controlling process can signal exit−event, causing all such Op
enVPN processes to exit.
−−tap−sleep n
Monday May 07, 2012 − 28/35
Printed by root

May 07, 12 21:14 − Page 57/69 May 07, 12 21:14 − Page 58/69
When executing an OpenVPN process using the −−service directive, O −−client−connect
penVPN will probably not have a console Executed in −−mode server mode immediately after client authentica
window to output status/error messages, therefore it is useful to tion.
use −−log or −−log−append to write these
messages to a file. −−route−up
Executed after connection authentication, either immediately
−−show−adapters after, or some number of seconds after as
(Standalone) Show available TAP−Win32 adapters which can be select defined by the −−route−delay option.
ed using the −−dev−node option. On non−
Windows systems, the ifconfig(8) command provides similar function −−client−disconnect
ality. Executed in −−mode server mode on client instance shutdown.
−−allow−nonadmin [TAP−adapter] −−down Executed after TCP/UDP and TUN/TAP close.
(Standalone) Set TAP−adapter to allow access from non−administrat
ive accounts. If TAP−adapter is omitted, −−learn−address
all TAP adapters on the system will be configured to allow non−adm Executed in −−mode server mode whenever an IPv4 address/route or M
in access. The non−admin access setting AC address is added to OpenVPN’s internal
will only persist for the length of time that the TAP−Win32 de routing table.
vice object and driver remain loaded, and
will need to be re−enabled after a reboot, or if the driver is unl −−auth−user−pass−verify
oaded and reloaded. This directive can Executed in −−mode server mode on new client connections, when the
only be used by an administrator. client is still untrusted.
−−show−valid−subnets String Types and Remapping
(Standalone) Show valid subnets for −−dev tun emulation. Since In certain cases, OpenVPN will perform remapping of characters in stri
the TAP−Win32 driver exports an ethernet ngs. Essentially, any characters outside
interface to Windows, and since TUN devices are point−to−point in the set of permitted characters for each string type will be converted to
nature, it is necessary for the TAP−Win32 underbar (’_’).
driver to impose certain constraints on TUN endpoint address selec
tion. Q: Why is string remapping necessary?
Namely, the point−to−point endpoints used in TUN device emulation A: It’s an important security feature to prevent the malicious coding of
must be the middle two addresses of a /30 strings from untrusted sources to be
subnet (netmask 255.255.255.252). passed as parameters to scripts, saved in the environment, used as a comm
on name, translated to a filename, etc.
−−show−net
(Standalone) Show OpenVPN’s view of the system routing table and n Q: Can string remapping be disabled?
etwork adapter list.
A: Yes, by using the −−no−name−remapping option, however this should be c
PKCS#11 Standalone Options: onsidered an advanced option.
−−show−pkcs11−ids provider [cert_private]
(Standalone) Show PKCS#11 token object list. Specify cert_private Here is a brief rundown of OpenVPN’s current string types and the permitt
as 1 if certificates are stored as priâM−^@M−^P ed character class for each string:
vate objects.
X509 Names: Alphanumeric, underbar (’_’), dash (’−’), dot (’.’), at (
−−verb option can be used BEFORE this option to produce debugging ’@’), colon (’:’), slash (’/’), and equal
information. (’=’). Alphanumeric is defined as a character which will cause the C lib
rary isalnum() function to return true.
SCRIPTING AND ENVIRONMENTAL VARIABLES
OpenVPN exports a series of environmental variables for use by user−defin Common Names: Alphanumeric, underbar (’_’), dash (’−’), dot (’.’), and at
ed scripts. (’@’).
Script Order of Execution −−auth−user−pass username: Same as Common Name, with one exception: start
−−up Executed after TCP/UDP socket bind and TUN/TAP open. ing with OpenVPN 2.0.1, the username is
passed to the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY plugin in its raw form
−−tls−verify , without string remapping.
Executed when we have a still untrusted remote peer.
−−auth−user−pass password: Any "printable" character except CR or LF
−−ipchange . Printable is defined to be a character
Executed after connection authentication, or remote IP address cha which will cause the C library isprint() function to return true.
nge.
−−client−config−dir filename as derived from common name or username: Alp
Monday May 07, 2012 − 29/35
Printed by root

May 07, 12 21:14 − Page 59/69 May 07, 12 21:14 − Page 60/69
hanumeric, underbar (’_’), dash (’−’), rived from the −−ifconfig option when
and dot (’.’) except for "." or ".." as standalone strings. As of 2 −−dev tap is used. Set prior to OpenVPN calling the ifconfig or
.0.1−rc6, the at (’@’) character has been netsh (windows version of ifconfig) comâM−^@M−^P
added as well for compatibility with the common name character class. mands which normally occurs prior to −−up script execution.
Environmental variable names: Alphanumeric or underbar (’_’). ifconfig_local
The local VPN endpoint IP address specified in the −−ifconfig opti
Environmental variable values: Any printable character. on (first parameter). Set prior to OpenâM−^@M−^P
VPN calling the ifconfig or netsh (windows version of ifconfig
For all cases, characters in a string which are not members of the legal ) commands which normally occurs prior to
character class for that string type will −−up script execution.
be remapped to underbar (’_’).
ifconfig_remote
Environmental Variables The remote VPN endpoint IP address specified in the −−ifconfig opt
Once set, a variable is persisted indefinitely until it is reset by a new ion (second parameter) when −−dev tun is
value or a restart, used. Set prior to OpenVPN calling the ifconfig or netsh (windows
version of ifconfig) commands which norâM−^@M−^P
As of OpenVPN 2.0−beta12, in server mode, environmental variables s mally occurs prior to −−up script execution.
et by OpenVPN are scoped according to the
client objects they are associated with, so there should not be any issue ifconfig_netmask
s with scripts having access to stale, The subnet mask of the virtual ethernet segment that is specified
previously set variables which refer to different client instances. as the second parameter to −−ifconfig
when −−dev tap is being used. Set prior to OpenVPN calling
bytes_received the ifconfig or netsh (windows version of
Total number of bytes received from client during VPN session. Se ifconfig) commands which normally occurs prior to −−up script exec
t prior to execution of the −−client−disâM−^@M−^P ution.
connect script.
ifconfig_pool_local_ip
bytes_sent The local virtual IP address for the TUN/TAP tunnel taken from an
Total number of bytes sent to client during VPN session. Set prio −−ifconfig−push directive if specified,
r to execution of the −−client−disconnect or otherwise from the ifconfig pool (controlled by the −−ifconf
script. ig−pool config file directive). Only set
for −−dev tun tunnels. This option is set on the server prior to
common_name execution of the −−client−connect and
The X509 common name of an authenticated client. Set prior to exe −−client−disconnect scripts.
cution of −−client−connect, −−client−disâM−^@M−^P
connect, and −−auth−user−pass−verify scripts. ifconfig_pool_netmask
The virtual IP netmask for the TUN/TAP tunnel taken from an −−ifco
config Name of first −−config file. Set on program initiation and reset nfig−push directive if specified, or othâM−^@M−^P
on SIGHUP. erwise from the ifconfig pool (controlled by the −−ifconfig−pool c
onfig file directive). Only set for
daemon Set to "1" if the −−daemon directive is specified, or "0" otherwis −−dev tap tunnels. This option is set on the server prior
e. Set on program initiation and reset to execution of the −−client−connect and
on SIGHUP. −−client−disconnect scripts.
daemon_log_redirect ifconfig_pool_remote_ip
Set to "1" if the −−log or −−log−append directives are specified, The remote virtual IP address for the TUN/TAP tunnel taken from an
or "0" otherwise. Set on program initiaâM−^@M−^P −−ifconfig−push directive if specified,
tion and reset on SIGHUP. or otherwise from the ifconfig pool (controlled by the −−ifconfig−
pool config file directive). This option
dev The actual name of the TUN/TAP device, including a unit number if is set on the server prior to execution of the −−client−connect an
it exists. Set prior to −−up or −−down d −−client−disconnect scripts.
script execution.
link_mtu
foreign_option_{n} The maximum packet size (not including the IP header) of tunnel da
An option pushed via −−push to a client which does not natively su ta in UDP tunnel transport mode. Set
pport it, such as −−dhcp−option on a non− prior to −−up or −−down script execution.
Windows system, will be recorded to this environmental variable se
quence prior to −−up script execution. local The −−local parameter. Set on program initiation and reset on SIG
HUP.
ifconfig_broadcast
The broadcast address for the virtual ethernet segment which is de local_port
Monday May 07, 2012 − 30/35
Printed by root

May 07, 12 21:14 − Page 61/69 May 07, 12 21:14 − Page 62/69
The local port number, specified by −−port or −−lport. Set on pro Client connection timestamp, formatted as a human−readable ti
gram initiation and reset on SIGHUP. me string. Set prior to execution of the
−−client−connect script.
password
The password provided by a connecting client. Set prior to −−au time_duration
th−user−pass−verify script execution only The duration (in seconds) of the client session which is now disco
when the via−env modifier is specified, and deleted from the envir nnecting. Set prior to execution of the
onment after the script returns. −−client−disconnect script.
proto The −−proto parameter. Set on program initiation and reset on SIG time_unix
HUP. Client connection timestamp, formatted as a unix integer date/t
ime value. Set prior to execution of the
remote_{n} −−client−connect script.
The −−remote parameter. Set on program initiation and reset on SI
GHUP. tls_id_{n}
A series of certificate fields from the remote peer, where n is th
remote_port_{n} e verification level. Only set for TLS
The remote port number, specified by −−port or −−rport. Set on pr connections. Set prior to execution of −−tls−verify script.
ogram initiation and reset on SIGHUP.
tls_serial_{n}
route_net_gateway The serial number of the certificate from the remote peer, where n
The pre−existing default IP gateway in the system routing table. is the verification level. Only set for
Set prior to −−up script execution. TLS connections. Set prior to execution of −−tls−verify script.
route_vpn_gateway tun_mtu
The default gateway used by −−route options, as specified in eithe The MTU of the TUN/TAP device. Set prior to −−up or −−down script
r the −−route−gateway option or the secâM−^@M−^P execution.
ond parameter to −−ifconfig when −−dev tun is specified. Set prio
r to −−up script execution. trusted_ip
Actual IP address of connecting client or peer which has been auth
route_{parm}_{n} enticated. Set prior to execution of
A set of variables which define each route to be added, and are se −−ipchange, −−client−connect, and −−client−disconnect scripts.
t prior to −−up script execution.
trusted_port
parm will be one of "network", "netmask", "gateway", or "metric". Actual port number of connecting client or peer which has been
authenticated. Set prior to execution of
n is the OpenVPN route number, starting from 1. −−ipchange, −−client−connect, and −−client−disconnect scripts.

If the network or gateway are resolvable DNS names, their IP add untrusted_ip
ress translations will be recorded rather Actual IP address of connecting client or peer which has not been
than their names as denoted on the command line or configuration f authenticated yet. Sometimes used to
ile. nmap the connecting host in a −−tls−verify script to ensure it is
firewalled properly. Set prior to execuâM−^@M−^P
script_context tion of −−tls−verify and −−auth−user−pass−verify scripts.
Set to "init" or "restart" prior to up/down script execution. For
more information, see documentation for untrusted_port
−−up. Actual port number of connecting client or peer which has not been
authenticated yet. Set prior to execuâM−^@M−^P
script_type tion of −−tls−verify and −−auth−user−pass−verify scripts.
One of up, down, ipchange, route−up, tls−verify, auth−user−pass−v
erify, client−connect, client−disconnect, username
or learn−address. Set prior to execution of any script. The username provided by a connecting client. Set prior to −−au
th−user−pass−verify script execution only
signal The reason for exit or restart. Can be one of sigusr1, sighup, si when the via−env modifier is specified.
gterm, sigint, inactive (controlled by
−−inactive option), ping−exit (controlled by −−ping−exit opt X509_{n}_{subject_field}
ion), ping−restart (controlled by −−ping− An X509 subject field from the remote peer certificate, where n is
restart option), connection−reset (triggered on TCP connection res the verification level. Only set for
et), error, or unknown (unknown signal). TLS connections. Set prior to execution of −−tls−verify script
This variable is set just prior to down script execution. . This variable is similar to tls_id_{n}
except the component X509 subject fields are broken out, and no st
time_ascii ring remapping occurs on these field valâM−^@M−^P
Monday May 07, 2012 − 31/35
Printed by root

May 07, 12 21:14 − Page 63/69 May 07, 12 21:14 − Page 64/69
ues (except for remapping of control characters to "_"). For exam EXAMPLES
ple, the following variables would be set Prior to running these examples, you should have OpenVPN installed on t
on the OpenVPN server using the sample client certificate in sampl wo machines with network connectivity
e−keys (client.crt). Note that the veriâM−^@M−^P between them. If you have not yet installed OpenVPN, consult the INSTA
fication level is 0 for the client certificate and 1 for the CA ce LL file included in the OpenVPN distribuâM−^@M−^P
rtificate. tion.
X509_0_emailAddress=me@myhost.mydomain TUN/TAP Setup:
X509_0_CN=Test−Client If you are using Linux 2.4 or higher, make the tun device node and load t
X509_0_O=OpenVPN−TEST he tun module:
X509_0_ST=NA
X509_0_C=KG mknod /dev/net/tun c 10 200
X509_1_emailAddress=me@myhost.mydomain
X509_1_O=OpenVPN−TEST modprobe tun
X509_1_L=BISHKEK
X509_1_ST=NA If you installed from RPM, the mknod step may be omitted, because the RPM
X509_1_C=KG install does that for you.

SIGNALS If you have Linux 2.2, you should obtain version 1.1 of the TUN/TAP drive
SIGHUP Cause OpenVPN to close all TUN/TAP and network connections, re r from http://vtun.sourceforge.net/tun/
start, re−read the configuration file (if and follow the installation instructions.
any), and reopen TUN/TAP and network connections.
For other platforms, consult the INSTALL file at http://openvpn.net/insta
SIGUSR1 ll.html for more information.
Like SIGHUP, except don’t re−read configuration file, and possibly
don’t close and reopen TUN/TAP device, Firewall Setup:
re−read key files, preserve local IP address/port, or prese If firewalls exist between the two machines, they should be set to forw
rve most recently authenticated remote IP ard UDP port 1194 in both directions. If
address/port based on −−persist−tun, −−persist−key, −−persist−loc you do not have control over the firewalls between the two machines, you
al−ip, and −−persist−remote−ip options may still be able to use OpenVPN by
respectively (see above). adding −−ping 15 to each of the openvpn commands used below in the exampl
es (this will cause each peer to send out
This signal may also be internally generated by a timeout conditio a UDP ping to its remote peer once every 15 seconds which will cause many
n, governed by the −−ping−restart option. stateful firewalls to forward packets in
both directions without an explicit firewall rule).
This signal, when combined with −−persist−remote−ip, may be s
ent when the underlying parameters of the If you are using a Linux iptables−based firewall, you may need to ente
host’s network interface change such as when the host is a DHCP cl r the following command to allow incoming
ient and is assigned a new IP address. packets on the TUN device:
See −−ipchange above for more information.
iptables −A INPUT −i tun+ −j ACCEPT
SIGUSR2
Causes OpenVPN to display its current statistics (to the syslog f See the firewalls section below for more information on configuring firew
ile if −−daemon is used, or stdout otherâM−^@M−^P alls for use with OpenVPN.
wise).
VPN Address Setup:
SIGINT, SIGTERM For purposes of our example, our two machines will be called may.kg and j
Causes OpenVPN to exit gracefully. une.kg. If you are constructing a VPN
over the internet, then replace may.kg and june.kg with the internet host
TUN/TAP DRIVER SETUP name or IP address that each machine will
If you are running Linux 2.4.7 or higher, you probably have the TUN/TAP d use to contact the other over the internet.
river already installed. If so, there
are still a few things you need to do: Now we will choose the tunnel endpoints. Tunnel endpoints are private IP
addresses that only have meaning in the
Make device: mknod /dev/net/tun c 10 200 context of the VPN. Each machine will use the tunnel endpoint of the oth
er machine to access it over the VPN. In
Load driver: modprobe tun our example, the tunnel endpoint for may.kg will be 10.4.0.1 and for june
.kg, 10.4.0.2.
If you have Linux 2.2 or earlier, you should obtain version 1.1 of th
e TUN/TAP driver from http://vtun.sourceâM−^@M−^P Once the VPN is established, you have essentially created a secure altern
forge.net/tun/ and follow the installation instructions. ate path between the two hosts which is
addressed by using the tunnel endpoints. You can control which network
Monday May 07, 2012 − 32/35
Printed by root

May 07, 12 21:14 − Page 65/69 May 07, 12 21:14 − Page 66/69
traffic passes between the hosts (a) over verb 5 −−secret key
the VPN or (b) independently of the VPN, by choosing whether to use (a) t
he VPN endpoint address or (b) the public Now verify the tunnel is working by pinging across the tunnel.
internet address, to access the remote host. For example if you are on
may.kg and you wish to connect to june.kg On may:
via ssh without using the VPN (since ssh has its own built−in security) y
ou would use the command ssh june.kg. ping 10.4.0.2
However in the same scenario, you could also use the command telnet
10.4.0.2 to create a telnet session with On june:
june.kg over the VPN, that would use the VPN to secure the session rather
than ssh. ping 10.4.0.1
You can use any address you wish for the tunnel endpoints but make sure t Example 3: A tunnel with full TLS−based security
hat they are private addresses (such as For this test, we will designate may as the TLS client and june as th
those that begin with 10 or 192.168) and that they are not part of any e TLS server. Note that client or server
existing subnet on the networks of either designation only has meaning for the TLS subsystem. It has no bearing on
peer, unless you are bridging. If you use an address that is part of you OpenVPN’s peer−to−peer, UDP−based commuâM−^@M−^P
r local subnet for either of the tunnel nication model.
endpoints, you will get a weird feedback loop.
First, build a separate certificate/key pair for both may and june (see
Example 1: A simple tunnel without security above where −−cert is discussed for more
On may: info). Then construct Diffie Hellman parameters (see above where −−dh is
discussed for more info). You can also
openvpn −−remote june.kg −−dev tun1 −−ifconfig 10.4.0.1 10.4.0.2 − use the included test files client.crt, client.key, server.crt, server
−verb 9 .key and ca.crt. The .crt files are cerâM−^@M−^P
tificates/public−keys, the .key files are private keys, and ca.crt is a c
On june: ertification authority who has signed
both client.crt and server.crt. For Diffie Hellman parameters you ca
openvpn −−remote may.kg −−dev tun1 −−ifconfig 10.4.0.2 10.4.0.1 −− n use the included file dh1024.pem. Note
verb 9 that all client, server, and certificate authority certificates and keys
included in the OpenVPN distribution are
Now verify the tunnel is working by pinging across the tunnel. totally insecure and should be used for testing only.

On may: On may:

ping 10.4.0.2 openvpn −−remote june.kg −−dev tun1 −−ifconfig 10.4.0.1 10.4.0.2 −
−tls−client −−ca ca.crt −−cert client.crt
On june: −−key client.key −−reneg−sec 60 −−verb 5

ping 10.4.0.1 On june:

The −−verb 9 option will produce verbose output, similar to the tcpdump openvpn −−remote may.kg −−dev tun1 −−ifconfig 10.4.0.2 10.4.0.1 −−
(8) program. Omit the −−verb 9 option to tls−server −−dh dh1024.pem −−ca ca.crt
have OpenVPN run quietly. −−cert server.crt −−key server.key −−reneg−sec 60 −−verb 5

Example 2: A tunnel with static−key security (i.e. using a pre−shared secret) Now verify the tunnel is working by pinging across the tunnel.
First build a static key on may.
On may:
openvpn −−genkey −−secret key
ping 10.4.0.2
This command will build a random key file called key (in ascii format).
Now copy key to june over a secure medium On june:
such as by using the scp(1) program.
ping 10.4.0.1
On may:
Notice the −−reneg−sec 60 option we used above. That tells OpenVPN t
openvpn −−remote june.kg −−dev tun1 −−ifconfig 10.4.0.1 10.4.0.2 − o renegotiate the data channel keys every
−verb 5 −−secret key minute. Since we used −−verb 5 above, you will see status information on
each new key negotiation.
On june:
For production operations, a key renegotiation interval of 60 seconds is
openvpn −−remote may.kg −−dev tun1 −−ifconfig 10.4.0.2 10.4.0.1 −− probably too frequent. Omit the −−reneg−
Monday May 07, 2012 − 33/35
Printed by root

May 07, 12 21:14 − Page 67/69 May 07, 12 21:14 − Page 68/69
sec 60 option to use OpenVPN’s default key renegotiation interval of one n, OpenVPN will be guaranteed to send a packet to its peer at least onc
hour. e every n seconds. If n is less than the
stateful firewall connection timeout, you can maintain an OpenVPN connect
Routing: ion indefinitely without explicit fireâM−^@M−^P
Assuming you can ping across the tunnel, the next step is to route a rea wall rules.
l subnet over the secure tunnel. Suppose
that may and june have two network interfaces each, one connected to the You should also add firewall rules to allow incoming IP traffic on TUN or
internet, and the other to a private netâM−^@M−^P TAP devices such as:
work. Our goal is to securely connect both private networks. We
will assume that may’s private subnet is iptables −A INPUT −i tun+ −j ACCEPT
10.0.0.0/24 and june’s is 10.0.1.0/24.
to allow input packets from tun devices,
First, ensure that IP forwarding is enabled on both peers. On Linux, ena
ble routing: iptables −A FORWARD −i tun+ −j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward to allow input packets from tun devices to be forwarded to other hosts on
the local network,
and enable TUN packet forwarding through the firewall:
iptables −A INPUT −i tap+ −j ACCEPT
iptables −A FORWARD −i tun+ −j ACCEPT
to allow input packets from tap devices, and
On may:
iptables −A FORWARD −i tap+ −j ACCEPT
route add −net 10.0.1.0 netmask 255.255.255.0 gw 10.4.0.2
to allow input packets from tap devices to be forwarded to other hosts on
On june: the local network.
route add −net 10.0.0.0 netmask 255.255.255.0 gw 10.4.0.1 These rules are secure if you use packet authentication, since no inc
oming packets will arrive on a TUN or TAP
Now any machine on the 10.0.0.0/24 subnet can access any machine on the 1 virtual device unless they first pass an HMAC authentication test.
0.0.1.0/24 subnet over the secure tunnel
(or vice versa). FAQ
http://openvpn.net/faq.html
In a production environment, you could put the route command(s) in
a shell script and execute with the −−up HOWTO
option. For a more comprehensive guide to setting up OpenVPN in a productio
n setting, see the OpenVPN HOWTO at
FIREWALLS http://openvpn.net/howto.html
OpenVPN’s usage of a single UDP port makes it fairly firewall−friendly.
You should add an entry to your firewall PROTOCOL
rules to allow incoming OpenVPN packets. On Linux 2.4+: For a description of OpenVPN’s underlying protocol, see http://openvpn.ne
t/security.html
iptables −A INPUT −p udp −s 1.2.3.4 −−dport 1194 −j ACCEPT
WEB
This will allow incoming packets on UDP port 1194 (OpenVPN’s default UDP OpenVPN’s web site is at http://openvpn.net/
port) from an OpenVPN peer at 1.2.3.4.
Go here to download the latest version of OpenVPN, subscribe to the maili
If you are using HMAC−based packet authentication (the default in any of ng lists, read the mailing list archives,
OpenVPN’s secure modes), having the fireâM−^@M−^P or browse the SVN repository.
wall filter on source address can be considered optional, since HMAC pack
et authentication is a much more secure BUGS
method of verifying the authenticity of a packet source. In that case: Report all bugs to the OpenVPN team <info@openvpn.net>.
iptables −A INPUT −p udp −−dport 1194 −j ACCEPT SEE ALSO
dhcpcd(8), ifconfig(8), openssl(1), route(8), scp(1) ssh(1)
would be adequate and would not render the host inflexible with respect t
o its peer having a dynamic IP address. NOTES
This product includes software developed by the OpenSSL Project ( http://
OpenVPN also works well on stateful firewalls. In some cases, you ma www.openssl.org/ )
y not need to add any static rules to the
firewall list if you are using a stateful firewall that knows how to trac For more information on the TLS protocol, see http://www.ietf.org/rfc/rfc
k UDP connections. If you specify −−ping 2246.txt
Monday May 07, 2012 − 34/35
Printed by root

May 07, 12 21:14 − Page 69/69

For more information on the LZO real−time compression library see http://
www.oberhumer.com/opensource/lzo/
COPYRIGHT
Copyright (C) 2002−2010 OpenVPN Technologies, Inc. This program is free s
oftware; 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 FoundaâM−^@M−^P
tion.
AUTHORS
James Yonan <jim@yonan.net>

17 November 2008
openvpn(8)

Monday May 07, 2012 − 35/35

You might also like