From 85f49f93a56ac36f0a2c24e07315777a885136ab Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Mon, 16 Oct 2023 22:37:13 -0700 Subject: [PATCH] Update hairpin nat script --- wizard/scripts/update_hairpin_nat.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/wizard/scripts/update_hairpin_nat.sh b/wizard/scripts/update_hairpin_nat.sh index f106eeb..562e748 100644 --- a/wizard/scripts/update_hairpin_nat.sh +++ b/wizard/scripts/update_hairpin_nat.sh @@ -4,17 +4,18 @@ source /opt/vyatta/etc/functions/script-template # create copies of config for modification and backup cp /config/config.boot /config/config.new cp /config/config.boot /config/backups/config.bk-$(date +%Y-%m-%d) -# get current public IP -NEW_IP=$(run show interfaces pppoe pppoe1 | grep "inet\s" | cut -d ' ' -f 6) -# get old public IP -OLD_IP=$(run show nat destination rules | grep 1100 | head -1 | cut -d ' ' -f 8) - -# edit the config.new file -sed -i "s/$OLD_IP/$NEW_IP/" /config/config.new # switch mode to config configure +# get current public IP +NEW_IP=$(run show interfaces pppoe pppoe1 | grep "inet\s" | cut -d ' ' -f 6) +# get old public IP +OLD_IP=$(run show nat destination rules | grep 1100 | head -1 | tr -s ' ' | cut -d' ' -f 3) + +# edit the config.new file +sed -i "s/$OLD_IP/$NEW_IP/" /config/config.new + # apply the new config load /config/config.new { # try commit, save, exit