Last active
June 11, 2022 22:50
-
-
Save metrafonic/53b51b117c9ebb7f75ac412fcf619605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/vbash | |
# /config/scripts/dynamic-vti.sh | |
# configure vti address based on dynamic dns address | |
NEW_IP=$(getent hosts yourdomain.com | awk '{ print $1 }') | |
CUR_IP=$(cat /config/config.boot | grep site-to-site -A1 | grep peer | awk '{ print $2}') | |
echo "CURRENT: $CUR_IP" | |
echo "NEW: $NEW_IP" | |
if [ "$CUR_IP" = "$NEW_IP" ]; then | |
echo Addresses the same | |
exit 1; | |
fi | |
echo "CHANGE NEEDED" | |
source /opt/vyatta/etc/functions/script-template | |
configure | |
delete vpn ipsec site-to-site | |
set vpn ipsec site-to-site peer $NEW_IP | |
# Paste the rest of your config here. | |
# For example: | |
# set vpn ipsec site-to-site peer $NEW_IP authentication pre-shared-secret xxxxx" | |
# Make sure you include all config items needed to set up your connection | |
commit | |
save | |
exit | |
restart vpn | |
ping 192.168.x.x # To initiate the link (create traffic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment