WireGuard

Office Site

https://www.wireguard.com/

Server

Ubuntu

Install

1
2
3
4
apt install software-properties-common
add-apt-repository ppa:wireguard/wireguard
apt-get update
apt-get install wireguard-dkms wireguard-tools

Configure Server

1
vim /etc/wireguard/wg0.conf
1
2
3
4
5
6
7
8
9
10
11
12
[Interface]
PrivateKey = $s1
Address = 10.0.0.1/24
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = $port
DNS = 8.8.8.8
MTU = 1420

[Peer]
PublicKey = $c2
AllowedIPs = 10.0.0.2/32

Configure Client

1
vim /etc/wireguard/client.conf
1
2
3
4
5
6
7
8
9
10
11
[Interface]
PrivateKey = $c1
Address = 10.0.0.2/24
DNS = 8.8.8.8
MTU = 1420

[Peer]
PublicKey = $s2
Endpoint = $serverip:$port
AllowedIPs = 0.0.0.0/0, ::0/0
PersistentKeepalive = 25

Start

1
2
3
sudo wg-quick up wg0
# status
sudo wg

Client

MacOS

1
2
3
4
5
6
7
brew install wireguard-tools jq

# Turn on
wg-quick up config.conf

# Turn Off
wg-quick down config.conf

Refer

https://10to7.xyz/setup-wireguard-on-ubuntu-18-04-and-android-oero/