openvpn.is
English
简体中文繁體中文EnglishРусскийفارسی

HomeGuidesBuild your own gate

Build your own gate

Build an OpenVPN 2.7 server from scratch: CA and certificates with easy-rsa, server.conf, opening the port, forwarding, and the first .ovpn file.

Building a server of your own
Building a server of your own Raysonho @ Open Grid Scheduler / Grid Engine, Public domain

What you need

  • A Linux server with a public IP.
  • Half an hour.
  • A decision about the gate: UDP 1194 is fast, TCP 443 gets through.

1. Appoint the issuer

Best on your own computer, not on the server
sudo apt install easy-rsa
make-cadir ~/ca && cd ~/ca
./easyrsa init-pki
./easyrsa build-ca

You will be asked for a password. That password and pki/private/ca.key are the seal of the whole city.

2. Stamp the first papers

One for the server, one for the laptop
./easyrsa build-server-full server nopass
./easyrsa build-client-full laptop nopass
./easyrsa gen-crl
openvpn --genkey tls-crypt tc.key

3. Configure the server

/etc/openvpn/server/server.conf
port 1194
proto udp
dev tun
topology subnet
server 10.9.0.0 255.255.255.0
ca ca.crt
cert server.crt
key server.key
dh none
tls-crypt tc.key
crl-verify crl.pem
remote-cert-tls client
data-ciphers AES-256-GCM:CHACHA20-POLY1305:AES-128-GCM
keepalive 10 60
persist-tun
user nobody
group nogroup

Put ca.crt, server.crt, server.key, crl.pem and tc.key in the same folder.

4. Open the gate

Allow and start
sudo ufw allow 1194/udp
sudo systemctl enable --now openvpn-server@server
sudo systemctl status openvpn-server@server

On a cloud server also allow UDP 1194 in the security group.

5. Make an .ovpn

Get the skeleton from the profile maker, then paste in four pieces: ca.crt, laptop.crt, laptop.key, tc.key. Import it into the client. When the log says Initialization Sequence Completed, you are through.

Is something missing with dh none?

No. Keys are now exchanged on elliptic curves and the dh file is no longer needed.

How long do certificates last?

easy-rsa defaults to 825 days for clients and servers and ten years for the CA. Put it in your calendar.

Walk onImport a profile

Nearby gates

Signposts: OpenVPN server setup, OpenVPN server.conf, easy-rsa tutorial