On this page
How it differs from WireGuard
Inside it is the same WireGuard: fast and simple. The difference is on the outside: the packets are changed, so AmneziaWG gets through where plain WireGuard is already recognized.
Where filtering is serious, it gets found over time. Then a protocol that looks like an ordinary website to your ISP is the better pick: VLESS Reality or Veli.
How to install it by hand
Below is the setup on Ubuntu as root from the Amnezia project's official PPA. The amneziawg package builds the kernel module and installs the awg and awg-quick tools.
- 1
Take a server with spare memory
AmneziaWG builds a module for the server's kernel. With 1 GB of memory and no swap that takes 5–10 minutes, and with less it may not build.
- 2
Turn on package sources
The build needs source packages from APT.
/etc/apt/sources.listmust have adeb-srcline with no # in front. On Ubuntu 24.04 the settings are in/etc/apt/sources.list.d/ubuntu.sources: change the lineTypes: debtoTypes: deb deb-src. - 3
Install what the build needs
Command:
On the serverapt update && apt install -y software-properties-common python3-launchpadlib gnupg2 linux-headers-$(uname -r) - 4
Install AmneziaWG
Commands:
On the serveradd-apt-repository ppa:amnezia/ppaThen
apt install -y amneziawg. On Debian the same PPA is added by hand: the commands are in the README of the amneziawg-linux-kernel-module project on GitHub. - 5
Create the keys
Commands:
On the servermkdir -p /etc/amnezia/amneziawg && cd /etc/amnezia/amneziawgThen
umask 077, thenOn the serverawg genkey | tee server.key | awg pubkey > server.pubDo the same for each device:
On the serverawg genkey | tee phone.key | awg pubkey > phone.pub - 6
Write awg0.conf
File:
/etc/amnezia/amneziawg/awg0.conf. A sample is in the next section. - 7
Turn on forwarding
Commands:
On the serverecho net.ipv4.ip_forward=1 > /etc/sysctl.d/99-awg.confThen
sysctl --system. Without it a device connects but doesn't reach the internet. - 8
Open the port
If ufw is on:
ufw allow 51820/udp. With ufw, forwarding is needed too: in/etc/default/ufwsetDEFAULT_FORWARD_POLICY="ACCEPT"and runufw reload. If the host has a firewall in its dashboard, open the UDP port there too. - 9
Start it
Command:
awg-quick up awg0. Check:awg showlists the interface and connected devices. To start it after a reboot:On the serversystemctl enable awg-quick@awg0 - 10
Make a file for each device
An AmneziaWG profile is a .conf file. Each device gets its own: one key on two devices at the same time does not work. A sample is below.
The server file awg0.conf
Replace SERVER_PRIVATE_KEY with the contents of server.key and PHONE_PUBLIC_KEY with the contents of phone.pub. eth0 is the server's outside interface: ip route shows its name after the word dev in the default line. If there is no iptables: apt install -y iptables.
Pick your own H1–H4: four different numbers from 5 to 2147483647. Port 51820 can be any free UDP port.
[Interface]
PrivateKey = SERVER_PRIVATE_KEY
Address = 10.8.0.1/24
ListenPort = 51820
Jc = 4
Jmin = 8
Jmax = 80
S1 = 40
S2 = 70
H1 = 1376029114
H2 = 2052410238
H3 = 908143527
H4 = 1610284493
PostUp = iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
[Peer]
PublicKey = PHONE_PUBLIC_KEY
AllowedIPs = 10.8.0.2/32The device file
PHONE_PRIVATE_KEY is the contents of phone.key, SERVER_PUBLIC_KEY is the contents of server.pub, IP is the server address. Copy the Jc–H4 lines from the server as they are.
The next device is one more [Peer] on the server with its own key and the address 10.8.0.3/32, then 10.8.0.4/32 and on. After editing: awg-quick down awg0, then awg-quick up awg0.
[Interface]
PrivateKey = PHONE_PRIVATE_KEY
Address = 10.8.0.2/32
DNS = 1.1.1.1
Jc = 4
Jmin = 8
Jmax = 80
S1 = 40
S2 = 70
H1 = 1376029114
H2 = 2052410238
H3 = 908143527
H4 = 1610284493
[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = IP:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25What the masking settings mean
Jc— how many junk packets go out before the handshake: from 1 to 128, usually 4–12.JminandJmax— the smallest and largest junk packet size in bytes. Usually 8 and 80;Jmaxis at most 1280.S1andS2— how many random bytes are added to the handshake packets:S1to the first one,S2to the reply. Usually 15–150, andS1+ 56 must not equalS2.H1–H4— your own markers in place of the headers of the four WireGuard packet types. Four different numbers from 5 to 2147483647.S1,S2andH1–H4must match on the server and the device.Jc,JminandJmaxmay differ.
If the install does not go through
- Not enough memory — take a bigger plan or a protocol with no build, such as Veli or VLESS Reality.
- An error about the package mirror — that is the host's server. Try again later or pick another mirror in the hosting panel.
- Short of disk space — free some on the server and try again.