From owner-freebsd-bugs Mon Nov 26 15:10:27 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id DDA2B37B421 for ; Mon, 26 Nov 2001 15:10:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fAQNA1l67292; Mon, 26 Nov 2001 15:10:01 -0800 (PST) (envelope-from gnats) Received: from tomts14-srv.bellnexxia.net (tomts14.bellnexxia.net [209.226.175.35]) by hub.freebsd.org (Postfix) with ESMTP id E060437B41B for ; Mon, 26 Nov 2001 15:08:17 -0800 (PST) Received: from khan.anarcat.dyndns.org ([65.94.177.56]) by tomts6-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20011126225911.BMMD9997.tomts6-srv.bellnexxia.net@khan.anarcat.dyndns.org> for ; Mon, 26 Nov 2001 17:59:11 -0500 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id F245518D3 for ; Mon, 26 Nov 2001 18:01:44 -0500 (EST) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id 0DE1120ACB; Mon, 26 Nov 2001 18:00:38 -0500 (EST) Message-Id: <20011126230038.0DE1120ACB@shall.anarcat.dyndns.org> Date: Mon, 26 Nov 2001 18:00:38 -0500 (EST) From: The Anarcat Reply-To: The Anarcat To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/32318: no userland tool available to test resolver facilities Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 32318 >Category: bin >Synopsis: no userland tool available to test resolver facilities >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Nov 26 15:10:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: The Anarcat >Release: FreeBSD 4.4-STABLE i386 >Organization: Nada, Inc. >Environment: System: FreeBSD shall.anarcat.dyndns.org 4.4-STABLE FreeBSD 4.4-STABLE #0: Fri Nov 16 12:57:38 EST 2001 anarcat@shall.anarcat.dyndns.org:/usr/obj/usr/src/sys/SHALL i386 >Description: Traditionally, since BIND has been part of FreeBSD for a good while, a few basic tools are available to query the DNS servers configured on a machine. However, no tool is available to query the resolver (in the sense of gethostbyname/addr() routines) transparently. Host(1), dig(1), nslookup(1) all use the name servers, and not the /etc/hosts files or NIS/YP. >How-To-Repeat: Try to do a address to hostname lookup using a command line tool for an address in /etc/hosts that will actually use gethostbyname(3). I don't know of any such tool and a post on -questions didn't yield anything better. >Fix: Possible implementation of a iplookup tool. Chris J. Clark sent code to freebsd-questions, for a tool that would to reverse lookups with gethostbyaddr(3). I hacked it a bit to lookup names -> addresses in case the address isn't parsable. See: Message-ID: <20011126010753.E222@gohan.cjclark.org> on -questions for the original code. /* * Copyright (c) 2001 Crist J. Clark * $Id: iplookup.c,v 1.2 2001/11/26 22:01:40 anarcat Exp $ */ #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { struct hostent *h; struct in_addr a; int i, name_l; char addr[24]; char **p; for (i = 1; i < argc; i++) { if (name_l = (inet_aton(argv[i], &a) == 0)) { h = gethostbyname(argv[i]); } else { h = gethostbyaddr((char *)&a, sizeof a, AF_INET); } if (h == NULL) errx(EX_OSERR, "address, %s, failed: %s", argv[i], hstrerror(h_errno)); if (name_l) { printf("%s: ", h->h_name); a.s_addr = inet_addr(h->h_addr); for (p = h->h_addr_list ; p != NULL && *p ;) { addr[0] = '\0'; inet_ntop(h->h_addrtype, *p, addr, sizeof addr); printf("%s",addr); if (++p != NULL && *p) { printf(", "); } } printf("\n"); } else { printf("%s: %s\n", argv[i], h->h_name); } for (p = h->h_aliases; p != NULL && *p; p++) printf("\t%s\n", *p); } return 0; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message