Jafner.net/homelab/wizard/scripts/update_hairpin_nat.sh
Joey Hafner 6086222503
Reorganize root level of repo.
- Move homelab, Jafner.dev (now called blog) to root.
- Rename "archived projects" -> "archive"
- Rename "active projects" -> "projects"
- Rename "jafner-homebrew" -> "5ehomebrew"
- Rename "docker-llm-amd" -> "local-ai"
2024-07-16 12:17:55 -07:00

24 lines
613 B
Bash

#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
# get current public IP
NEW_IP=$(show interfaces pppoe pppoe1 | grep "inet\s" | cut -d ' ' -f 6)
# get old public IP
OLD_IP=$(show nat destination rules | grep 1100 | head -1 | tr -s ' ' | cut -d' ' -f 3)
show configuration commands | grep $OLD_IP | sed --expression="s/$OLD_IP/$NEW_IP/" > ipupdate.tmp
configure
source ipupdate.tmp
{ # try commit, save, exit
commit && save && exit
} || { # catch, exit discard and create a very basic error file
exit discard
echo "Script failed. Write some real error handling."
}
rm ipupdate.tmp