To connect to a Wideguard VPN from your local machine to a remote server using the AmneziaWG configuration file you previously received from the configured server, follow these steps. This guide assumes you are using Ubuntu 22.04. You’ll need to install the WireGuard software, configure it, and initiate the VPN connection. Here’s how to do it:

1. Change sources.list on the client’s operation system:

Open a terminal and back up your sources.list:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

Edit the File:

nano /etc/apt/sources.list

Uncomment deb-src Lines: Remove the # from the beginning of any deb-src lines you want to activate.

#Example sources.list file for Ubuntu 22.04
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu jammy main restricted
deb-src http://archive.ubuntu.com/ubuntu jammy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu jammy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu jammy universe
deb-src http://archive.ubuntu.com/ubuntu jammy universe
deb http://archive.ubuntu.com/ubuntu jammy-updates universe
deb-src http://archive.ubuntu.com/ubuntu jammy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu jammy multiverse
deb-src http://archive.ubuntu.com/ubuntu jammy multiverse
deb http://archive.ubuntu.com/ubuntu jammy-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu jammy-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu jammy-security main restricted
deb-src http://security.ubuntu.com/ubuntu jammy-security main restricted
deb http://security.ubuntu.com/ubuntu jammy-security universe
deb-src http://security.ubuntu.com/ubuntu jammy-security universe
deb http://security.ubuntu.com/ubuntu jammy-security multiverse
deb-src http://security.ubuntu.com/ubuntu jammy-security multiverse

Save and Exit.

2. Upgrade the System

apt update && apt upgrade && apt-get full-upgrade && apt install resolvconf

3. Install AmneziaWG on Ubuntu 22.04

apt install -y software-properties-common python3-launchpadlib gnupg2 linux-headers-$(uname -r)

add-apt-repository ppa:amnezia/ppa

apt-get install -y amneziawg

Check the availability of all necessary drivers in the system:

lsmod | grep amnezia

If the command doesn’t show any outputs execute this command:

modprobe amneziawg && lsmod | grep amnezia

4. Copy AmneziaWG client config to Linux (Ubuntu)

Include the command:

scp [username]@[server-ip-address]:/root/awg/wg-client1.conf /etc/amnezia/amneziawg/

Where:

  • username - the username of the server

  • server-ip-address - the IP address of the server

  • /root/awg/ - directory where located an amneziawg client config files

  • wg-client1.conf - amneziawg config file

  • /etc/amnezia/amneziawg/ - the local directory on your Linux machine

5. Get Your Amnezia WireGuard Configuration

The Amnezia wireguard configuration file must be downloaded from VPS. The .conf file, is usually in the following format:

[Interface]
PrivateKey = kHcPwRvI3FRc4qcE+Fgrln1K1qxQNM3jl4CpPzaYx4o=
#_PublicKey = 7vzU3tVk39Dj+XvjpX3e9yZzDZhfbTZUde2Elju3nRM=
Address = 10.10.8.2/32
DNS = 8.8.8.8
Jc = 120
Jmin = 60
Jmax = 1266
S1 = 11
S2 = 54
H1 = 563549684
H2 = 1544213701
H3 = 529241130
H4 = 981267317

[Peer]
AllowedIPs = 0.0.0.0/5, 8.0.0.0/7, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/6, 172.0.0.0/12, 172.32.0.0/11, 172.64.0.0/10, 172.128.0.0/9, 173.0.0.0/8, 174.0.0.0/7, 176.0.0.0/4, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4, 8.8.8.8/32
Endpoint = VPS_REMOTE_IP:54666
PersistentKeepalive = 60
PublicKey = 7gExcFjYZ6rR5nU7F3xzrDQchtGu4OCxEwGjSlRGwnE=

Save this file with a .conf extension, e.g., wg0.conf.

6. Move Configuration to AmneziaWG Directory

Move your configuration file to AmneziaWG’s directory, where wg-client1.conf this is a client config that was previously downloaded from the server:

sudo mv /etc/amnezia/amneziawg/wg-client1.conf /etc/amnezia/amneziawg/wg0.conf

Ensure the file permissions are restricted to prevent unauthorized access:

sudo chmod 600 /etc/amnezia/amneziawg/wg0.conf

7. Start the WireGuard VPN Connection

To start the VPN connection using the configuration file, run the following command:

sudo awg-quick up wg0

If everything is configured properly, you’ll be connected to the WireGuard VPN.

8. Verify the Connection

To check if the connection is active, use:

awg show
ip 

This command shows details about the active WireGuard connection, such as the interface name, peer details, and data transfer statistics.

9. Disconnect from the VPN

To stop the VPN connection, use:

sudo awg-quick down wg0

10. Optionally Enable WireGuard on Boot

If you want the VPN to start automatically on boot, you can enable it with:

sudo systemctl enable awg-quick@wg0

To disable it from starting on boot, use:

sudo systemctl disable awg-quick@wg0

Troubleshooting Tips:

  • Ensure that your private key, public key, and endpoint details in the configuration are correct.

  • If you face any connection issues, check the system logs for more detailed error messages:

sudo journalctl -xe

Following these steps, you should be able to connect to AmneziaWG on Ubuntu.

Links: