Date: February 3, 2023 /  Author: Ralf Eichinger

Wireguard VPN-Client (Linux)

This post describes how to install a wireguard VPN-client under Linux.

Specification

Installation

Ubuntu 22.10

$ sudo apt install wireguard
...
$ wg --version
wireguard-tools v1.0.20210914 - https://git.zx2c4.com/wireguard-tools/

Configuration

Create Public/Private-Key pair:

$ wg genkey | tee /dev/tty | wg pubkey
fjhdskjfhdsafdsfkjhsadkfhkkfhds
zrewirziwzruewruiwzreiwzriuewzr

(The above output is just dummy placeholders.) The first line is the private key. The second line is the public key.

Do not save output anywhere!

  • Send public key to Wireguard-Server-Admins. Wait for answer (telling you your IP-address)
  • Add private key and your VPN ip address into configuration file etc/wireguard/wg0.conf:
[Interface]
PrivateKey = ** your private key from above output **
Address = ** your vpn ip address **
MTU = 1364

[Peer]
PublicKey = ** public key of wireguard gateway server - NOT above public key!!! **
AllowedIPs = ** comma separated list of IPs to be routed over VPN **
Endpoint = ** VPN gateway server address (and port) **
PersistentKeepalive = 25

Secure config file (only root readable/writable):

$ sudo chmod -R 700 /etc/wireguard

Usage

Manually start/stop

  • Start: sudo wg-quick up wg0
  • Stop: sudo wg-quick down wg0

Automatically

$ sudo systemctl enable wg-quick@wg0
  • Start: sudo systemctl start wg-quick@wg0
  • Stop: sudo systemctl stop wg-quick@wg0
 Tags:  topics linux

Previous
⏪ KeePassXC password manager

Next
Docker Desktop & Docker Compose ⏩