Setup Wireguard on Ubuntu (Guide)

This guide will show you how to install WireGuard on Ubuntu.

This guide assumes the following items (and therefore will not be covered in this guide):

  • Ubuntu 18.04 LTS is installed on a physical Machine, Virtual Machine, or VPS
  • UDP Port that you intend to use for WireGuard has been forwarded through any Firewalls or Routers
  • Public IP or Domain pointing at the Ubuntu Server that will run WireGuard (yellow below)
  • Name of Network Adapter that is externally reachable (red below)

All commands throughout the guide are to be entered into the Ubuntu Servere Terminal either via direct access or an SSH client such as PuTTY.

To determine your IP and Network Adapter:

In the Terminal enter: ifconfig

Domain name should be forwarded to the external IP address (e.g. 111.222.333.444 in the screenshot below)

Determine which network is externally reachable (e.g. ens3 in the screenshot below)

ifconfig screenshot


I have developed a Bash script to completely perform all the install steps which the below will download and run. Alternatively you can view the script on the projects github page: WG-AutoSetup.

The script will prompt you for your Domain Name/IP, Port, and Network Adapter name. It will then proceed to install WireGuard, configure it, and create 1 client ready to be scanned onto your Mobile Device.

To begin, once logged into Ubuntu as root, enter the following into the Terminal:

  1. wget
  2. chmod +x
  3. ./
  4. Follow the prompts, once complete the Terminal will display a QR code to be Scanned via the WireGuard Mobile App (Android or iOS)

  5. Scan QR Code on Mobile App
  6. Restart Ubuntu (mandatory!)
  7. Once Ubuntu has restarted your WireGuard VPN should be active and you can now connect.