A web interface written in Go lets you manage WireGuard graphically, including creating and deleting users. In this tutorial, we explain how to configure it on Ubuntu 20.04.
Installing WireGuard first
To use WireGuard-UI, you need to have WireGuard installed. Run the following commands:
# apt install wireguard
# modprobe wireguardInstalling using the compiled binary
First, go to the GitHub Releases section to download the latest version. At the time of writing this tutorial, the latest version is v0.3.7.
# wget https://github.com/ngoduykhanh/wireguard-ui/releases/download/v0.3.7/wireguard-ui-v0.3.7-linux-amd64.tar.gzExtract the archive:
# tar zxf wireguard-ui-v0.3.7-linux-amd64.tar.gzNow run the downloaded binary:
# ./wireguard-uiThe following output will appear:
Wireguard UI
App Version : v0.2.7
Git Commit : b8142b80c235753e501376e21d3694cd066d977c
Git Ref : refs/tags/v0.3.7
Build Time : 02-03-2021 10:46:34
Git Repo : https://github.com/ngoduykhanh/wireguard-ui
Authentication : true
Bind address : 0.0.0.0:5000
⇨ http server started on [::]:5000You can now access the panel using the server's public IP address and port 5000:
Important
To access port 5000, you must have this port open in your Firewall profile.
The WireGuard-UI login credentials are:
- Username: admin
- Password: admin
We strongly recommend changing the login password. You can do this by editing the db/server/users.json file
Important!
Remember to terminate the WireGuard-UI process once you have configured the clients.
Installing from source code
To compile WireGuard-UI manually, you need to install the following packages:
- First, you need Yarn:
# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# apt update
# apt install yarn- Second, you need to have Go installed
# apt-get install golang-rice golang-go gcc g++ make- Third, you also need NodeJS
# curl -sL https://deb.nodesource.com/setup_15.x | bash -
# apt-get install -y nodejsDownload the GitHub repository:
# git clone https://github.com/ngoduykhanh/wireguard-ui.gitRun the script to prepare the assets:
# ./prepare_assets.shCompile the source code:
# rice embed-go
# go build -o wireguard-uiOnce the process is complete, the binary will be ready to run.
# ./wireguard-uiImportant!
Remember to terminate the WireGuard-UI process once you have configured the clients.
Configuring WireGuard from WireGuard-UI
Go to the WireGuard Server section and configure the following:
You need to add the server's private web interface 10.0.8.1/24, open UDP port 51820 in the server's Firewall profile, and then add the Post Up Script and the Post Down Script:
- PostUp Script: iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
- PostDown Script: iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
Click Save and then, at the top right, Apply Config and restart the WireGuard service.
Creating a WireGuard client
Go to WireGuard Client and then click New Client:
Under Allowed IPs, add the two routes 10.0.8.0/24 and 10.20.10.0/24. Once you have submitted the changes, click Apply Config. After creating the user, you can scan the QR code to configure the device or download the configuration file to import it into the WireGuard client.