The default configuration file name, /etc/inadyn.conf, is looked at automatically if inadyn is called without any command line options. The format is as expected for a UNIX config file; the hash character is used to comment entire lines. Spaces are ingored.
![Install configure inadyn configuration Install configure inadyn configuration](/uploads/1/2/6/2/126281340/919854143.jpg)
![Configuration Configuration](/uploads/1/2/6/2/126281340/271266280.png)
The problem with this solution is that inadyn does not detect if network is up, and sometimes it updates too much times and server disables your dynamic dns account.
This script works most of the times. It uses dhcp to know when ip has been updated.
#!/bin/sh
# FILE: dhcp3/dhclient-exit-hooks.d/zzz_public_ip
username=*fill in*
password=*fill in*
domain=*fill in*
dns_ip=`host '$domain' |sed -e 's/[A-Za-z. -]* //'`
actual_ip=`wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`
function test_network_and_ip_on_dns() {
# Some times ping is not allowed :-(
# case `ping -qnc 1 google.com 2>&1` in
# *'100% packet loss'*)
# logger -t publicIP “The network is DOWN.”
# exit 0
# ;;
# esac
NETSTATUS=`wget -O - www.google.com 2>&1 | grep 'Network is unreachable'`
# echo 'NETSTATUS: $NETSTATUS.'
if [ -z '$NETSTATUS' ] || [ ' '$NETSTATUS' ]; then
test_ip_on_dns
else
logger -t publicIP “Network is DOWN.”
exit 0
fi
}
function test_ip_on_dns() {
if [ '$dns_ip' '$actual_ip' ]; then
logger -t publicIP 'Public IP is $actual_ip'
else
logger -t publicIP 'Updating ip for domain $domain with username $username'
/usr/sbin/inadyn --iterations 1 -u $username -p $password -a $domain
logger -t publicIP 'Public IP is $actual_ip'
fi
}
if [ -z '$reason' ]; then
test_network_and_ip_on_dns
exit 0
fi
case '$reason' in
MEDIUM|ARPCHECK|ARPSEND|NBI|BOUND|RENEW|REBIND)
logger -t publicIP 'Updating public IP. Reason: $reason'
test_network_and_ip_on_dns
;;
EXPIRE|FAIL|TIMEOUT|PREINIT|REBOOT|STOP|RELEASE|*)
logger -t publicIP 'Not updating. Reason: $reason'
;;
esac
This script works most of the times. It uses dhcp to know when ip has been updated.
#!/bin/sh
# FILE: dhcp3/dhclient-exit-hooks.d/zzz_public_ip
username=*fill in*
password=*fill in*
domain=*fill in*
dns_ip=`host '$domain' |sed -e 's/[A-Za-z. -]* //'`
actual_ip=`wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`
function test_network_and_ip_on_dns() {
# Some times ping is not allowed :-(
# case `ping -qnc 1 google.com 2>&1` in
# *'100% packet loss'*)
# logger -t publicIP “The network is DOWN.”
# exit 0
# ;;
# esac
NETSTATUS=`wget -O - www.google.com 2>&1 | grep 'Network is unreachable'`
# echo 'NETSTATUS: $NETSTATUS.'
if [ -z '$NETSTATUS' ] || [ ' '$NETSTATUS' ]; then
test_ip_on_dns
else
logger -t publicIP “Network is DOWN.”
exit 0
fi
}
function test_ip_on_dns() {
if [ '$dns_ip' '$actual_ip' ]; then
logger -t publicIP 'Public IP is $actual_ip'
else
logger -t publicIP 'Updating ip for domain $domain with username $username'
/usr/sbin/inadyn --iterations 1 -u $username -p $password -a $domain
logger -t publicIP 'Public IP is $actual_ip'
fi
}
if [ -z '$reason' ]; then
test_network_and_ip_on_dns
exit 0
fi
case '$reason' in
MEDIUM|ARPCHECK|ARPSEND|NBI|BOUND|RENEW|REBIND)
logger -t publicIP 'Updating public IP. Reason: $reason'
test_network_and_ip_on_dns
;;
EXPIRE|FAIL|TIMEOUT|PREINIT|REBOOT|STOP|RELEASE|*)
logger -t publicIP 'Not updating. Reason: $reason'
;;
esac