Blog Post 3: Configuring the Ubuntu Server as a WireGuard Client

Introduction to WireGuard

WireGuard, a modern and efficient VPN protocol, offers several benefits, including speed, security, and simplicity. In our previous posts, we introduced WireGuard and set up the MikroTik router as a WireGuard server. Now, it’s time to configure the client side of our VPN connection. In this post, we will guide you through the process of configuring an Ubuntu Server 22.04 as a WireGuard client.

The Purpose and Benefits of WireGuard

Before we dive into the client configuration, let’s understand the purpose and benefits of WireGuard. WireGuard offers:

  • Speed: WireGuard is exceptionally fast due to its streamlined design.
  • Security: It employs the latest cryptographic techniques for robust encryption.
  • Simplicity: Configuration and maintenance are straightforward, even for beginners.
  • Flexibility: WireGuard can be deployed on a wide range of platforms.

Server Setup

Before we delve into configuring WireGuard on the Ubuntu Server, let’s ensure that you have your server set up and ready for action.

  1. Ubuntu Server 22.04 Instance:
    • Ensure that you have provisioned an Ubuntu Server 22.04 instance. This could be on physical hardware or a virtual machine.
    • Make sure the server has a reliable internet connection, as it will need to communicate with the MikroTik WireGuard server.
  2. SSH Access:
    • Ensure that you can SSH into your Ubuntu Server. This will be your primary means of accessing and configuring the server.

Installing WireGuard on Ubuntu

To configure the Ubuntu Server as a WireGuard client, you’ll first need to install the WireGuard package. Here’s how to do it:

  1. Installing WireGuard Package:
    • Connect to your Ubuntu Server via SSH.Run the following command to install the WireGuard package:

    sudo apt update sudo apt install wireguard

    This command will update your package lists and then install the WireGuard package.
  2. Load the WireGuard Module:
    • After installing WireGuard, ensure that the WireGuard kernel module is loaded. Run:

    sudo modprobe wireguard

    This command ensures that the WireGuard module is active and ready for use.

Generating WireGuard Keys on Ubuntu

Now that WireGuard is installed on your Ubuntu Server, it’s time to generate the necessary keys for the WireGuard client configuration.

  1. Generating WireGuard Keys:
    • Run the following commands to generate WireGuard private and public keys on your Ubuntu Server:
    umask 077

    # This ensures that the private key file is created with secure permissions

    wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey

    This set of commands will create a private key and save it in /etc/wireguard/privatekey, as well as generate a corresponding public key and save it in /etc/wireguard/publickey.
  2. Securely Store the Keys:
    • Just as with the server, it’s crucial to securely store these keys on your Ubuntu Server.

Now that you have installed WireGuard on your Ubuntu Server and generated the required keys, you are well-prepared to configure the WireGuard client. In the next part of this series, we will guide you through the process of configuring the client and establishing a secure connection with the MikroTik WireGuard server. Stay tuned for more tomorrow!