Table of Contents

Static IPSec VPN

The following document provides information on how to configure the IPsec VPN service for your ClearOS system.

The app is available in two flavours, the full Business version and a free Basic version.

The Basic version provides:-

The Business version comes with the above plus options to support connections with third party hardware:-

Installation

If you did not select this module to be included during the installation process, you must first install the module.

You can find this feature in the menu system at the following location:

<navigation>Network|VPN|Static IPsec VPN</navigation>

Configuring Connections with Static IPsec VPN

The Static IPsec VPN app enables you to configure secure IPsec encrypted tunnels between two or more networks, in host-to-host or subnet-to-subnet type arrangements. In order to create a connection between two systems, you need to configure both VPN systems.

When creating tunnels it is often helpful to have a third party connection which can be used to connect to either tunnel in the event of problems. This is because the route for packets between hosts will be lost once the tunnel is configured, but may not be functional.

IPsec VPN's are a widely supported method of connecting sites together by creating an encrypted tunnel across the public internet between two private networks.

IPsec VPN is ideally suited for use in scenarios which have a static IP at each end. For dynamic IP configurations, please see the Dynamic VPN app available from the Marketplace.

Tunnel Creation

From the webconfig tool, click on add in the Static VPN Connections box. In summary to create a tunnel you need to:

Note: * denotes options that are not available in the basic version of the app

For the best chance of success connecting to third party IPsec hardware, connection configurations must match at both ends.

Tunnel Examples

In most implementations subnets are used to separate one side of the VPN from the other.

<important>The LAN networks at either end of the VPN connection must not overlap!</important>

Local Site
WAN IP = 1.2.3.4
LAN Subnet = 192.168.1.XXX
LAN IP = 192.168.1.1

Remote Site 1
WAN IP = 4.5.6.7
LAN Subnet = 192.168.2.XXX
LAN IP = 192.168.2.1

Local-to-Remote1 Site-to-Site Tunnel configuration

Local-to-Remote1 Host-to-Host Tunnel configuration

Local-to-Remote1 using Default Route (can be used if Local has a dynamic IP) *

Note that if you use Any in a PSK, all tunnels must use the same PSK

If this does not work, please check that /etc/ipsec.conf has a line “interfaces=%defaultroute” in the “config setup” section

Local to Remote1 if Remote1 has a dynamic IP *

Note that if you use Any in a PSK, all tunnels must use the same PSK

One end Static, one end Dynamic with IKEv1 *

This uses the traditional set up using Any in the PSK which means all tunnels must use the same PSK For the Dynamic end use “Local-to-Remote1 using Default Route” from above For the Static end use “Local to Remote1 if Remote1 has a dynamic IP” from above

Note that the tunnel may not always recover when the dynamic end changes its IP.

One end Static, one end Dynamic with IKEv2 *

This uses the more recent and less widely used IKEv2 and has the advantage that you can still have different PSK's for each tunnel. It is critical the Encryption configuration matches at each end and that the Local ID at one end matches the Remote ID at the other end and vice-versa.

Note that you can use different Ciphers, Hashes and DH Groups but they must match at each end. The cipher is stronger than the Libreswan default (AES-128) but the Cipher and Hash are the same and we don't recommend going any weaker.

This method may also not correctly re-establish a connection after a WAN IP change. If it does not, you can use the relevant method from the previous example.

If you leave the Phase 1 IKE Encryption Cipher/Hash/DH/PFS Group empty and Phase 2 Encryption Cipher/Hash empty, Libreswan will choose a strong set of defaults which allow for good interoperation with other systems.
If you get errors in the logs indicating that packets are being sent outside the tunnel, please check /etc/ipsec.conf for references to an updown script and remove them or comment them out. They are legacy from the Dynamic VPN and do not work with IKEv2. If you have them, you will also probably need to add “interfaces=%defaultroute” to the “config setup” section

IPsec behind NAT *

This can work but is not the ideal scenario and it depends if the tunnel initiator or responder (or both) are behind NAT. In all cases both ends need to open port UDP:4500 to incoming traffic. Note that in a set up with Connection Mode = Automatic at both ends, both ends are initiators and responders at the same time.

If you leave the Phase 1 IKE Encryption Cipher/Hash/DH/PFS Group empty and Phase 2 Encryption Cipher/Hash empty, Libreswan will choose a strong set of defaults which allow for good interoperation with other systems.

Configuration Notes

Most router appliances targeted at the small business market (such as Netgear / D-Link) use IKEv1.

