From 13068adddfc7c743a7e5caeca0bcca74312537a4 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Mon, 22 Aug 2022 03:25:47 +0300 Subject: [PATCH] fix hardcoded device name --- sample_wg_cfg/wg-external.conf | 4 ++-- sample_wg_cfg/wg-internal.conf | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sample_wg_cfg/wg-external.conf b/sample_wg_cfg/wg-external.conf index b7f2dec..4044a23 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 ens2 -j MASQUERADE -PostDown = iptables -t nat -D POSTROUTING -o ens2 -j MASQUERADE +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] diff --git a/sample_wg_cfg/wg-internal.conf b/sample_wg_cfg/wg-internal.conf index 17353db..c025637 100644 --- a/sample_wg_cfg/wg-internal.conf +++ b/sample_wg_cfg/wg-internal.conf @@ -2,10 +2,10 @@ Address = 10.20.30.1/32 ListenPort = 17968 PrivateKey = kOd3FVBggwpjD3AlZKXUxNTzJT0+f3MJdUdR8n6ZBn8= -PostUp = iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE -PostUp = ip rule add from 195.2.79.13 table main -PostDown = iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE -PostDown = ip rule del from 195.2.79.13 table main +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]