DataLife Engine / How to install and configure WireGuard on Ubuntu

How to install and configure WireGuard on Ubuntu

How to install and configure WireGuard on Ubuntu

1. Install package
apt update
apt install wireguard -y

2. Generate keys
wg genkey | tee /etc/wireguard/private.key
chmod go= /etc/wireguard/private.key
cat /etc/wireguard/private.key | wg pubkey | tee /etc/wireguard/public.key

3. Create config
cat <<EOF | tee /etc/wireguard/wg0.conf
[Interface]
PrivateKey = <private_key>
Address = 10.10.101.1/24
ListenPort = 443

[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.10.0.0/16, 192.168.100.0/24
#Endpoint = 203.0.113.1:51820
EOF

4. Enable packet forwarding between interfaces
echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/60-netipv4_sysctl.conf
sysctl -w net.ipv4.ip_forward=1

5. Start up tunnel interface
wg-quick up wg0
wg show
Вчера, 17:14
Вернуться назад