This is an old revision of the document!
Here, you can view/configure settings for OpenVPN Servers via the web interface. A custom configuration area allows more settings customization.
OpenVPN is an evolving VPN implementation using SSL/TLS security.
It has several advantages over some older protocols, including:
However, there are still differences between versions. For example, clients and servers may be configured on different versions. Encryption algorithms may be negotiated differently among versions. FreshTomato 2024.3 includes OpenVPN 2.6.12. For details, see the OpenVPN documentation/support forums: https://build.openvpn.net/man/openvpn-2.5/openvpn.8.html
FreshTomato can run 2 concurrent OpenVPN Server instances, with different configurations (“Server 1”/“Server 2”).
Each server menu has its own interface tabs:
The Basic and Advanced Tabs are used to configure the general setup of servers and configuration file options. The OpenVPN server reads options settings when it starts. It first reads Options set in the web interface, then it reads options.
In the Keys tab you enter (externally-sourced) encryption keys used. You can also generate keys directly there, for setups that don't get keys from an external source.
When the OpenVPN server is running, the “Status” tab shows connected clients, routing and statistics.
Start with WAN: makes OpenVPN Server run whenever the WAN interface comes up. This is used to make OpenVPN run 24/7.
Start Now: starts the OpenVPN server immediately if Start with WAN is unchecked, or the server isn't running.
VPNs use virtual (software) network devices to emulate physical network adapters.
OpenVPN has 2 main types of virtual interfaces:
TUN, (“network TUNnel”), emulates a network layer device.
TUN operates at OSI layer 3 to carry IP datagrams. It is used with routing. In general, TUN is used for VPN tunnels where only IP is used.
Advantages
Disadvantages
TAP, (“network TAP”), simulates a layer 2, link layer device to create a bridge.
It carries full Ethernet frames through the tunnel. It supports non-routable protocols (IPX/ AppleTalk).
Other important differences include:
Common applications of TUN/TAP include:
Advantages
Disadvantages
Clients/server must use the same Interface types. You can't use TAP on clients and TUN on servers.
This appears when TAP is chosen. Here, you choose the VLANs to which to bridge clients that connect to the OpenVPN server.
OpenVPN can run over TCP or UDP transport protocols.
UDP OpenVPN Protocol
TCP OpenVPN Protocol
Here, set the port on which OpenVPN server listens on the WAN interface.
You must set firewall / IPTables rules to let traffic through the port. The IANA assignment for OpenVPN is port 1194, but other ports may be used.
This lets you set the authorization mode for the OpenVPN Server.
OpenVPN lets peers authenticate each other using a Static (Pre‐Shared) Key or certificates.
In client‐server configuration, The OpenVPN server releases an authentication certificate for each client, using signature/certificate authority.
OpenVPN uses the OpenSSL encryption library, and the SSLv3/TLSv1 protocol. It has many security and control features.
Static Key
Advantages
Disadvantages
This menu appears if TLS Authorization mode is chosen. It lets you choose the security measures to apply to the control channel.
TLS authentication/encryption options require you to generate and distribute some additional static keys for the server/clients. Both tls-auth and tls-crypt require you to have at least one pre-shared key used by server and clients.
By contrast, with Tls-crypt-v2, you must generate specific keys for each client. (Ref. OpenVPN –tls-auth, –tls-crypt, –tls-crypt-v2 and –secret).
TLS exchanges multiple packets to authenticate a peer. In the exchange, OpenVPN allocates memory and CPU resources to the potential peer. The potential peer exposes parts of OpenVPN and the OpenSSL library to the packets it sends.
Most current network attacks exploit bugs in programs (like overflow attacks) or force a program to consume so many resources it becomes unusable. The first line of defense is good programming. Preventing buffer overflow attacks was a main goal in designing OpenVPN. Even so, many widely-used network applications still fall to buffer overflow attacks.
The second line of defense is tls-auth, an authentication layer on top of the TLS Control channel. There, every control channel packet is authenticated by an HMAC signature and a Unique ID. This prevents replay attacks. The signature also helps protect against DoS attacks. DoS attacks are less likely when an unauthenticated client is limited in the resources it may use.
Enabling TLS Control Channel Security (Encrypt Channel / tls-crypt) makes FreshTomato sign every control channel packet with an HMAC signature. This includes packets sent before the TLS layer has authenticated its peer. Packets without the correct signature will immediately be dropped on receipt. As a result, those packets have no chance to consume more system resources.
However, this is feature is optional. The key file used with –tls-auth gives a peer the only the power to initiate a TLS handshake. It's not used to encrypt/authenticate tunnel data. Encrypt Channel should be used if you want to use the key file to authenticate and encrypt the TLS control channel.
This authentication system reduces the risks of the plaintext method when Basic authentication is used.
With Auth Digest, a client sends a hash of its data over the network. The client's username/password are never sent in plaintext, reducing the risk that someone might snoop the logon credentials.
With any setting except None, OpenVPN authenticates data channel packets and tls-auth control channel packets with HMAC. It uses a message digest algorithm (default: SHA1) for this. HMAC is a common Message Authentication Code algorithm.
HMAC produces a digital signature using:
The OpenVPN data channel protocol uses Encrypt-then-Mac order.
This method helps prevent padding oracle attacks.
If an AEAD cipher mode (say, GCM) is chosen, the specified –auth algorithm is ignored for the data channel. The AEAD's cipher authentication method is used instead. However, alg still specifies the digest used for tls-auth.
In Static Key encryption mode, the HMAC key is included in the key file. In TLS mode, the HMAC key is dynamically generated and shared between peers via the TLS control channel. If OpenVPN receives a packet with a bad HMAC, it drops that packet. Typically, HMAC adds 16 or 20 bytes per packet.
For basic HMAC information, see: TutorialsPoint: Message Authentication Code
This appears when TUN interface type is chosen. Here, enter the subnet/netmask used to assign addresses to OpenVPN clients.
If TUN is selected, the VPN topology is set to “subnet”. This mode allocates a single IP address per client connecting from the subnet range. If you need another OpenVPN topology, that must be set in the custom configuration field. (Ref. OpenVPN option “–topology”. Successful overriding of “–topology subnet” with a different topology in custom configuration to be confirmed.)
This option appears if TAP interface type is chosen. It sets the method used to assign addresses to OpenVPN clients.
DHCP - if checked, DHCP will assign addresses to OpenVPN clients from the normal DHCP pool.
If unchecked, the Client Address Pool field appears, prompting you for a special pool of VPN client addresses.
If set greater than zero, a watchdog polls connectivity every n minutes, to verify OpenVPN is running. If it finds OpenVPN isn't running, it restarts the OpenVPN service. If set to “0”, the watchdog is disabled.
[TBD]
This instructs OpenVPN clients to redirect all Internet traffic through this server. In other words, this server becomes their default gateway. If disabled, the client performs its default routing.
On supported platforms, this sets the client DNS server to the local FreshTomato DNS. (Ref.OpenVPN “–dhcp-option”)
This contains a colon-delimited list of ciphers in the order they'll be negotiated with clients. If nothing is defined, the server defaults to “AES-256-GCM:AES-128-GCM”.
The first cipher in the list that the client supports will be pushed to clients that support cipher negotiation. If no common cipher is found during negotiation, the connection is terminated.
Available ciphers include:
(Ref. OpenVPN “–data-ciphers”)
This enables either the LZO or LZ4 compression algorithm. Generally, LZ4 offers the best performance/CPU usage balance. For backwards compatibility with OpenVPN versions earlier than v2.4, use “LZO”. LZO is identical to the older OpenVPN option “–comp-lzo yes”.
Choosing Disabled disables compression. However, packet framing for compression is still enabled, allowing a different setting to be pushed later.
Security Considerations
Combining compression and encryption is tricky. If an attacker knows or is able to control (parts of) the plaintext of packets containing secrets, they might be able to extract the secret if compression is enabled. For example, the CRIME and BREACH attacks on TLS use compression to break encryption. If you're not sure the above problems don't apply to your traffic, disable compression.
Secifies how many seconds (n) will pass before OpenVPN renegotiates the data channel key (Default=3600). When using dual-factor authentication, the default may cause the end user to be asked to reauthorize once every hour.
This can be used on both client and server. Whichever host uses the lower value triggers the renegotiation. It's a common mistake to set this to a higher value on either client or server, while the other end is set with the default. In this case, renegotiation still occurs once every 3600 seconds. The solution is to increase –reneg-sec on both client and server, or set it to “0” (disabled) on one side, and to your preferred value on the other.
If enabled, this lets you apply individual client options. If disabled, the option to allow client certificates with the same common name is applied.
(Ref.OpenVPN “–duplicate-cn”)
With this selected, options appear to enable you to configure access between VPN clients.
The Allow Client↔Client option lets an OpenVPN client access the other OpenVPN client's network, and/or the network behind each OpenVPN client. By default, OpenVPN blocks network access between OpenVPN clients.
When Allow Client↔Client is enabled on the server, you can limit the networks available to clients. Use the “Allow Only These Clients” table to specify and limit the access your client will have over the network. (Ref. OpenVPN “–client-to-client”)
To use Client-Specific Options, each client must have a certificate with a unique, common name (“CN”). This is used to identify which client rule to apply. By default, duplicate client names are rejected.
If you still need client-specific options and don`t want to use unique client certificates, allow usernames as a common name, or duplicate common names. However, using usernames or duplicate common names may lead to unexpected results if you're expecting different client rules.
Consider using one of these phrases in your Custom Settings:
duplicate-cn
Or you could use:
username-as-common-name
You can use the push checkbox in the clients table to push routes to clients. If it is disabled, you must set routes separately in each client configuration. The check box is not applicable when Allow Client↔Client is disabled.
You can set other client-specific options in the Custom Configuration field, and a Client Configuration Directory. Enabling client-specific options creates an internal Client Configuration Directory. That directory holds client-specific options set in the web interface. (Ref. OpenVPN “–client-config-dir”)
[To be confirmed whether multiple Client Config Dirs are read or whether the custom Client Config Dir replaces the 'internal' CCD]
Here, you can specify a custom configuration for the OpenVPN server to use.
For details about valid custom parameters, please see:
https://build.openvpn.net/man/openvpn-2.5/openvpn.8.html
.
If TLS authorization mode is selected, you MUST configure certificates.
Instead of using a static key, you can let the machines use TLS to negotiate an encryption key/algorithm. During the TLS handshake, one machine acts as server and the other as client. When the handshake is complete, OpenVPN interaction is on a peer-to-peer basis.
For a TLS handshake, both “server” and “client” must have their respective certificates. Also, you must generate Diffie-Hellman parameters for the “server”. This will finally lead to the creation of a shared secret number. You will generate your own certificates.
Every certificate is issued by a Certificate Authority, (“CA”), so you must create one. You can create a CA, certificates, and Diffie-Hellman parameters in FreshTomato.
The first step to building an OpenVPN 2.x setup is to create a Public Key Infrastructure.
A PKI consists of:
OpenVPN uses bidirectional, certificate-based authentication. Client/server must authenticate the other's certificates before they establish mutual trust.
Both server and client authenticate each other:
This security model has several desirable features:
Note that server and client clocks need to be roughly synchronized for certificates to function properly.
The Generate Keys button generates all necessary keys directly from the web interface.
It can also be done at the command-line with OpenVPN's “easy-rsa” tool using these instructions:
It may be costly to store certificate values in NVRAM, especially on models with limited NVRAM. The certificates consume about 14 KB of NVRAM space. If your model has limited NVRAM, consider storing certificates in JFFS or other router-connected mass storage. However, consider the security risks before following this procedure. Certificates may be accessible if you use Samba or NFS.
This shows how to include certificates in Custom Configuration if you don't want to use NVRAM:
#Path names and filenames below are used only as example dh /jffs/certs/dh.pem #Contains Diffie-Hellman parameters cert /jffs/certs/srv.crt #Contains Server Certificate Server Key ca /jffs/certs/ca.crt #Contains CA Key
If you're using tls-crypt or tls-auth, you must also define a static pre-shared-key path/file.
A code commit was entered for Elliptical elliptic curve cryptography on 2024-10-19, and should be included in the next release. If your release doesn't support elliptical curve cryptography, you must configure Diffie-Hellman parameters.
Elliptic curve cryptography is also implemented in releases of OpenVPN since v2.4.
There are a few more settings you may need to configure, mostly outside OpenVPN. The most common issues relate to adjusting your OS to allow packet forwarding, and appropriately configuring the firewall.
Configuring a Linux-based firewall can be different from configuring one based on other *nix based OSes. In addition, several Linux distributions have their own tools to manage iptables. As a result, it's better to read the manuals for firewall configuration specific to your OS.
A common mistake when setting up a new Certificate Authority is to place all CA files on the OpenVPN server. **Avoid this**. A CA needs a private key to sign the certificates clients and servers use. If you lose control of the CA private key, you can no longer trust certificates from that CA. At that point, anyone with access to the key can sign new certificates without your knowledge. Clients using those certificates can then connect to your OpenVPN server without changing anything on the VPN Server. Whenever possible, place your CA files on an offline storage medium, only to be activated when you need to get a new certificate for a client or server.
There are 3 files you need to copy from a CA to achieve this:
The server also needs a Diffie-Hellman parameters file.
Also, avoid generating keys on devices that don't have a good entropy source for randomizing data. This includes most common Wi-Fi routers and similar embedded devices. As well, many VMs don't have a good entropy source, or can be manipulated via the hypervisor. Always try to generate keys and Diffie-Hellman parameters on bare metal equipment.
To better understand PKI, see this introduction:
https://github.com/OpenVPN/easy-rsa/blob/master/doc/Intro-To-PKI.md
Within the CA, you can revoke certificates when needed. Using your preferred CA management tool, you can generate a Certificate Revocation List (CRL file). Adding this to the OpenVPN server should cause all client certificates to be checked against this list. Clients whose certificates are listed in the CRL won't be allowed to connect. This common method lets you deny access to a VPN on a per-user level.
Add this line to the OpenVPN server configuration:
crl /full/path/to/crl.pem
In some cases, when you've generated server certificate/keys using EasyRSA 3, the server may not start. This can be happen when the server certificate requires a password but there was no way to provide it. In such cases, regenerate the certificate/key using the the EasyRSA “nopass” option. This should allow OpenVPN Server to start properly.
You must add network routes to access specific resources from other IP addresses via the VPN. A route tells your system where to send network traffic to access certain resources. An OS can handle multiple routes via multiple gateways at the same time.
For example, let's say:
You need to configure OpenVPN to route specific hosts or networks through the tunnel.
To do this, you must add a line similar to this in the server configuration:
push "route 192.168.1.0 255.255.255.0"
You must then restart both the OpenVPN server and the client.
This will cause the server to tell any client that connects to route all traffic for IP addresses in scope 192.168.1.XXX through the VPN.
This example describes a basic setup. The setup is almost complete. The only thing left is to add the appropriate routes, as with normal routing.
You also must ensure return routes. Just because a VPN client can access a host behind the VPN server, doesn't mean the host behind the server will send the response via the same route. Hosts behind the VPN server must know which gateway to use for VPN traffic. Usually, this is done by adding a route on the existing default gateway. Then, if you run OpenVPN on an existing gateway, you have the return route already implicitly configured.
For a more detailed example, see the Using routing section in the Bridging and routing wiki page.
You can route all network traffic over the VPN. The configuration for this is fairly simple. However, you'll need to learn how to configure NAT on your VPN server for the virtual TUN adapter.
You can do this by pushing a “route everything over VPN” setting via the server. Another method is to add it explicitly to the client configuration. Don't use both methods at the same time.
This illustrates the server push method:
push "redirect-gateway def1"
This illustrates the client configuration method:
redirect-gateway def1
OpenVPN v2.3 and later support IPv6. Configuring IPv6 for a VPN is similar to the above IPv4 examples. To configure IPv6, you must use the
–server-ipv6 and –route-ipv6 options.
For example, adding this sets the IPv6 addresses for server/clients:
server-ipv6 2001:db8:cada::/64
You can use the –route-ipv6 option two ways. You can push it from the server, or use it directly in client settings. The same is true for the –route option.
The syntax is similar:
route-ipv6 2001:db8:daca::/64