|
Last change
on this file was 740, checked in by Silvan Scherrer, 13 years ago |
|
Samba Server: update vendor 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 |
|
|---|
| 28 | import sys
|
|---|
| 29 |
|
|---|
| 30 | import dns.update
|
|---|
| 31 | import dns.query
|
|---|
| 32 | import dns.tsigkeyring
|
|---|
| 33 |
|
|---|
| 34 | #
|
|---|
| 35 | # Replace the keyname and secret with appropriate values for your
|
|---|
| 36 | # configuration.
|
|---|
| 37 | #
|
|---|
| 38 | keyring = dns.tsigkeyring.from_text({
|
|---|
| 39 | 'keyname.' : 'NjHwPsMKjdN++dOfE5iAiQ=='
|
|---|
| 40 | })
|
|---|
| 41 |
|
|---|
| 42 | #
|
|---|
| 43 | # Replace "example." with your domain, and "host" with your hostname.
|
|---|
| 44 | #
|
|---|
| 45 | update = dns.update.Update('example.', keyring=keyring)
|
|---|
| 46 | update.replace('host', 300, 'A', sys.argv[1])
|
|---|
| 47 |
|
|---|
| 48 | #
|
|---|
| 49 | # Replace "10.0.0.1" with the IP address of your master server.
|
|---|
| 50 | #
|
|---|
| 51 | response = dns.query.tcp(update, '10.0.0.1', timeout=10)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.