mirror of
https://github.com/vvzvlad/trickster-vpn.git
synced 2024-12-26 02:41:00 +03:00
add generator-config module
This commit is contained in:
parent
fa89ef055d
commit
d8581416b7
12
config_generator/configs/wg-external.conf
Normal file
12
config_generator/configs/wg-external.conf
Normal file
@ -0,0 +1,12 @@
|
||||
[Interface]
|
||||
Address = 10.20.30.2/32
|
||||
PrivateKey = wFOIRBeFqxu9cU/tAvKAHCOnTDsxQCe2hR02mjF/kHo=
|
||||
PostUp = iptables -t nat -A POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
PostDown = iptables -t nat -D POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
|
||||
#internal node
|
||||
[Peer]
|
||||
PublicKey = UG0rzuBEciN9XGWZnvyU+I8XEosm6Q8XKLumnk+k61o=
|
||||
AllowedIPs = 10.20.30.0/24
|
||||
Endpoint = 195.2.79.13:17968
|
||||
PersistentKeepalive = 25
|
18
config_generator/configs/wg-internal.conf
Normal file
18
config_generator/configs/wg-internal.conf
Normal file
@ -0,0 +1,18 @@
|
||||
[Interface]
|
||||
Address = 10.20.30.1/32
|
||||
ListenPort = 17968
|
||||
PrivateKey = iPnvzKtdDawMWNHEPDIzKq2Za2pG4EkGq1nlZmyDLlE=
|
||||
PostUp = iptables -t nat -A POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
PostUp = ip rule add from `ip route | awk '/default/ {print $3; exit}'` table main
|
||||
PostDown = iptables -t nat -D POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
PostDown = ip rule del from `ip route | awk '/default/ {print $3; exit}'` table main
|
||||
|
||||
#external node
|
||||
[Peer]
|
||||
PublicKey = Kph5VVV/mCx5DPVwD2vwk8RS2Lv6J8U2reVszJKyFEU=
|
||||
AllowedIPs = 10.20.30.2/32, 0.0.0.0/0
|
||||
|
||||
#mobile-client node
|
||||
[Peer]
|
||||
PublicKey = B+VlF5NaHyFCeA/AX7dXQbjo9pe7VVFgvLbbO+vZvnE=
|
||||
AllowedIPs = 10.20.30.3/32
|
11
config_generator/configs/wg-mobile-client.conf
Normal file
11
config_generator/configs/wg-mobile-client.conf
Normal file
@ -0,0 +1,11 @@
|
||||
[Interface]
|
||||
Address = 10.20.30.3/32
|
||||
PrivateKey = OLiqlb0Q4Ryx0QihepS0fYhgWCckZCjEE8ePu6/akkk=
|
||||
DNS = 1.1.1.1, 8.8.8.8
|
||||
|
||||
#internal node
|
||||
[Peer]
|
||||
PublicKey = UG0rzuBEciN9XGWZnvyU+I8XEosm6Q8XKLumnk+k61o=
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
Endpoint = 195.2.79.13:17968
|
||||
PersistentKeepalive = 25
|
52
config_generator/generate_cfgs.sh
Normal file
52
config_generator/generate_cfgs.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!^bin^bash
|
||||
|
||||
PRIVATE_KEY_EXTERNAL=`wg genkey`
|
||||
PUBLIC_KEY_EXTERNAL=`echo $PRIVATE_KEY_EXTERNAL | wg pubkey`
|
||||
PRIVATE_KEY_INTERNAL=`wg genkey`
|
||||
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`
|
||||
|
||||
mkdir configs
|
||||
cp ./wg-external.conf ./configs/wg-external.conf
|
||||
cp ./wg-internal.conf ./configs/wg-internal.conf
|
||||
cp ./wg-mobile-client.conf ./configs/wg-mobile-client.conf
|
||||
|
||||
|
||||
echo "Generating keys..."
|
||||
echo "********************************"
|
||||
echo "Private key for External: $PRIVATE_KEY_EXTERNAL"
|
||||
echo "Public key for External: $PUBLIC_KEY_EXTERNAL"
|
||||
echo "Private key for Internal: $PRIVATE_KEY_INTERNAL"
|
||||
echo "Public key for Internal: $PUBLIC_KEY_INTERNAL"
|
||||
echo "Private key for Client 1: $PRIVATE_KEY_CLIENT_1"
|
||||
echo "Public key for Client 1: $PUBLIC_KEY_CLIENT_1"
|
||||
echo "********************************"
|
||||
|
||||
|
||||
echo "Replacing templates in configs..."
|
||||
gsed -i "s^---PRIVATE_KEY_EXTERNAL---^$PRIVATE_KEY_EXTERNAL^" ./configs/wg-external.conf
|
||||
gsed -i "s^---PRIVATE_KEY_EXTERNAL---^$PRIVATE_KEY_EXTERNAL^" ./configs/wg-internal.conf
|
||||
gsed -i "s^---PRIVATE_KEY_EXTERNAL---^$PRIVATE_KEY_EXTERNAL^" ./configs/wg-mobile-client.conf
|
||||
|
||||
gsed -i "s^---PUBLIC_KEY_EXTERNAL---^$PUBLIC_KEY_EXTERNAL^" ./configs/wg-external.conf
|
||||
gsed -i "s^---PUBLIC_KEY_EXTERNAL---^$PUBLIC_KEY_EXTERNAL^" ./configs/wg-internal.conf
|
||||
gsed -i "s^---PUBLIC_KEY_EXTERNAL---^$PUBLIC_KEY_EXTERNAL^" ./configs/wg-mobile-client.conf
|
||||
|
||||
gsed -i "s^---PRIVATE_KEY_INTERNAL---^$PRIVATE_KEY_INTERNAL^" ./configs/wg-external.conf
|
||||
gsed -i "s^---PRIVATE_KEY_INTERNAL---^$PRIVATE_KEY_INTERNAL^" ./configs/wg-internal.conf
|
||||
gsed -i "s^---PRIVATE_KEY_INTERNAL---^$PRIVATE_KEY_INTERNAL^" ./configs/wg-mobile-client.conf
|
||||
|
||||
gsed -i "s^---PUBLIC_KEY_INTERNAL---^$PUBLIC_KEY_INTERNAL^" ./configs/wg-external.conf
|
||||
gsed -i "s^---PUBLIC_KEY_INTERNAL---^$PUBLIC_KEY_INTERNAL^" ./configs/wg-internal.conf
|
||||
gsed -i "s^---PUBLIC_KEY_INTERNAL---^$PUBLIC_KEY_INTERNAL^" ./configs/wg-mobile-client.conf
|
||||
|
||||
gsed -i "s^---PRIVATE_KEY_CLIENT_1---^$PRIVATE_KEY_CLIENT_1^" ./configs/wg-external.conf
|
||||
gsed -i "s^---PRIVATE_KEY_CLIENT_1---^$PRIVATE_KEY_CLIENT_1^" ./configs/wg-internal.conf
|
||||
gsed -i "s^---PRIVATE_KEY_CLIENT_1---^$PRIVATE_KEY_CLIENT_1^" ./configs/wg-mobile-client.conf
|
||||
|
||||
gsed -i "s^---PUBLIC_KEY_CLIENT_1---^$PUBLIC_KEY_CLIENT_1^" ./configs/wg-external.conf
|
||||
gsed -i "s^---PUBLIC_KEY_CLIENT_1---^$PUBLIC_KEY_CLIENT_1^" ./configs/wg-internal.conf
|
||||
gsed -i "s^---PUBLIC_KEY_CLIENT_1---^$PUBLIC_KEY_CLIENT_1^" ./configs/wg-mobile-client.conf
|
||||
|
||||
echo "Generating complete"
|
12
config_generator/wg-external.conf
Normal file
12
config_generator/wg-external.conf
Normal file
@ -0,0 +1,12 @@
|
||||
[Interface]
|
||||
Address = 10.20.30.2/32
|
||||
PrivateKey = ---PRIVATE_KEY_EXTERNAL---
|
||||
PostUp = iptables -t nat -A POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
PostDown = iptables -t nat -D POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
|
||||
#internal node
|
||||
[Peer]
|
||||
PublicKey = ---PUBLIC_KEY_INTERNAL---
|
||||
AllowedIPs = 10.20.30.0/24
|
||||
Endpoint = 195.2.79.13:17968
|
||||
PersistentKeepalive = 25
|
18
config_generator/wg-internal.conf
Normal file
18
config_generator/wg-internal.conf
Normal file
@ -0,0 +1,18 @@
|
||||
[Interface]
|
||||
Address = 10.20.30.1/32
|
||||
ListenPort = 17968
|
||||
PrivateKey = ---PRIVATE_KEY_INTERNAL---
|
||||
PostUp = iptables -t nat -A POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
PostUp = ip rule add from `ip route | awk '/default/ {print $3; exit}'` table main
|
||||
PostDown = iptables -t nat -D POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE
|
||||
PostDown = ip rule del from `ip route | awk '/default/ {print $3; exit}'` table main
|
||||
|
||||
#external node
|
||||
[Peer]
|
||||
PublicKey = ---PUBLIC_KEY_EXTERNAL---
|
||||
AllowedIPs = 10.20.30.2/32, 0.0.0.0/0
|
||||
|
||||
#mobile-client node
|
||||
[Peer]
|
||||
PublicKey = ---PUBLIC_KEY_CLIENT_1---
|
||||
AllowedIPs = 10.20.30.3/32
|
11
config_generator/wg-mobile-client.conf
Normal file
11
config_generator/wg-mobile-client.conf
Normal file
@ -0,0 +1,11 @@
|
||||
[Interface]
|
||||
Address = 10.20.30.3/32
|
||||
PrivateKey = ---PRIVATE_KEY_CLIENT_1---
|
||||
DNS = 1.1.1.1, 8.8.8.8
|
||||
|
||||
#internal node
|
||||
[Peer]
|
||||
PublicKey = ---PUBLIC_KEY_INTERNAL---
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
Endpoint = 195.2.79.13:17968
|
||||
PersistentKeepalive = 25
|
Loading…
Reference in New Issue
Block a user