From 696976c52d53ca669a44583540188a03ac25371e Mon Sep 17 00:00:00 2001 From: Matt Low Date: Fri, 1 Jan 2021 09:10:11 -0700 Subject: [PATCH] Slight reordering/cleanup --- vpnerator.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vpnerator.sh b/vpnerator.sh index 942ce1c..ff7a472 100755 --- a/vpnerator.sh +++ b/vpnerator.sh @@ -90,7 +90,7 @@ ssh -T ${HOST} /bin/bash << END # include SERVER_LIB ${SERVER_LIB} -# Install depends +# Check/install depends deps || exit 1 # Cleanup previous tunnel @@ -102,9 +102,6 @@ if [ "\$?" -eq 2 ] ; then fi umask 0177 - -exec_sudo ip link add "${INTERFACE_NAME}" type wireguard - TMP=\$(mktemp) cat << EOF > \${TMP} [Interface] @@ -118,11 +115,10 @@ PresharedKey = ${PSK} AllowedIPs = ${CLIENT_ADDR} EOF +exec_sudo ip link add "${INTERFACE_NAME}" type wireguard exec_sudo wg setconf "${INTERFACE_NAME}" "\${TMP}" rm "\${TMP}" -enable_forwarding - exec_sudo ip addr add "${SERVER_ADDR}" dev "${INTERFACE_NAME}" exec_sudo ip link set mtu 1420 up dev "${INTERFACE_NAME}" @@ -130,6 +126,8 @@ exec_sudo iptables -A FORWARD -i "${INTERFACE_NAME}" -j ACCEPT exec_sudo iptables -A FORWARD -o "${INTERFACE_NAME}" -j ACCEPT exec_sudo iptables -t nat -A POSTROUTING -s "${CLIENT_ADDR}" -o "\${DEFAULT_IFACE}" -j MASQUERADE +enable_forwarding + echo sudo wg show "$INTERFACE_NAME" END