From df3d8b70ec2256dfe0c755f6243ce0bfbb0ec2c6 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Tue, 23 Aug 2022 23:12:01 +0300 Subject: [PATCH] fixed a bug incorrect interface selection --- config_generator/wg-external.conf | 4 ++-- config_generator/wg-internal.conf | 4 ++-- sample_wg_cfg/wg-external.conf | 4 ++-- sample_wg_cfg/wg-internal.conf | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config_generator/wg-external.conf b/config_generator/wg-external.conf index 84b361d..73291ff 100644 --- a/config_generator/wg-external.conf +++ b/config_generator/wg-external.conf @@ -1,8 +1,8 @@ [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 +PostUp = iptables -t nat -A POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -j MASQUERADE +PostDown = iptables -t nat -D POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -j MASQUERADE #internal node [Peer] diff --git a/config_generator/wg-internal.conf b/config_generator/wg-internal.conf index 4d8f32a..1fabeef 100644 --- a/config_generator/wg-internal.conf +++ b/config_generator/wg-internal.conf @@ -2,9 +2,9 @@ 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 = iptables -t nat -A POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -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 = iptables -t nat -D POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -j MASQUERADE PostDown = ip rule del from `ip route | awk '/default/ {print $3; exit}'` table main #external node diff --git a/sample_wg_cfg/wg-external.conf b/sample_wg_cfg/wg-external.conf index 4044a23..965fb9c 100644 --- a/sample_wg_cfg/wg-external.conf +++ b/sample_wg_cfg/wg-external.conf @@ -1,8 +1,8 @@ [Interface] Address=10.20.30.2/32 PrivateKey=6CCRP42JiTObyf64Vo0BcqsX6vptsqOU+MKUslUun28= -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 +PostUp = iptables -t nat -A POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -j MASQUERADE +PostDown = iptables -t nat -D POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -j MASQUERADE #internal node [Peer] diff --git a/sample_wg_cfg/wg-internal.conf b/sample_wg_cfg/wg-internal.conf index c025637..b8e43c1 100644 --- a/sample_wg_cfg/wg-internal.conf +++ b/sample_wg_cfg/wg-internal.conf @@ -2,9 +2,9 @@ Address = 10.20.30.1/32 ListenPort = 17968 PrivateKey = kOd3FVBggwpjD3AlZKXUxNTzJT0+f3MJdUdR8n6ZBn8= -PostUp = iptables -t nat -A POSTROUTING -o `ip link show | awk -F ': ' '/state UP/ {print $2}'` -j MASQUERADE +PostUp = iptables -t nat -A POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -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 = iptables -t nat -D POSTROUTING -o `ip route | awk '/default/ {print $5; exit}'` -j MASQUERADE PostDown = ip rule del from `ip route | awk '/default/ {print $3; exit}'` table main #external node