pcfe's blog

DynDNS Updates With TSIG and /etc/ppp/ip-up.local

changing providers I adjusted the old script to fit my router, using PPPoE but not NetworkManager.

Create /etc/ppp/ip-up.local with this content

(ip-up.local) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# adapted from
# NetworkManager dispatcher script to update dyndns via TSIG using nsupdate
# http://centos5.pcfe.net/wordpress/2011/09/dyndns-updates-with-tsig-and-networkmanager-dispatcher/
# http://www.pcfe.net/octopress/blog/2011/09/13/dyndns-updates-with-tsig-and-networkmanager-dispatcher/
# pcfe, 2012-09-07
#
# adaptation of http://messinet.com/trac/browser/networkmanager-nsupdate-gss-tsig/20-nsupdate-gss-tsig
# read https://www.dyndns.com/account/settings/tsig.html
# and https://www.dyndns.com/support/kb/ddns_updates_and_tsig.html
# pcfe, 2011-09-13
#

# set -x

# http://www.tldp.org/HOWTO/PPP-HOWTO/x1455.html
# When the ppp link comes up, this script is called with the following
# parameters
#       $1      the interface name used by pppd (e.g. ppp3)
#       $2      the tty device name
#       $3      the tty device speed
#       $4      the local IP address for the interface
#       $5      the remote IP address
#       $6      the parameter specified by the 'ipparam' option to pppd
#

#
# Function definitions
#

# Invoke nsupdate 
# (vars defined below)
updateRRs() {
  (echo "server update.dyndns.com"
   echo "zone ${ZONE}"
   echo "key ${KEY_NAME} ${KEY_HMAC}"
   echo "update add ${HOST}.${ZONE} ${TTL} A ${ADDR}"
   echo "send"
  ) | nsupdate -t 60 || exit 1
}

#
# Start working...
#

# Set the host name & ttl
ADDR=`/sbin/ifconfig $1 | grep "inet addr:" | awk '{print $2}' | awk -F ":" '{print $2}'`
#ADDR=`/sbin/ifconfig $1 | grep "inet " | awk '{print $2}'`
# short TTL so we have the new address shortly after ADSL came up
TTL=60
# the DynDNS hostname and zone you want to update, e.g. myserver.mydomain.net
HOST="myserver"
ZONE="mydomain.net"
# get the next two values from https://www.dyndns.com/account/settings/tsig.html
KEY_NAME="MyKeyName"
KEY_HMAC="MyKeyHMAC"
# Proceed only if called for ppp  interface
if [[ "$1" ==  ppp* ]]
then
  # logger "Called as $0 $@."
  logger updating DNS to point at $4
  updateRRs
else
  logger "Not called for ppp interface. Exiting."
  exit 1
fi

exit 0

nail down the file permissions:

1
2
3
4
cd /etc/ppp
chmod 700 ip-up.local
chown root.root ip-up.local
restorecon -v /etc/ppp/ip-up.local

I’ve only used this on CentOS5, but you can expect this to work on pretty much any distribution. Go through your distribution’s ifup scripts (Red Hat based distros /etc/sysconfig/network-scripts) if /etc/ppp/ip-up.local is not the path for you.

If the above makes no sense to you, then you probably want to continue updating your DynDNS entries with ddclient.

nsupdate can be found in the bind-utils RPM. yum install bind-utils.

When having trouble with bind, I find that the book DNS and BIND (5th Edition), ISBN 9780596100575, published by O’Reilly Media, Inc always comes in handy.