diff options
author | angristan <angristan@pm.me> | 2019-05-24 00:26:35 +0200 |
---|---|---|
committer | angristan <angristan@pm.me> | 2019-05-24 00:26:35 +0200 |
commit | 0e4ef1e1e4078401cbdd1e6e5c17b6f0b0aa592b (patch) | |
tree | ad286e81741de178aa3e946fc018232e5afa42a9 /wireguard-install.sh | |
parent | 1981429774a9958df8254674a6eb4cad93c10a07 (diff) |
Fix endpoint when IPv6 is used
Fix #10
Diffstat (limited to 'wireguard-install.sh')
-rw-r--r-- | wireguard-install.sh | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/wireguard-install.sh b/wireguard-install.sh index 203599f..cec2b4b 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -38,6 +38,8 @@ fi SERVER_PUB_IPV4=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) read -rp "IPv4 or IPv6 public address: " -e -i "$SERVER_PUB_IPV4" SERVER_PUB_IP +read -rp "Did you enter an IPv6 address? (y/n) " -e -i n SERVER_PUB_IPV6_USED + # Detect public interface and pre-fill for the user SERVER_PUB_NIC="$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)" read -rp "Public interface: " -e -i "$SERVER_PUB_NIC" SERVER_PUB_NIC @@ -67,6 +69,12 @@ read -rp "First DNS resolver to use for the client: " -e -i "$CLIENT_DNS_1" CLIE CLIENT_DNS_2="176.103.130.131" read -rp "Second DNS resolver to use for the client: " -e -i "$CLIENT_DNS_2" CLIENT_DNS_2 +if [[ $SERVER_PUB_IPV6_USED = 'y' ]]; then + ENDPOINT="[$SERVER_PUB_IP]:$SERVER_PORT" +else + ENDPOINT="$SERVER_PUB_IP:$SERVER_PORT" +fi + # Install WireGuard tools and module if [[ "$OS" = 'ubuntu' ]]; then add-apt-repository ppa:wireguard/wireguard @@ -121,7 +129,7 @@ DNS = $CLIENT_DNS_1,$CLIENT_DNS_2" > "$HOME/$SERVER_WG_NIC-client.conf" # Add the server as a peer to the client echo "[Peer] PublicKey = $SERVER_PUB_KEY -Endpoint = $SERVER_PUB_IP:$SERVER_PORT +Endpoint = $ENDPOINT AllowedIPs = 0.0.0.0/0,::/0" >> "$HOME/$SERVER_WG_NIC-client.conf" chmod 600 -R /etc/wireguard/ |