source: trunk/server/lib/dnspython/examples/ddns.py

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 1.2 KB
Line 
1#!/usr/bin/env python
2
3#
4# Use a TSIG-signed DDNS update to update our hostname-to-address
5# mapping.
6#
7# usage: ddns.py <ip-address>
8#
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
11# python code.
12#
13# E.g. on my systems I have this
14#
15# #!/bin/sh
16#
17# DEVICE=$1
18#
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
23# fi
24#
25# in /etc/ifup-local.
26#
27
28import sys
29
30import dns.update
31import dns.query
32import dns.tsigkeyring
33
34#
35# Replace the keyname and secret with appropriate values for your
36# configuration.
37#
38keyring = dns.tsigkeyring.from_text({
39 'keyname.' : 'NjHwPsMKjdN++dOfE5iAiQ=='
40 })
41
42#
43# Replace "example." with your domain, and "host" with your hostname.
44#
45update = dns.update.Update('example.', keyring=keyring)
46update.replace('host', 300, 'A', sys.argv[1])
47
48#
49# Replace "10.0.0.1" with the IP address of your master server.
50#
51response = dns.query.tcp(update, '10.0.0.1', timeout=10)
Note: See TracBrowser for help on using the repository browser.