Showing posts with label dns. Show all posts
Showing posts with label dns. Show all posts

Thursday, July 13, 2017

FreeDNS dynamic DNS update client (revisited)

Back in 2011 I posted a tweaked script from afraid.org (of FreeDNS) - named dnsactual.sh - to update your IP addresses dynamically in this DNS service provider.

Today I reviewed it, and I further tweaked it, removing dependencies for external web sites.
Before, a GET to http://ipecho.net/plain (or other similar site) was required to get you your public IP address.
But if the site is unavailable, you could get in trouble and end up shooting yourself on the foot, messing up your dynamic DNS entries.

Thanks to OpenDNS (or the omnipresent Google), there is a way to get your IP address with a simple 'dig' query :-)

dig +short myip.opendns.com @resolver1.opendns.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com [ trackback ]

Now the updated script. Feel free to used, edit, magle, whatever!
This logs any updates to syslog, and appends to file, for historic reasons.
I know it could have a lot more health checks for error handling, but for me it's enough.

#!/bin/bash

FQDN="## your own FQDN on FreeDNS ##"
TOKENS="## get your own##"
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LOGGER="logger -t FREEDNS"

CacheIP=$(dig +short $FQDN @ns1.afraid.org)
CurreIP=$(dig +short myip.opendns.com @resolver1.opendns.com)

if [ "$CurreIP" != "$CacheIP" ]
then
  for A in $TOKENS ; do
    $LOGGER `curl -k -s "https://freedns.afraid.org/dynamic/update.php?$A"`
  done
  echo "`date +%Y%m%d-%H%M`: New IP address $CurreIP (old was $CacheIP)" >> /var/log/freedns.log
else
  $LOGGER "Public IP hasn't changed..."
  # the 'else' section is just to validate if the script is actually running, not really needed once tested
fi

Monday, January 3, 2011

dnsactual.sh FreeDNS client

Since ddclient is supposed to work with FreeDNS, but is not *actually* working on Ubuntu, changed to dnsactual.sh from afraid.org unix client listings.

Since there's no .deb, had to hack it.

location: /usr/local/bin
schedule: root crontab every minute

TOKEN="YOU WISH :-)"
PATH=/bin:/sbin:/usr/bin:/usr/sbin
IFACE=[PUBLIC-IF]

if test -f /etc/freedns/dnsactual.conf
then
CacheIP=$(cat /etc/freedns/dnsactual.conf)
fi

CurreIP=$(ifconfig $IFACE | grep -oEe "addr:[0-9\.]*" | cut -f 2 -d :)

if [ "$CurreIP" = "$CacheIP" ]
then
# Both IP are equal
echo "Update not required..."
else
# The IP has change
echo "Updating http://free.afraid.org with " $CurreIP
wget http://freedns.afraid.org/dynamic/update.php?$TOKEN -o /dev/null -O /dev/stdout
echo `date` "Updating log with IP " $CurreIP >> /var/log/dnsactual.log
fi
rm -f /etc/freedns/dnsactual.conf
echo $CurreIP > /etc/freedns/dnsactual.conf

Tuesday, June 13, 2006

Windows :: Disable DNS dynamic updates

Disable DNS dynamic updates

WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

By default, dynamic updates are configured on Windows Server 2003-based clients. To disable dynamic updates for all network interfaces, follow these steps:
  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. On the Edit menu, point to New, and then click DWORD value.
  4. Type DisableDynamicUpdate, and then press ENTER two times.
  5. In Edit DWORD Value, type 1 in the Value data box, and then click OK.
  6. Quit Registry Editor.
To disable dynamic updates for a specific interface, follow these steps:

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\interface - Note interface is the device ID of the network adaptor for the interface that you want to disable dynamic update for.
  3. On the Edit menu, point to New, and then click DWORD value.
  4. Type DisableDynamicUpdate, and then press ENTER two times.
  5. In Edit DWORD Value, type 1 in the Value data box, and then click OK.
  6. Quit Registry Editor.
[ trackback ]