nsupdate hack, all-encompassing dynamic domain

brian-bind at stech.cx brian-bind at stech.cx
Sat Apr 8 03:34:46 UTC 2000


Hello everyone...

I've gotten bored and made an nsupdate hack, patch following, which allows one
to pick a nameserver to send updates to, but am not quite sure if there's a
better way to do it.  Anyone?

Also, is there a way to make an all-encompassing domain without killing lookups
from clients to far-away nameservers?  (Situation: I only have one server, and
must use it for DNS resolution for my behind-the-firewall computers.  However,
I must also be able to use the above nsupdate to create/modify/delete ANY
domain, as I'm working on the new version of DynDNS, which will hopefully
automate the domain-adding process)

-Brian

nsupdate patch:

--- nsupdate.c  Tue Oct 19 18:22:59 1999
+++ nsupdate.c.new      Fri Apr  7 23:32:18 2000
@@ -167,12 +167,11 @@
        ns_tsig_key key;
        char *keyfile=NULL, *keyname=NULL, *p, *pp;
        int file_major, file_minor, alg;
-
-
+       char *forced_server_addr = NULL;
 
        progname = argv[0];
 
-       while ((c = getopt(argc, argv, "dsvk:n:")) != -1) {
+       while ((c = getopt(argc, argv, "dsvk:n:a:")) != -1) {
                switch (c) {
                case 'v':
                        vc = 1;
@@ -199,6 +198,9 @@
                 case 'n':
                        keyname=optarg;
                        break;
+                case 'a':
+                       forced_server_addr = optarg;
+                       break;
                default:
                        usage();
                }
@@ -581,6 +583,11 @@
                APPEND(listuprec, rrecp, r_link);
            } else { /* end of an update packet */
                (void) res_ninit(&res);
+
+               /*  I'm guessing the above sets the nameserver, etc, so this goes here:  */
+               if (forced_server_addr != NULL)
+                       res.nsaddr.sin_addr.s_addr = inet_addr(forced_server_addr);
+
                if (vc)
                    res.options |= RES_USEVC | RES_STAYOPEN;
                if (debug)
@@ -606,7 +613,7 @@
 
 static void
 usage() {
-       fprintf(stderr, "Usage: %s [ -k keydir:keyname ] [-d] [-v] [file]\n",
+       fprintf(stderr, "Usage: %s [ -k keydir:keyname ] [-d] [-v] [file] [-a nameserver]\n",
                progname);
        exit(1);
 }



More information about the bind-users mailing list