"/etc/network/interfaces"
auto tun1 iface tun1 inet6 static address 2001:67c:75c::1 netmask 48 pre-up ip tunnel add tun1 mode gre remote 123.123.123.123 local 185.37.145.80 ttl 255 post-up /root/gre-updater.sh tun1 example.dyndns.org 185.37.145.80
"/root/gre-updater.sh"
#!/bin/bash tunnel_if="$1" tunnel_ext_host="$2" tunnel_int_host="$3" if (( $# == 3 )) then tunnel_home_old=`ip tunnel show | grep $tunnel_if | awk '/remote/ {split ($4,A," "); print A[1]}'` tunnel_home_new=`nslookup $tunnel_ext_host | awk -F ': ' 'NR==6 { print $2 } '` if [ ! "$tunnel_home_old" = "$tunnel_home_new" ] ; then ip tunnel change $tunnel_if mode gre remote $tunnel_home_new local $tunnel_int_host ttl 255 echo "Remote IP updated" else echo "Remote IP is correct" fi else echo usage: gre-updater.sh tun1 example.dyndns.org 123.123.123.123 fi
"/etc/crontab"
Prüft alle 5 Minuten, ob die IP-Adresse noch stimmt und passt diese ggf. an.
*/5 * * * * root /root/gre-updater.sh tun1 example.dyndns.org 185.37.145.80 > /dev/null