add get IP func to generate

This commit is contained in:
vvzvlad 2022-08-25 02:25:19 +03:00
parent 34d8f3e48c
commit b6b2283dbe
3 changed files with 8 additions and 2 deletions

View File

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

View File

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

View File

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