--- check_dns.c.old 2004-11-17 13:18:35.000000000 -0700 +++ check_dns.c 2004-11-17 12:53:21.000000000 -0700 @@ -38,6 +38,7 @@ #define ADDRESS_LENGTH 256 char query_address[ADDRESS_LENGTH] = ""; char dns_server[ADDRESS_LENGTH] = ""; +int dns_server_port = 53; char ptr_server[ADDRESS_LENGTH] = ""; int verbose = FALSE; char expected_address[ADDRESS_LENGTH] = ""; @@ -76,7 +77,7 @@ } /* get the command to run */ - asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server); + asprintf (&command_line, "%s %s %s -port=%d", NSLOOKUP_COMMAND, query_address, dns_server, dns_server_port); alarm (timeout_interval); gettimeofday (&tv, NULL); @@ -275,6 +276,7 @@ {"timeout", required_argument, 0, 't'}, {"hostname", required_argument, 0, 'H'}, {"server", required_argument, 0, 's'}, + {"port", required_argument, 0, 'p'}, {"reverse-server", required_argument, 0, 'r'}, {"expected-address", required_argument, 0, 'a'}, {"expect-authority", no_argument, 0, 'A'}, @@ -289,7 +291,7 @@ strcpy (argv[c], "-t"); while (1) { - c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index); + c = getopt_long (argc, argv, "hVvAt:H:p:s:r:a:", long_opts, &opt_index); if (c == -1 || c == EOF) break; @@ -316,6 +318,9 @@ die (STATE_UNKNOWN, _("Input buffer overflow\n")); strcpy (query_address, optarg); break; + case 'p': /* hostname */ + dns_server_port = atoi(optarg); + break; case 's': /* server name */ /* TODO: this is_host check is probably unnecessary. */ /* Better to confirm nslookup response matches */ @@ -403,6 +408,8 @@ The name or address you want to query\n\ -s, --server=HOST\n\ Optional DNS server you want to use for the lookup\n\ +-p, --port=HOST\n\ + Optional DNS server port, defaults to 53\n\ -a, --expected-address=IP-ADDRESS\n\ Optional IP address you expect the DNS server to return\n\ -A, --expect-authority\n\ @@ -426,7 +433,7 @@ print_usage (void) { printf (_("\ -Usage: %s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n\ +Usage: %s -H host [-s server] [-p port] [-a expected-address] [-A] [-t timeout]\n\ %s --help\n\ %s --version\n"), progname, progname, progname); }