As IPSEC has developed vendors have adopted different naming conventions for describing either side of the tunnel: head office / satellite, left / right. The convention used in the ClearOS app is Local, Remote.

There are a number of 'accepted' default values:

Subnet masks are required to be be noted in their full CIDR notation (e.g. 192.168.1.0/24)

Preshared key – similar to a good password policy, use a combination of numbers and letters, to ensure maximum compatibility avoid using special characters. The preshared key must be the same for all tunnels if Local PSK ID Type or Remote PSK ID Type is Any.

Interface MTU - Ethernet interfaces have a default MTU of 1500, if directly applied, the additional IPSEC header will cause packet fragmentation, which will likely result in data transfer problems. It is recommended that the MTU for WAN interfaces supporting IPSEC VPN tunnels is reduced. There are several popular choices, but 1430 seems the most widely adopted. As of 6.4 setting the MTU for an eth interface is not available from the GUI, so the line MTU=“1430” will need to be added to /etc/sysconfig/network-scripts/ifcfg-ethx (remember to reload using ifdown ethx && ifup ethx for the change to take effect).

It is always preferable to have PFS set to yes, but if connecting to a third party router and you don't know how it is configured, if you set it to NO and the router proposes NO, it will connect but if the router proposes YES it will still connect and YES will be used
Note: It is strongly recommended that if you intend to have any Road Warriors connecting to you by any VPN method (IPsec, OpenVPN, PPTP) that you do not use LAN subnets of 192.168.0.0/24 and 192.168.1.0/24. These are the common defaults of domestic routers and most domestic users do not change them. A Road Warrior behind one of these routers will be able to connect but no traffic will pass through the VPN

Technical

The IPsec VPN app uses Libreswan.

The app configures tunnels by using files within the /etc/ipsec.d/ subfolder. Each tunnel is managed by a separate tunnel.conf (containing the connection parameters) and tunnel.secrets (containing the pre-shared key) file. Global parameters can be applied by editing /etc/ipsec.conf

Troubleshooting

There are several things you can do to determine what is going on with your tunnel

Configuration Parameters

For further detailed information on each of the configuration parameters please refer to the IPsec manual pages. <important>The items denoted with * are not available in the basic version of the app.</important>

Connection Name

Tunnel name, no spaces permitted

Connection Mode

Tunnel connection mode at startup, 'automatic' tunnels will be brought up on boot, 'listen' only implies responder type tunnels only, 'manual start' ignores the tunnel unless manually brought up via the user using the reload button or from the command line

Local WANIP/FQDN

