netstat -an
udp6 0 0 *.51820 *.* udp4 0 0 *.51820 *.*
#!/bin/bash#!/bin/bash#set -x#logger "BACKUP started"IP="10.10.10.1"static="123.45.78.97" # is static addressfunction reset(){ifdown wg0sleep 2sifup wg0sleep 10sreturn}function test(){OK=0ping -i 1 -c 1 -q $1 &>/dev/null ||OK=1echo $OK}function replace(){ # get current dynIP new=( $(host dyn.dns.fqdn|grep address|awk -F\ '{ print $4 }') ) old=`grep "dyn.dns.fqdn" /etc/hosts|awk -F\ '{ print $1 }'` if [ "$static" = "$old" ]; then sed -i "0,/$old/s//$new/" /etc/hosts else if [ "$new" = "$old" ]; then sed -i "0,/$old/s//$static/" /etc/hosts else sed -i "0,/$old/s//$new/" /etc/hosts fi fireturn}BO=0BO=$(test $IP )while [ $BO -eq 1 ]do echo "Verbindung fehlerhaft" replace reset BO=$(test $IP ) if [ $BO -eq 1 ]; then sleep 10m BO=$(test $IP ) fi done