Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4641652
By: csrc
Hello All,
Here is a patch to ddclient 3.6.3 to enable via nsupdate. I took and extended
the original idea from the freshmeat list. Help information is included in
the patch to ddclient.
Thanks for poviding a great and extendable base program!
=============={ Cut Here }=======================
--- ddclient.ori 2007-11-25 12:06:19.000000000 -0700
+++ ddclient 2007-11-25 15:49:10.000000000 -0700
@@ -13,7 +13,7 @@
use Sys::Hostname;
use IO::Socket;
-my $version = "3.6.3";
+my $version = "3.6.3.ns";
my $programd = $0;
$programd =~ s%^.*/%%;
my $program = $programd;
@@ -247,6 +247,10 @@
'mx' => setv(T_OFQDN, 0, 1, 1, '', undef),
'mxpri' => setv(T_NUMBER, 0, 0, 1, 5, undef),
},
+ 'nsupdate-common-defaults' => {
+ 'ttl' => setv(T_NUMBER, 0, 1, 0, 0, undef),
+ 'zone' => setv(T_STRING, 1, 1, 1, '', undef),
+ },
);
my %services = (
'dyndns1' => {
@@ -319,6 +323,17 @@
$variables{'service-common-defaults'},
),
},
+ 'nsupdate' => {
+ 'updateable' => undef,
+ 'update' => \&nic_nsupdate_update,
+ 'examples' => \&nic_nsupdate_examples,
+ 'variables' => merge(
+ { 'login' => setv(T_LOGIN, 1, 0, 1, 'nsupdate', undef),},
+ { 'ttl' => setv(T_NUMBER, 0, 1, 0, 600, undef),},
+ $variables{'nsupdate-common-defaults'},
+ $variables{'service-common-defaults'},
+ ),
+ },
);
$variables{'merged'} = merge($variables{'global-defaults'},
$variables{'service-common-defaults'},
@@ -2659,3 +2674,112 @@
}
}
######################################################################
+
+######################################################################
+## nic_nsupdate_updateable
+######################################################################
+sub nic_nsupdate_updateable {
+ return 0;
+}
+######################################################################
+## nic_nsupdate_examples
+######################################################################
+sub nic_nsupdate_examples {
+ return <<EoEXAMPLE;
+o 'nsupdate'
+
+The 'nsupdate' protocol is used to submit Dynamic DNS Update requests as
+defined in RFC2136 to a name server. This allows resource records to be
+added or removed from a zone without manually editing the zone file.
+
+The bind9 server from Internet Systems Consortium, Inc. ("ISC") is an
+example of such a server and client.
+
+Configuration variables specific to the 'nsupdate' protocol are:
+
+ttl=600 ## ttl - Time To Live of record
+ ## defaults to 600 seconds
+zone=dynamic.example.com ## forward zone that is to be updated
+
+Configuration variables applicable to the 'nsupdate' protocol are:
+
+login=nsupdate ## this option is not used and is defaulted
+ ## to nsupdate
+
+server= ## name or IP address of the Dynamic Name Server
+protocol=nsupdate ## sub-updater flag for ddclient
+pasword= ## path and name of the key file to use for secure
+ ## name updates
+<hostname> ## hostname of record to update; the zone name will be
+ ## appended where approriate
+
+Example of a fully populated ${program}.conf entry:
+
+##
+## nsupdate (isc.org)
+##
+server=127.0.0.1, \\
+protocol=nsupdate, \\
+zone=dynamic.example.com, \\
+password=/etc/${program}/Kmy-dynamic-key.+157+12345.private, \\
+ttl=42300, \\
+my-dynamic-hostname
+
+EoEXAMPLE
+}
+######################################################################
+## nic_nsupdate_update
+######################################################################
+sub nic_nsupdate_update {
+ debug("\nnic_nsupdate_update -------------------");
+
+ ## group hosts with identical attributes together
+ ## my %groups = group_hosts_by([ @_ ], [ qw(login password server wildcard
mx backupmx) ]);
+
+ ## each host is in a group by itself
+ my %groups = map { $_ => [ $_ ] } @_;
+
+
+ ## update each set of hosts that had similar configurations
+ foreach my $sig (keys %groups) {
+ my @hosts = @{$groups{$sig}};
+ my $hosts = join(',', @hosts);
+ my $h = $hosts[0];
+ my $dnsserver = $config{$h}{'server'};
+ my $dnsttl = $config{$h}{'ttl'};
+ my $dnszone = $config{$h}{'zone'};
+ info("setting IP address to %s for %s", $ip, $hosts);
+ verbose("UPDATE:","updating %s", $hosts);
+
+ my $url;
+ $url = "server $dnsserver\n";
+ $url .= "zone $dnszone\n";
+ $url .= "update delete $hosts.$dnszone\n";
+ $url .= "update add $hosts.$dnszone $dnsttl A $ip\n";
+ $url .= "send\n";
+
+ my $command;
+
+ if (opt('debug')) {
+ $command = "/usr/bin/nsupdate -d -k $config{$h}{'password'} ";
+ } else {
+ $command = "/usr/bin/nsupdate -k $config{$h}{'password'} ";
+ }
+ verbose("UPDATE:","Bind Command is :%s", $command);
+ verbose("UPDATE:","Bind Arguments is :%s", $url);
+
+ my $status = pipecmd($command,$url);
+
+
+
+ if ($status eq 1) {
+ $config{$h}{'ip'} = $ip;
+ $config{$h}{'mtime'} = $now;
+ success("updating %s: %s: IP address set to %s", $h, $status, $ip);
+ } else {
+ failed("updating %s", $h );
+ }
+
+ }
+}
+######################################################################
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=399427
|