|
@@ -0,0 +1,126 @@
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+apt update
|
|
|
|
+apt install software-properties-common -y
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+echo .read | add-apt-repository ppa:wireguard/wireguard
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+apt update
|
|
|
|
+apt install wireguard resolvconf -y
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+apt -y install qrencode
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+modprobe wireguard && lsmod | grep wireguard
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+modprobe wireguard && lsmod | grep wireguard
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+mkdir -p /etc/wireguard
|
|
|
|
+cd /etc/wireguard
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+wg genkey | tee sprivatekey | wg pubkey > spublickey
|
|
|
|
+wg genkey | tee cprivatekey | wg pubkey > cpublickey
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+serverip=$(curl -4 icanhazip.com)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+echo "[Interface]
|
|
|
|
+
|
|
|
|
+PrivateKey = $(cat sprivatekey)
|
|
|
|
+
|
|
|
|
+Address = 10.0.0.1/24
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
|
|
|
+
|
|
|
|
+ListenPort = 9009
|
|
|
|
+
|
|
|
|
+DNS = 8.8.8.8
|
|
|
|
+
|
|
|
|
+MTU = 1300
|
|
|
|
+[Peer]
|
|
|
|
+
|
|
|
|
+PublicKey = $(cat cpublickey)
|
|
|
|
+
|
|
|
|
+AllowedIPs = 10.0.0.2/32" > wg0.conf
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+echo "[Interface]
|
|
|
|
+
|
|
|
|
+PrivateKey = $(cat cprivatekey)
|
|
|
|
+
|
|
|
|
+Address = 10.0.0.2/24
|
|
|
|
+
|
|
|
|
+DNS = 8.8.8.8
|
|
|
|
+
|
|
|
|
+MTU = 1300
|
|
|
|
+
|
|
|
|
+PreUp = start .\route\routes-up.bat
|
|
|
|
+PostDown = start .\route\routes-down.bat
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+[Peer]
|
|
|
|
+
|
|
|
|
+PublicKey = $(cat spublickey)
|
|
|
|
+
|
|
|
|
+Endpoint = $serverip:9009
|
|
|
|
+
|
|
|
|
+AllowedIPs = 0.0.0.0/0, ::0/0
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+PersistentKeepalive = 25"|sed '/^#/d;/^\s*$/d' > client.conf
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+chmod 777 -R /etc/wireguard
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
|
|
+echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
|
|
|
|
+sysctl -p
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+wg-quick up wg0
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+systemctl enable wg-quick@wg0
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+wg
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+cat /etc/wireguard/client.conf | qrencode -o - -t ansi
|
|
|
|
+cat /etc/wireguard/client.conf
|