Last active
May 2, 2023 22:43
-
-
Save tuna2134/a86a883775032f43b52924915991f87d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INTERFACE=eth0 | |
clear | |
echo "[+] checking packages" && sudo pacman -Syyu --noconfirm > /dev/null && sudo pacman -S wireguard-tools qrencode jq --noconfirm > /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=172.16.42.1 | |
ListenPort=51820 | |
PostUp=iptables -A FORWARD -i wg0 -j ACCEPT && iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE | |
PostDown=iptables -D FORWARD -i wg0 -j ACCEPT && iptables -t nat -D POSTROUTING -o $INTERFACE -j MASQUERADE | |
[Peer] | |
PublicKey=$(cat /etc/wireguard/keypars/client.pub) | |
AllowedIPs=172.16.42.2 | |
PersistentKeepAlive=30 | |
EOF | |
sudo cat <<EOF > /etc/wireguard/client.conf.sample | |
[Interface] | |
PrivateKey=$(cat /etc/wireguard/keypars/client.key) | |
Address=172.16.42.2 | |
MTU=1420 | |
DNS=1.1.1.1 | |
[Peer] | |
PublicKey=$(cat /etc/wireguard/keypars/server.pub) | |
AllowedIPs=0.0.0.0/0 | |
Endpoint=$(curl -sL 'https://api.ipify.org?format=json' | jq .ip | sed 's/"//g'):51820 | |
PersistentKeepAlive=360 | |
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