OpenVPN

OpenVPN (Open Virtual Private Network) is software that enables the creation of secure point-to-point or site-to-site connections.

Emerge
Install the OpenVPN package:

Server side
If this is the first time setting up an openvpn server, we will need to create a PKI (Public Key Infrastructure) from scratch.

Write a server-side openvpn configuration.

Start openvpn server, run

Client side
Copy the necessary key files to client, via a secure way (such as SSH), including


 * ca.crt
 * client1.csr (in this example)
 * client1.crt (in this example)
 * client1.key (in this example)
 * ta.key (if using tls-auth)

Write a client-side openvpn configuration file:

To start client, run

systemd
If all goes well, this would give you a working OpenVPN server and client connection.

Gentoo specifics
The init script allows multiple tunnels. Decide on a name for the tunnel - eg EXAMPLE

Using OpenRC
Now create your config as /etc/openvpn/EXAMPLE.conf

Using systemd
Due to dependencies server and client operations are separated into two units.

Create your server config as /etc/openvpn/server/EXAMPLE.conf

Create your client config as /etc/openvpn/client/EXAMPLE.conf

You can then create more tunnels by replacing EXAMPLE with more names. Each one has its own configuration and can be stopped and started individually. The default is simply to use openvpn.conf and not symlink the service. You can of course use both methods.

External resources

 * https://wiki.archlinux.org/index.php/OpenVPN
 * easy vpn