Wireguard point-to-point

From UVOO Tech Wiki
Revision as of 09:33, 27 July 2024 by Busk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
sudo apt update
sudo apt install wireguard

sudo yum install epel-release
sudo yum install wireguard-tools

wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey

Host A /etc/wireguard/wg0.conf

[Interface]
PrivateKey = <Host A private key>
Address = 10.0.0.1/24
ListenPort = 51820

[Peer]
PublicKey = <Host B public key>
AllowedIPs = 10.0.0.2/32
Endpoint = <Host B public IP>:51820

Host B /etc/wireguard/wg0.conf

[Interface]
PrivateKey = <Host B private key>
Address = 10.0.0.2/24
ListenPort = 51820

[Peer]
PublicKey = <Host A public key>
AllowedIPs = 10.0.0.1/32
Endpoint = <Host A public IP>:51820

echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

sudo wg-quick up wg0

sudo wg show
sudo systemctl enable wg-quick@wg0

sudo journalctl -u wg-quick@wg0