Reply To: Multiple DynDns

Home Page Forums Network Management Networking Multiple DynDns Reply To: Multiple DynDns

#48756

Lightyear
Member

No need to bother Ivan; here follows the modified script 8)

#!/bin/sh
# Script made by Ivan Baldo to permit multiple dyndns accounts in ZeroShell

Host_PPP0="http_address_of_dyndns_account_1"
Host_PPP1="http_address_of_dyndns_account_2"

actualiza ()
{
Interfaz="$1"
Host="$2"
Usuario="$3"
Contrasena="$4"
IP=$(ifconfig $Interfaz 2>/dev/null | awk 'NR==2 {print $2}' | grep '.*..*..*..*' | cut -d: -f2)
touch /tmp/dyndns.ipviej.$Interfaz
IPViej="$(cat /tmp/dyndns.ipviej.$Interfaz)"
Actualizar="no"
if [ "$IP" != "" ]; then
if [ "$IP" != "$IPViej" ]; then
Actualizar="si"
fi
fi
if [ "$Actualizar" = "no" ]; then
return
fi
if [ -e /tmp/dyndns.deshabilitado.$Interfaz ]; then
return
fi
logger -t DDNS "Actualizando $Host a $IP de interfaz $Interfaz."
if wget "--bind-address=$IP" -t 3 -w 20 -o /tmp/dyndns.error.$Interfaz -O /tmp/dyndns.resultado.$Interfaz
"http://$Usuario:$Contrasena@members.dyndns.org/nic/update?system=dyndns&hostname=$Host&mx=$Host&myip=$IP"
then
logger -t DDNS "==> $(cat /tmp/dyndns.resultado.$Interfaz)"
if grep -q "!yours|notfqdn|abuse|nohost|badagent|badauth|badsys|dnserr|numhost|911|!donator"
/tmp/dyndns.resultado.$Interfaz
then
logger -t DDNS "==> Hubo un error reportado por DynDNS, luego de solucionar el problema borre el archivo /tmp/dyndns.deshabilitado.$Interfaz!"
touch /tmp/dyndns.deshabilitado.$Interfaz
else
echo "$IP" >/tmp/dyndns.ipviej.$Interfaz
fi
else
logger -t DDNS "==> Error al conectarse con DynDNS:"
grep -v " => " /tmp/dyndns.error.$Interfaz | logger -t DDNS
fi
}

while true; do
actualiza ppp0 $Host_PPP0 username_1 password_1
actualiza ppp1 $Host_PPP1 username_2 password_2
sleep 60
done

Of course, to provide for another DDNS service, it would be neccesary to know these other service quirks and tricks.
And thank you for the tip, ppalias! I do hope you have had a very good 2010 beginning.