Skip to content

Instantly share code, notes, and snippets.

@tuna2134
Last active January 14, 2025 03:52
Show Gist options
  • Save tuna2134/ba58cdde642da18033e9445b5c4019a7 to your computer and use it in GitHub Desktop.
Save tuna2134/ba58cdde642da18033e9445b5c4019a7 to your computer and use it in GitHub Desktop.
INTERFACE=eth0
clear
echo "[+] checking packages" && sudo apt-get update > /dev/null && sudo apt-get install wireguard qrencode jq -y > /dev/null &&
echo "[+] creating keypars" && rm -rf /etc/wireguard/keypars && mkdir /etc/wireguard/keypars &&
wg genkey | sudo tee -a /etc/wireguard/keypars/server.key > /dev/null
sudo cat /etc/wireguard/keypars/server.key | wg pubkey | tee -a /etc/wireguard/keypars/server.pub > /dev/null
wg genkey | tee -a /etc/wireguard/keypars/client.key > /dev/null
sudo cat /etc/wireguard/keypars/client.key | wg pubkey | tee -a /etc/wireguard/keypars/client.pub > /dev/null
echo "[+] creating config files"
sudo cat <<EOF > /etc/wireguard/wg0.conf
[Interface]
PrivateKey=$(cat /etc/wireguard/keypars/server.key)
Address=2601:1d08:8000:1::1/64
ListenPort=3478
PostUp=ip6tables -A FORWARD -i wg0 -j ACCEPT
PostDown=ip6tables -D FORWARD -i wg0 -j ACCEPT
[Peer]
PublicKey=$(cat /etc/wireguard/keypars/client.pub)
AllowedIPs=::/0
PersistentKeepAlive=30
EOF
sudo cat <<EOF > /etc/wireguard/client.conf.sample
[Interface]
PrivateKey=$(cat /etc/wireguard/keypars/client.key)
Address=2601:1d08:8000:1::2/64
MTU=1420
DNS=1.1.1.1
[Peer]
PublicKey=$(cat /etc/wireguard/keypars/server.pub)
AllowedIPs=::/0
Endpoint=$(curl -sL 'https://api.ipify.org?format=json' | jq .ip | sed 's/"//g'):3478
PersistentKeepAlive=25
EOF
echo "[+] setting up host"
sudo cat /etc/sysctl.conf | sudo sed -i '/net.ipv4.ip_forward=1/c net.ipv4.ip_forward=1' /etc/sysctl.conf
sudo sysctl -p > /dev/null
sudo systemctl enable --now wg-quick@wg0
sudo systemctl restart wg-quick@wg0
echo "[+] SCREENING KEYPARE"
echo "------------------< ClientKey >------------------"
cat /etc/wireguard/keypars/client.key
echo -e "\n------------------< ClientPub >------------------"
cat /etc/wireguard/keypars/client.pub
echo -e "\n------------------< ServerPub >------------------"
cat /etc/wireguard/keypars/client.pub
echo -e "\n------------------< ServerPub >------------------"
cat /etc/wireguard/keypars/server.pub
echo ""
echo "[+] SCREENING CLIENT CONFIG"
cat /etc/wireguard/client.conf.sample
echo ""
echo "[+] SCREENING CLIENT QR"
qrencode -t ansiutf8 < /etc/wireguard/client.conf.sample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment