WireGuard is an open-source VPN solution which is simple, fast, and secure. In this tutorial, we will walk you through how to install WireGuard on the latest version of Ubuntu Server.
Before we start the installation, we need to ensure that the following prerequisites are met:
The first step is to add the WireGuard PPA repository to your Ubuntu Server. We will use this repository to install the WireGuard software.
sudo apt update
software-properties-common
package, which is required to add new repositories using the following command:sudo apt install software-properties-common -y
sudo add-apt-repository ppa:wireguard/wireguard
sudo apt update
Now that we have added the WireGuard PPA repository, we can go ahead and install it.
sudo apt install wireguard -y
sudo wg
If the output of the above command is something like command not found: wg
, it means that there is an issue with the installation. You will need to troubleshoot the installation and try again.
Now that WireGuard is installed, it's time to configure it to connect to your VPN network.
sudo mkdir /etc/wireguard
sudo wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
This command will generate a private key and a public key, and save them to the /etc/wireguard/privatekey
and /etc/wireguard/publickey
files respectively.
sudo nano /etc/wireguard/wg0.conf
[Interface]
Address = 10.0.0.1/24
PrivateKey = <private key>
ListenPort = 51820
[Peer]
PublicKey = <peer public key>
AllowedIPs = 10.0.0.2/32
Replace the <private key>
and <peer public key>
placeholders with the actual keys generated in the previous step.
Save and exit the file.
Now start the WireGuard service using the following command:
sudo systemctl start wg-quick@wg0
To test if WireGuard is working correctly, you can ping the remote server.
On the client machine, install WireGuard using the same procedure as above.
Create a configuration file for the WireGuard interface on the client machine using the following command:
sudo nano /etc/wireguard/wg0.conf
[Interface]
Address = 10.0.0.2/24
PrivateKey = <private key of client>
[Peer]
PublicKey = <public key of server>
AllowedIPs = 10.0.0.1/32
Endpoint = <server public ip>:51820
Replace the <private key of client>
, <public key of server>
, and <server public ip>
placeholders with the actual keys and IP address of the server.
Save and exit the file.
Start the WireGuard service on the client machine using the following command:
sudo systemctl start wg-quick@wg0
ping 10.0.0.1
If the ping is successful, it means that WireGuard is working correctly.
In this tutorial, we have shown you how to install and configure WireGuard on the latest version of Ubuntu Server. With WireGuard, you can now enjoy a fast, secure, and easy-to-use VPN solution on your Ubuntu Server.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!