Installing WireGuard on Ubuntu

5 Minutes read
background effect
Top promotion

Introduction, WireGuard is a relatively new VPN protocol but has become popular thanks to its speed, security, and ease of use. It uses modern encryption techniques and is suitable for both servers and mobile devices. In this guide, we will learn how to install and set up WireGuard on Ubuntu 20.04.

Steps

1. Update the system Before installing any new software, make sure the system is up to date to ensure you have the latest packages.

sudo apt update
sudo apt upgrade

2. Install WireGuard, Ubuntu 20.04 already has WireGuard packages in the official repositories, so you can easily install it using apt:

sudo apt install wireguard

3. Generating public and private keys, WireGuard relies on public and private encryption keys.

First, we need to generate these keys. Navigate to the /etc/wireguard to store the keys:

sudo mkdir /etc/wireguard
cd /etc/wireguard
sudo umask 077
sudo wg genkey | sudo tee privatekey | sudo wg pubkey | sudo tee publickey
  • privatekey: Your private key.
  • publickey: Your public key.

4. Setting up WireGuard After generating the keys, we need to set up a configuration file. Create a new file:

sudo nano /etc/wireguard/wg0.conf

Then add the following configuration:

[Interface]
PrivateKey = put_your_private_key_here
Address = 10.0.0.1/24
ListenPort = 51820

[Peer]
PublicKey = Put_Your_Client_Public_Key_Here
AllowedIPs = 10.0.0.2/32

5. Activate and run WireGuard, after completing the configuration, you can activate and run WireGuard:

sudo wg-quick up wg0

To stop the service:

sudo wg-quick down wg0

To make sure the service runs automatically at startup:

sudo systemctl enable wg-quick@wg0

6. Verifying the connection, To verify that the connection has been set up successfully, you can use the following command to see the status of the connection and switches:

sudo wg

In conclusion, after following these steps, you will have installed and configured WireGuard on Ubuntu 20.04. WireGuard is a powerful VPN protocol that is simple and fast, making it an excellent choice for protecting your data and securing your connections.



Labixe host logo
LABIXE LTD - Company Num. 13706095