From b6b2283dbe05ef0b93364fda9df85bc74f4fe3fe Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Thu, 25 Aug 2022 02:25:19 +0300 Subject: [PATCH] add get IP func to generate --- config_generator/generate_cfgs.sh | 6 ++++++ config_generator/wg-external.conf | 2 +- config_generator/wg-mobile-client.conf | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config_generator/generate_cfgs.sh b/config_generator/generate_cfgs.sh index 7e31730..897d522 100644 --- a/config_generator/generate_cfgs.sh +++ b/config_generator/generate_cfgs.sh @@ -7,6 +7,8 @@ PUBLIC_KEY_INTERNAL=`echo $PRIVATE_KEY_INTERNAL | wg pubkey` PRIVATE_KEY_CLIENT_1=`wg genkey` PUBLIC_KEY_CLIENT_1=`echo $PRIVATE_KEY_CLIENT_1 | wg pubkey` +INTERNAL_IP_ADDRESS=`dig +short txt ch whoami.cloudflare @1.0.0.1` + mkdir configs cp ./wg-external.conf ./configs/wg-external.conf cp ./wg-internal.conf ./configs/wg-internal.conf @@ -49,4 +51,8 @@ sed -i "s^---PUBLIC_KEY_CLIENT_1---^$PUBLIC_KEY_CLIENT_1^" ./configs/wg-external sed -i "s^---PUBLIC_KEY_CLIENT_1---^$PUBLIC_KEY_CLIENT_1^" ./configs/wg-internal.conf sed -i "s^---PUBLIC_KEY_CLIENT_1---^$PUBLIC_KEY_CLIENT_1^" ./configs/wg-mobile-client.conf +sed -i "s^---INTERNAL_IP_ADDRESS---^$INTERNAL_IP_ADDRESS^" ./configs/wg-external.conf +sed -i "s^---INTERNAL_IP_ADDRESS---^$INTERNAL_IP_ADDRESS^" ./configs/wg-internal.conf +sed -i "s^---INTERNAL_IP_ADDRESS---^$INTERNAL_IP_ADDRESS^" ./configs/wg-mobile-client.conf + echo "Generating complete" diff --git a/config_generator/wg-external.conf b/config_generator/wg-external.conf index 73291ff..f2ed6f4 100644 --- a/config_generator/wg-external.conf +++ b/config_generator/wg-external.conf @@ -8,5 +8,5 @@ PostDown = iptables -t nat -D POSTROUTING -o `ip route | awk '/default/ {print $ [Peer] PublicKey = ---PUBLIC_KEY_INTERNAL--- AllowedIPs = 10.20.30.0/24 -Endpoint = 195.2.79.13:17968 +Endpoint = ---INTERNAL_IP_ADDRESS---:17968 PersistentKeepalive = 25 diff --git a/config_generator/wg-mobile-client.conf b/config_generator/wg-mobile-client.conf index 3d6d711..3960700 100644 --- a/config_generator/wg-mobile-client.conf +++ b/config_generator/wg-mobile-client.conf @@ -7,5 +7,5 @@ DNS = 1.1.1.1, 8.8.8.8 [Peer] PublicKey = ---PUBLIC_KEY_INTERNAL--- AllowedIPs = 0.0.0.0/0 -Endpoint = 195.2.79.13:17968 +Endpoint = ---INTERNAL_IP_ADDRESS---:17968 PersistentKeepalive = 25