4 # Use a TSIG-signed DDNS update to update our hostname-to-address
7 # usage: ddns.py <ip-address>
9 # On linux systems, you can automatically update your DNS any time an
10 # interface comes up by adding an ifup-local script that invokes this
13 # E.g. on my systems I have this
19 # if [ "X${DEVICE}" == "Xeth0" ]; then
20 # IPADDR=`LANG= LC_ALL= ifconfig ${DEVICE} | grep 'inet addr' |
21 # awk -F: '{ print $2 } ' | awk '{ print $1 }'`
22 # /usr/local/sbin/ddns.py $IPADDR
32 import dns
.tsigkeyring
35 # Replace the keyname and secret with appropriate values for your
38 keyring
= dns
.tsigkeyring
.from_text({
39 'keyname.' : 'NjHwPsMKjdN++dOfE5iAiQ=='
43 # Replace "example." with your domain, and "host" with your hostname.
45 update
= dns
.update
.Update('example.', keyring
=keyring
)
46 update
.replace('host', 300, 'A', sys
.argv
[1])
49 # Replace "10.0.0.1" with the IP address of your master server.
51 response
= dns
.query
.tcp(update
, '10.0.0.1', timeout
=10)