diff --git a/wireguard-install.sh b/wireguard-install.sh index 40c08ce..7c59544 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -12,10 +12,12 @@ function addClient() { ENDPOINT="$SERVER_PUB_IP:$SERVER_PORT" fi - CLIENT_WG_IPV4="10.66.66.2" + # count peers and increment the suggested client IP + peersCount=$(grep -c 'Peer' /etc/wireguard/"$SERVER_WG_NIC".conf) + CLIENT_WG_IPV4="10.66.66.$((peersCount+2))" read -rp "Client's WireGuard IPv4 " -e -i "$CLIENT_WG_IPV4" CLIENT_WG_IPV4 - CLIENT_WG_IPV6="fd42:42:42::2" + CLIENT_WG_IPV6="fd42:42:42::$((peersCount+2))" read -rp "Client's WireGuard IPv6 " -e -i "$CLIENT_WG_IPV6" CLIENT_WG_IPV6 # Adguard DNS by default