The IP address of the left participant's public-network interface. There are several magic values. If it is %defaultroute, and the config setup section's, interfaces specification contains %defaultroute, left will be filled in automatically with the local address of the default-route interface (as determined at IPsec startup time); this also overrides any value supplied for leftnexthop. (Either left or right may be %defaultroute, but not both.) The value %any signifies an address to be filled in (by automatic keying) during negotiation. If using IP addresses in combination with NAT, always use the actual local machine's (NAT'ed) IP address, and if the remote (eg right=) is NAT'ed as well, the remote's public (not NAT'ed) IP address.

Local Subnet IP

Private subnet behind the left participant, expressed as network/netmask; If omitted, essentially assumed to be left/32, signifying that the left end of the connection goes to the left participant only.

Local Gateway IP

Next-hop gateway IP address for the left participant's connection to the public network. If the value is to be overridden by the left=%defaultroute method (see above), an explicit value must not be given. Relevant only locally, other end need not agree on it. Normally it is not needed as Libreswan will work it out for itself.

Local LAN IP

The IP address for this host to use when transmitting a packet to the other side of this link. Relevant only locally, the other end need not agree. This option is used to make the gateway itself use its internal IP, which is part of the leftsubnet, to communicate to the rightsubnet or right. Otherwise, it will use its nearest IP address, which is its public IP address. This option is mostly used when defining subnet-subnet connections, so that the gateways can talk to each other and the subnet at the other end, without the need to build additional host-subnet, subnet-host and host-host tunnels.

Local ID *

ID used to identify the local, can either be a string beginning with @ or the WAN IP address. This is often used with %any type connections to identify remote hosts

Remote Options

As above but for the remote system. Note that the local/remote terminology is only for reference, Libreswan will determine which connection is which during negotiation and therefore it is possible to use exactly the same configuration at both ends.

Pre shared key

Pre shared key used to authenticate the tunnel connection between two hosts.

Local/Remote PSK ID Type *

What type of ID used to identify your PSK. This is typically your local and remote IP addresses, but can also be friendly ID names. Note that one PSK secrets file is setup for each tunnel, therefore the use of %any should be considered carefully as it will match more than one tunnel. You may also select FQDN which will force Libreswan to determine the IP address via DNS first. Useful for remote connections on dynamic IPs in conjunction with 'right=%any'

IKE Version *

IKEv2 (RFC4309) settings to be used. Currently the accepted values are permit, (the default) signifying no IKEv2 should be transmitted, but will be accepted if the other ends initiates to us with IKEv2; never or no signifying no IKEv2 negotiation should be transmitted or accepted; propose or yes signifying that we permit IKEv2, and also use it as the default to initiate; insist, signifying we only accept and receive IKEv2 - IKEv1 negotiations will be rejected.

Phase1 Cipher/Hash/DH Group *

IKE encryption/authentication algorithm to be used for the connection (phase 1 aka ISAKMP SA). Any left out option will be filled in with all allowed default options. For best compatibility with third party hardware, set these to be consistent with the remote end of the tunnel

Phase2 Cipher/Hash/PFS Group *

Specifies the algorithms that will be offered/accepted for a phase2 negotiation. If not specified, a secure set of defaults will be used.

IKE Connection Lifetime *

How long the keying channel of a connection (buzzphrase: “ISAKMP SA”) should last before being renegotiated; The two-ends-disagree case is similar to that of keylife.

SA LIfetime *

How long a particular instance of a connection (a set of encryption/authentication keys for user packets) should last, from successful negotiation to expiry;(default 8h, maximum 24h). Normally, the connection is renegotiated (via the keying channel) before it expires. The two ends need not exactly agree on salifetime, although if they do not, there will be some clutter of superseded connections on the end which thinks the lifetime is longer.

Dead Peer Detection Action *

When a DPD enabled peer is declared dead, what action should be taken. hold (default) means the eroute will be put into %hold status, while clear means the eroute and SA with both be cleared. restart means the the SA will immediately be renegotiated, and restart_by_peer means that ALL SA's to the dead peer will renegotiated. A hold option is often used for permanent site-to-site tunnels to prevent traffic leaving the gateway unencrypted. When a remote connection is likely to change IP address or you are located on a hub with many incoming tunnels, it may be better to clear the route instead. DPD can be configured at both ends of the tunnels, and does not need to match, however it is usually better to enable DPD on the initiating end of the tunnel.

Compress Data *

Whether IPComp compression of content is proposed on the connection (link-level compression does not work on encrypted data, so to be effective, compression must be done before encryption); acceptable values are yes and no (the default). The two ends need not agree. A value of yes causes IPsec to propose both compressed and uncompressed, and prefer compressed. A value of no prevents IPsec from proposing compression; a proposal to compress will still be accepted.

Perfect forward Secrecy (PFS) *

Whether Perfect Forward Secrecy of keys is desired on the connection's keying channel (with PFS, penetration of the key-exchange protocol does not compromise keys negotiated earlier); Since there is no reason to ever refuse PFS, Libreswan will allow a connection defined with pfs=no to use PFS anyway. Acceptable values are yes (the default) and no.

Rekey *

Whether a connection should be renegotiated when it is about to expire; acceptable values are yes (the default) and no. The two ends need not agree, but while a value of no prevents Pluto from requesting renegotiation, it does not prevent responding to renegotiation requested from the other end, so no will be largely ineffective unless both ends agree on it.

Aggressive Mode *

Use Aggressive Mode instead of Main Mode. Aggressive Mode is less secure, and vulnerable to Denial Of Service attacks. It is also vulnerable to brute force attacks with software such as ikecrack. It should not be used, and it should especially not be used with XAUTH and group secrets (PSK). If the remote system administrator insists on staying irresponsible, enable this option. Aggressive Mode is further limited to only proposals with one DH group as there is no room to negotiate the DH group. Therefore it is mandatory for Aggressive Mode connections that both IKE and PHASE2 options are specified with only fully specified proposal using one DH group. Acceptable values are yes or no (the default).

search?q=clearos%2C%20clearos%20content%2C%20Static%20IPSec%20VPN%2C%20app-static-vpn%2C%20clearos7%2C%20userguide%2C%20categorynetwork%2C%20subcategoryvpn%2C%20libreswan%2C%20ipsec%2C%20maintainer_dloper%2C%20maintainer_nhowitt&amp;btnI=lucky