Link options
This section covers options related to the connection between the local and the remote host.Use protocol for communicating with remote host.Valid values:
udp(default)tcp-clienttcp-serverudp4,tcp4-client,tcp4-server(IPv4 only)udp6,tcp6-client,tcp6-server(IPv6 only)
--proto udp should be specified on both peers.For TCP operation, one peer must use --proto tcp-server and the other must use --proto tcp-client. A peer started with tcp-server will wait indefinitely for an incoming connection. A peer started with tcp-client will attempt to connect, and if that fails, will sleep for 5 seconds and try again.OpenVPN is designed to operate optimally over UDP, but TCP capability is provided for situations where UDP cannot be used. In comparison with UDP, TCP will usually be somewhat less efficient and less robust when used over unreliable or congested networks.
TCP/UDP port number or port name for both local and remote (sets both
--lport and --rport options to given port).The current default of 1194 represents the official IANA port number assignment for OpenVPN.Set local TCP/UDP port number. Cannot be used together with
--nobind option.A port number of 0 is only honored to achieve “bind() to a random assigned port number” if a bind-to IP address is specified with --local.Set TCP/UDP port number or name used by the
--remote option. The port can also be set directly using the --remote option.Local host name or IP address and port for bind.Syntax:If specified, OpenVPN will bind to this address. If unspecified, OpenVPN will bind to all interfaces.
* can be used as hostname and means ‘any host’ (OpenVPN will listen on what is returned by the OS).On an OpenVPN setup running as --server, this can be specified multiple times to open multiple listening sockets on different addresses and/or different ports.--local implies --bind.Bind to local address and port. This is the default unless any of
--proto tcp-client, --http-proxy or --socks-proxy are used.If the optional ipv6only keyword is present, OpenVPN will bind only to IPv6 (as opposed to IPv6 and IPv4) when a IPv6 socket is opened.Do not bind to local address and port. The IP stack will allocate a dynamic port for returning packets.
Allow remote peer to change its IP address and/or port number, such as due to DHCP (this is the default if
--remote is not used).When specified with --remote, allows an OpenVPN session to initially connect to a peer at a known address, however if packets arrive from a new address and pass all authentication tests, the new address will take control of the session.This is useful when connecting to a peer which holds a dynamic address such as a dial-in user or DHCP client.
A helper directive designed to simplify the expression of Send ping once every This expands on the server to:
--ping and --ping-restart.Syntax:interval seconds, restart if ping is not received for timeout seconds.This option can be used on both client and server side, but it is enough to add this on the server side as it will push appropriate --ping and --ping-restart options to the client.Example:Ping remote over the TCP/UDP control channel if no packets have been sent for at least n seconds.This option has two intended uses:
- Compatibility with stateful firewalls. The periodic ping will ensure that a stateful firewall rule which allows OpenVPN UDP packets to pass will not time out.
- To provide a basis for the remote to test the existence of its peer using the
--ping-exitoption.
Similar to
--ping-exit, but trigger a SIGUSR1 restart after n seconds pass without reception of a ping or other packet from remote.This option is useful in cases where the remote peer has a dynamic IP address and a low-TTL DNS name is used to track the IP address.In client mode, the
--ping-restart parameter is set to 120 seconds by default. This default will hold until the client pulls a replacement value from the server, based on the --keepalive setting in the server configuration.Announce to TCP sessions running over the tunnel that they should limit their send packet sizes.Syntax:The default value is
1492 mtu. Use 0 as max to disable mssfix.If the mtu parameter is specified, the max value is interpreted as the resulting packet size of VPN packets including the IP and UDP header.If the fixed parameter is specified, OpenVPN will make no attempt to calculate the VPN encapsulation overhead but instead will set the MSS to limit the size of the payload IP packets to the specified number.The
--mssfix option only makes sense when you are using the UDP protocol for OpenVPN peer-to-peer communication.Enable internal datagram fragmentation so that no UDP datagrams are sent which are larger than max bytes.Syntax:If the
mtu parameter is present, the max parameter is interpreted to include IP and UDP encapsulation overhead.Instruct OpenVPN to try to limit the maximum on-write packet size by restricting the control channel packet size and setting
--mssfix.OpenVPN will try to keep its control channel messages below this size. The default is 1250 bytes.The control channel packet size will be restricted to values between 154 and 2048. The maximum packet size includes encapsulation overhead like UDP and IP.In general the default size of 1250 should work almost universally, especially since IPv6 requires a MTU of 1280 or larger.
Modify the replay protection sliding-window size and time window.Syntax:Use a replay protection sliding-window of size
n and a time window of t seconds.By default n is 64 (the IPSec default) and t is 15 seconds.This option is only relevant in UDP mode.
Apply the given flags to the OpenVPN transport socket. Currently, only
TCP_NODELAY is supported.The TCP_NODELAY socket flag is useful in TCP mode, and causes the kernel to send tunnel packets immediately over the TCP connection without trying to group several smaller packets into a larger packet. This can result in a considerable improvement in latency.This macro sets the
TCP_NODELAY socket flag on the server as well as pushes it to connecting clients.The TCP_NODELAY flag disables the Nagle algorithm on TCP sockets causing packets to be transmitted immediately with low latency, rather than waiting a short period of time in order to aggregate several packets into a larger containing packet.In VPN applications over TCP,
TCP_NODELAY is generally a good latency optimization.Virtual network adapter options
Options in this section relate to configuration of the virtual tun/tap network interface, including setting the VPN IP address and network routing.TUN/TAP virtual network device which can be
tunX, tapX, null or an arbitrary name string (X can be omitted for a dynamic device).You must use either tun devices on both ends of the connection or tap devices on both ends. You cannot mix them:tundevices encapsulate IPv4 or IPv6 (OSI Layer 3)tapdevices encapsulate Ethernet 802.3 (OSI Layer 2)
Which device type are we using? Should be
tun (OSI Layer 3) or tap (OSI Layer 2).Use this option only if the TUN/TAP device used with --dev does not begin with tun or tap.Configure virtual addressing topology when running in
--dev tun mode. This directive has no meaning in --dev tap mode, which always uses a subnet topology.Valid values:subnet(default) - Use a subnet rather than a point-to-point topologynet30- Use a point-to-point topology, by allocating one /30 subnet per clientp2p- Use a point-to-point topology where the remote endpoint always points to the local endpoint
Using
--topology subnet changes the interpretation of the arguments of --ifconfig to mean “address netmask”, and not “local remote”.Set TUN/TAP adapter parameters. It requires the IP address of the local VPN endpoint.For TUN devices in point-to-point mode, the next argument must be the VPN IP address of the remote VPN endpoint.For TAP devices, or TUN devices used with
--topology subnet, the second argument is the subnet mask of the virtual network segment.Examples:Configure an IPv6 address on the tun device.Syntax:The
ipv6addr/bits argument is the IPv6 address to use. The second parameter is used as route target for --route-ipv6 if no gateway is specified.The
--topology option has no influence with --ifconfig-ipv6.Add route to routing table after connection is established. Multiple routes can be specified.Syntax:Special keywords for gateway:
vpn_gateway- The remote VPN endpoint addressnet_gateway- The pre-existing IP default gatewayremote_host- The--remoteaddress if OpenVPN is being run in client mode
Setup IPv6 routing in the system to send the specified IPv6 network into OpenVPN’s tun.Syntax:
Specify a default gateway for use with If
--route.Syntax:dhcp is specified as the parameter, the gateway address will be extracted from a DHCP negotiation with the OpenVPN server-side LAN.Specify a default metric for use with
--route.Delay n seconds (default 0) after connection establishment, before adding routes.Syntax:If
n is 0, routes will be added immediately upon connection establishment.This option is designed to be useful in scenarios where DHCP is used to set tap adapter addresses. The delay will give the DHCP handshake time to complete before routes are added.
Automatically execute routing commands to cause all outgoing IP traffic to be redirected over the VPN. This is a client-side option.Option flags:
local- Add if both OpenVPN peers are directly connected via a common subnetautolocal- Try to automatically determine whether to enablelocalflagdef1- Override the default gateway by using 0.0.0.0/1 and 128.0.0.0/1 rather than 0.0.0.0/0bypass-dhcp- Add a direct route to the DHCP server which bypasses the tunnelbypass-dns- Add a direct route to the DNS server(s) which bypasses the tunnelblock-local- Block access to local LAN when the tunnel is activeipv6- Redirect IPv6 routing into the tunnel!ipv4- Do not redirect IPv4 traffic
When used with
--client or --pull, accept options pushed by server EXCEPT for routes, block-outside-dns and dhcp options like DNS servers.This option effectively bars the server from adding routes to the client’s routing table, however note that this option still allows the server to set the TCP/IP properties of the client’s TUN/TAP interface.
Take the TUN device MTU to be tun-mtu and derive the link MTU from it.Syntax:The default for tun-mtu is 1500.
In most cases, you will probably want to leave this parameter set to its default value. It’s best to use the
--fragment and/or --mssfix options to deal with MTU sizing issues.This configures the maximum MTU size that a server can push to maxmtu, by configuring the internal buffers to allow at least this packet size.The default for
maxmtu is 1600. Currently, only increasing beyond 1600 is possible.Don’t close and reopen TUN/TAP device or run up/down scripts across SIGUSR1 or
--ping-restart restarts.On Linux, this option can be useful when OpenVPN is not executed as root and the CAP_NET_ADMIN has not been granted, because the process would otherwise not be allowed to bring the interface down and back up.
On the client, instead of sending IPv6 packets over the VPN tunnel, all IPv6 packets are answered with an ICMPv6 no route host message.On the server, all IPv6 packets from clients are answered with an ICMPv6 no route to host message.
This option is intended for cases when IPv6 should be blocked and other options are not available.
Set additional network parameters on supported platforms. May be specified on the client or pushed from the server.Syntax:Valid types:
DOMAIN name- Set Connection-specific DNS SuffixDOMAIN-SEARCH name- Add name to the domain search listDNS address- Set primary domain name server IPv4 or IPv6 addressWINS address- Set primary WINS server addressNTP address- Set primary NTP server addressNBDD address- Set primary NBDD server addressNBT type- Set NetBIOS over TCP/IP Node type (1=b-node, 2=p-node, 4=m-node, 8=h-node)DISABLE-NBT- Disable Netbios-over-TCP/IP
Standalone TUN/TAP operations
Create a persistent tunnel on platforms which support them such as Linux.Normally TUN/TAP tunnels exist only for the period of time that an application has them open. This option takes advantage of the TUN/TAP driver’s ability to build persistent tunnels that live through multiple instantiations of OpenVPN and die only when they are deleted or the machine is rebooted.
One of the advantages of persistent tunnels is that they eliminate the need for separate
--up and --down scripts to run the appropriate ifconfig and route commands.Remove a persistent tunnel.