March 7, 2022
wireguard fast launch
AWS EC2 instance with Ubuntu 20.04
apt update && apt upgrade -y apt install -y wireguard wg genkey | tee /etc/wireguard/privatekey | wg pubkey | tee /etc/wireguard/publickey chmod 600 /etc/wireguard/privatekey
add to /etc/wireguard/wg0.conf
[Interface] PrivateKey = <privatekey> Address = 10.0.0.1/24 ListenPort = 51500 PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ens5 -j MASQUERADE PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ens5 -j MASQUERADE
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf sysctl -p
systemctl enable [email protected] systemctl start [email protected] systemctl status [email protected]
wg genkey | tee /etc/wireguard/client1_privatekey | wg pubkey | tee /etc/wireguard/client1_publickey
add to /etc/wireguard/wg0.conf
[Peer] PublicKey = <client1_publickey> AllowedIPs = 10.0.0.2/32
systemctl restart wg-quick@wg0 systemctl status wg-quick@wg0
[Interface] PrivateKey = <CLIENT-PRIVATE-KEY> Address = 10.0.0.2/32 DNS = 8.8.8.8 [Peer] PublicKey = <SERVER-PUBKEY> Endpoint = <SERVER-IP>:51830 AllowedIPs = 0.0.0.0/0 PersistentKeepalive = 20