Wireguard is recently making a splash as human-configurable low-overhead alternative to OpenVPN and IPSec. As some privacy-centric VPN providers are planning to support it (e.g., PIA) or already have a beta running (e.g., IVPN, as tested by Ars Technica) it was time for me to look into it.
The Setup
To get a better feeling about the used technology I directly connected my laptop to my desktop (gigabit Ethernet with no switch/router in between) and setup OpenVPN with a minimalist configuration as well as with a more realistic TLS-configuration. I took some bandwidth/latency measurements with iperf and qperf and compared those to a minimal Wireguard setup.
To summarize the used hardware/software:
Component | Notebook | Desktop |
---|---|---|
CPU | Intel i7-8550U @1.8GHz | Intel i5-4690K @3.5GHz |
Network Card | Intel PRO/1000 e1001 3.2.6-k | Qualcom alx AR815x/AR127x |
Distribution | Ubuntu 18.10 | Fedora 29 |
Linux Kernel | 4.18.0-12-generic | 4.19.7-300.fc29.x86_64 |
OpenVPN | 2.4.6 with OpenSSL 1.1.1 | 2.4.6 with OpenSSL 1.1.1 FIPS |
Wireguard | 20181119-wg1 | 0.0.20181119-1 |
IP-Address (direct) | 192.168.66.2 | 192.168.66.1 |
The performance baseline:
|
|
Minimal OpenVPN Configuration (shared secret)
This is a setup based upon [the OpenVPN documentation](roughly based upon https://openvpn.net/community-resources/static-key-mini-howto/): the two computers are connected with a minimal VPN configuration and a shared secret key is used (this key has to be copied between those two computers beforehand). This uses a 2048 bit key, no TLS and BF-CBC as cipher (blowfish). The shared secret (stored in the file static.key
) was created with the command $ OpenVPN --genkey --secret static.key
and afterwards copied with scp.
The server configuration was thus:
|
|
and the client configuration was:
|
|
The different clients then were started using the openvpn
command line tool:
|
|
And with that we were able to measure the bandwidth and the performance. Please notice that it took around seven seconds to get the tunnel established.
OpenVPN with TLS and AES-GCM
The next step was to create a realistic public-/private-key based OpenVPN setup. Compared to the minimalist setup there were the following differences:
- OpenVPN uses a data and a control channel. The control channel can be configured using the
tls-cipher
directive and achacha20-poly1305
cipher was used for better comparison with Wireguard (which uses the same cipher). For the data channel neither Fedora nor Ubuntu providedchacha20-poly1305
soAES-256-GCM
was configured using thecipher
configuration option. AES-GCM should perform very fast as OpenSSL would be using the Intel hardware support for this cipher/block-mode. - a 4096 bit DH parameter was created using
openssl dhparam -out dh4096.pem 4096
easy-rsa (public/private key setup)
Sadly for the public-/private-key setup we need some sort of CA (certificate issuer). I’ve taken the easy way out and used easy-rsa.
To not blow up the volume of this article, I’ll just post my used commands (on the Ubuntu machine):
|
|
Then the relevant files were copied to client and server. For the server-side we need ca.crt
, dh4096.pem
, server.key
, server.crt
. For the client we need ca.crt
, client.key
and client.crt
.
Configuration
The generated keys/certificates were thus configured on the server side:
|
|
On the client side I used the following configuration:
|
|
With this we were able to connect client and server and take some measurements:
|
|
Wireguard
Wireguard is configured using both the linux ip
as well as the Wireguard wg
binary. To create the setup two private-/public-keypairs as well as a shared preshared key were created. The public key is a short BASE64-encoded value (e..g, 1ykxqzUAXcNK0VnzUf/4kf9Frt/CU5bc2h1m6uPf6yc=
while the pre-shared key is contained in a normal text file).
Wireguard itself used Chacha20-Poly1305
. This is a software algorithm with almost no hardware acceleration support. While the lack of hardware support hurts on x86_64 platforms the algorithm’s good software performance is one of the reasons that Alphabet is using this on ARM-Platforms (i.e., Android) which until recently were lacking (AES-)GCM hardware support.
Key generation
I created a private/public-keypair on both clients (just outputting this for one side, execute this on both clients):
|
|
Also I’ve created the preshared key (and copied that from one client to the other client):
|
|
Configuration
As mentioned before, wireguard
can be configured using just the command line, this was done on client 1:
|
|
Now we an output the resulting configuration, please note the public key as well as the listening port:
|
|
We do the same on client 2:
|
|
Now we need to tell client 1 the network endpoint and public key of client 2 (and vice versa). For client one this means:
|
|
And for client 2:
|
|
What let to some problems for me was that the public key is supplied directly as BASE64-encoded value while the pre-shared key is provided through a file. More RTFM for me.
I cannot really tell how fast the VPN tunnel was established as it was almost instant, maybe faster than half a second.
And with that I was able to gain some performance numbers.
Results
And now, for the performance numbers:
Setup | startup-time | iperf (Bandwidth) | qperf tcp_bw (Bandwidth) | qperf tcp_lat (Latency) |
---|---|---|---|---|
direct, no VPN | well, none | 840 Mb/sec | 102us | |
OpenVPN minimal, shared secret, no TLS | 7s | 428 Mbits/sec | 337 Mb/sec | 144us |
OpenVPN TLS, AES-256GCM | 5s | 882 MBits/sec | 842 MB/sec | 105us |
Wireguard | < 1sec | 898 MBit/sec | 893 MB/sec | 317us |
I was highly surprised by the bad performance achieved by the minimal OpenVPN configuration. Another surprise was that Wireguard was able to beat OpenSSL’s performance even with it’s software-based crypto construction (sadly I was not able to capture CPU utilization so maybe the performance was achieved by spending more CPU cycles. But I wouldn’t really care about that TBH). One thing that saddened me was Wireguards worse latency when compared to OpenVPN with hardware AES-GCM support but this was offset by the way-easier public/private-key configuration as well as the almost instant tunnel establishment time (this would be come handy when using mobile/roaming clients).
As soon as Private Internet Access offers wireguard support I will test its performance (against OpenVPN) over a wireless (802.11b) as well as through a mobile (LTE) network.