1
1
mirror of https://github.com/angristan/wireguard-install.git synced 2024-05-31 18:50:47 +00:00

Auto increment the suggested client IP

This commit is contained in:
randomshell 2020-07-01 17:28:09 +00:00
parent 59570c786b
commit 8c0dd0f1a6

View File

@ -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