-
Notifications
You must be signed in to change notification settings - Fork 118
/
How to Install Wireguard VPN Server on Ubuntu Server 22.04.2.txt
79 lines (58 loc) · 1.9 KB
/
How to Install Wireguard VPN Server on Ubuntu Server 22.04.2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
[How to Install Wireguard VPN Server on Ubuntu Server 22.04.2]
Server configuration
(1) -- Installing WireGuard --
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install wireguard
(2) -- IP forwarding --
sudo nano /etc/sysctl.conf (Delete # symbol on line "net.ipv4.ip_forward=1")
sudo sysctl -p
(3) -- Configuring firewall rules --
sudo apt install ufw
sudo ufw allow ssh
sudo ufw allow 51820/udp
sudo ufw enable
sudo ufw status
(4) -- Generating private and public keys --
cd /etc/wireguard
ls
umask 077
wg genkey | tee privatekey | wg pubkey > publickey
sudo cat /etc/wireguard/publickey
sudo cat /etc/wireguard/privatekey
* Copy publickey and privatekry into Notepad *
(5) -- Generating server config --
sudo nano /etc/wireguard/wg0
######################################################
[Interface]
PrivateKey = <contents-of-server-privatekey>
Address = 10.0.0.1/24
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o ens33 -j MASQUERADE
ListenPort = 51820
[Peer]
PublicKey = <contents-of-client-publickey>
AllowedIPs = 10.0.0.2/32
######################################################
(6) -- Start Wireguard --
wg-quick up wg0
(7) -- Check Wireguard Config --
wg show
(8) -- Enable Automatic Start --
systemctl enable wg-quick@wg0
(9) -- Update Server --
sudo apt-get update && sudo apt-get upgrade -y
Client configuration
For Windows
(1) Download Wireguard Client: https://www.wireguard.com/install/
(2) Click "Add empty tunnel..."
######################################################
[Interface]
Address = 10.0.0.2/32
PrivateKey = <contents-of-client-privatekey>
DNS = 1.1.1.1
[Peer]
PublicKey = <contents-of-server-publickey>
Endpoint = <server-public-ip>:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 10
######################################################