DDNS feature request with patch
Ferenc Kiraly
feri at feridot.com
Sun Apr 18 12:16:33 UTC 2004
Hi!
I have a delegated DNS subdomain according to RFC2317, where the reverse
lookup zone name looks like "192-255.1.168.192.in-addr.arpa". As far as
I can see, I cannot use the DHCP server's DDNS feature to update records
in this kind of zone, because I have no way of specifying the correct
reverse domain name. The current implementation appends a given string
(default is ".in-addr.arpa") to the reversed IP address of the client,
to form something like this: "193.1.168.192.in-addr.arpa".
I need DDNS updates for this kind of domains quite badly, so I added a
boolean option called "ddns-rev-domainname-replace", which causes only
the last octet of the IP address of the client to be used instead of the
entire reversed IP address. So a DDNS update correctly applies for a PTR
record of the form "193.192-255.1.168.192.in-addr.arpa".
Of course this feature can be expanded to use more (or less) than one
octet, according to the netmask, but one octet works fine for me for
now. If this patch sounds reasonable enough for inclusion into the DHCP
server, I would be willing to spend the effort to make the patch acceptable.
feri.
The patch follows:
------------------- snip ----------------------------------------------
diff -urN dhcp-3.0.1rc13.orig/includes/dhcpd.h
dhcp-3.0.1rc13/includes/dhcpd.h
--- dhcp-3.0.1rc13.orig/includes/dhcpd.h 2003-02-10 02:22:46.000000000 +0100
+++ dhcp-3.0.1rc13/includes/dhcpd.h 2004-04-18 13:27:14.000000000 +0200
@@ -421,6 +421,7 @@
#define SV_LOG_FACILITY 44
#define SV_DO_FORWARD_UPDATES 45
#define SV_PING_TIMEOUT 46
+#define SV_DDNS_REV_DOMAIN_NAME_REPLACE 47
#if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1
diff -urN dhcp-3.0.1rc13.orig/server/ddns.c dhcp-3.0.1rc13/server/ddns.c
--- dhcp-3.0.1rc13.orig/server/ddns.c 2002-11-17 03:29:30.000000000 +0100
+++ dhcp-3.0.1rc13/server/ddns.c 2004-04-18 13:33:00.000000000 +0200
@@ -471,6 +471,8 @@
/*
* Compute the reverse IP name.
*/
+ s1 = s2 = 0;
+
oc = lookup_option (&server_universe, state -> options,
SV_DDNS_REV_DOMAIN_NAME);
if (oc)
@@ -480,7 +482,39 @@
state -> options,
&lease -> scope, oc, MDL);
- if (oc && s1) {
+ oc = lookup_option (&server_universe, state -> options,
+ SV_DDNS_REV_DOMAIN_NAME_REPLACE);
+ if (oc)
+ s2 = evaluate_boolean_option_cache (&ignorep, packet, lease,
+ (struct client_state *)0,
+ packet -> options,
+ state -> options,
+ &lease -> scope, oc, MDL);
+
+ if (s1 && s2) {
+ /* Buffer length:
+ * XXX.<ddns-rev-domain-name>\0
+ * where XXX is the last octet of the IP */
+ buffer_allocate (&ddns_rev_name.buffer,
+ d1.len + 5, MDL);
+ if (ddns_rev_name.buffer) {
+ ddns_rev_name.data = ddns_rev_name.buffer -> data;
+#ifndef NO_SNPRINTF
+ snprintf ((char *)ddns_rev_name.buffer -> data, 17,
+ "%d.", lease -> ip_addr . iabuf[3]);
+#else
+ sprintf ((char *)ddns_rev_name.buffer -> data,
+ "%d.", lease -> ip_addr . iabuf[3]);
+#endif
+ ddns_rev_name.len =
+ strlen ((const char *)ddns_rev_name.data);
+ data_string_append (&ddns_rev_name, &d1);
+ ddns_rev_name.buffer -> data
[ddns_rev_name.len] ='\0';
+ ddns_rev_name.terminated = 1;
+ }
+
+ data_string_forget (&d1, MDL);
+ } else if (s1) {
/* Buffer length:
XXX.XXX.XXX.XXX.<ddns-rev-domain-name>\0 */
buffer_allocate (&ddns_rev_name.buffer,
diff -urN dhcp-3.0.1rc13.orig/server/stables.c
dhcp-3.0.1rc13/server/stables.c
--- dhcp-3.0.1rc13.orig/server/stables.c 2003-02-10 02:22:54.000000000 +0100
+++ dhcp-3.0.1rc13/server/stables.c 2004-04-18 13:28:26.000000000 +0200
@@ -492,7 +492,7 @@
{ "log-facility", "Nsyslog-facilities.", &server_universe, 44 },
{ "do-forward-updates", "f", &server_universe, 45 },
{ "ping-timeout", "T", &server_universe, 46 },
- { "unknown-47", "X", &server_universe, 47 },
+ { "ddns-rev-domainname-replace", "f", &server_universe, 47 },
{ "unknown-48", "X", &server_universe, 48 },
{ "unknown-49", "X", &server_universe, 49 },
{ "unknown-50", "X", &server_universe, 50 },
More information about the dhcp-hackers
mailing list