Skip to content

Instantly share code, notes, and snippets.

@i-v-s
Last active January 19, 2021 14:03
Show Gist options
  • Save i-v-s/3246ab426c9816bb91ebaf1459f61ba2 to your computer and use it in GitHub Desktop.
Save i-v-s/3246ab426c9816bb91ebaf1459f61ba2 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Usage: sh wg.sh number endpoint:35053 public_key
sudo apt update
sudo apt install -y openresolv wireguard
umask 077
wg genkey > privatekey
pk=`cat privatekey`
sudo cat > /etc/wireguard/wg0.conf << EOL
[Interface]
Address = 10.8.0.$1/24
PrivateKey = ${pk}
DNS = 8.8.8.8
[Peer]
PublicKey = $3
Endpoint = $2
AllowedIPs = 10.8.0.1/24
PersistentKeepalive = 20
EOL
wg pubkey < privatekey
rm privatekey
sudo systemctl start wg-quick@wg0
sudo systemctl enable wg-quick@wg0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment