RE: DNS reverse

Glynn Clements (glynn@sensei.co.uk)
Sun, 11 Oct 1998 23:32:16 +0100 (BST)


--pewMm1/jao
Content-Type: text/plain; charset=us-ascii
Content-Description: message body and .signature
Content-Transfer-Encoding: 7bit

Neil Moore-Smith wrote:

> Who actually manages the reverse lookup domains?

Who manages which reverse lookup domains?

> We got a bunch of subnets
> from our ISP, and I set up a primary name server, which works fine. If you
> do a whois query, mine is listed, along with the ISP's, and they do a zone
> transfer every day. So far so good. I also set up ccc.bbb.aaa.in-addr.arpa
> as a primary zone on my name server and maintain it. Are you saying that
> this should be registered? It seems to work, as mail programs that do a
> reverse lookup as an anti-spam check seem to go through OK. Who should it
> be registered with?

All domains need to be delegated by the parent domain, i.e.
ccc.bbb.aaa.in-addr.arpa needs to be delegated by
bbb.aaa.in-addr.arpa.

Use nslookup or dig to locate the nameservers for the domain
bbb.aaa.in-addr.arpa, then ask those nameservers to which nameservers
the ccc.bbb.aaa.in-addr.arpa domain is delegated.

> Second, I always meant to ask someone... how do you do a reverse lookup, to
> find the host and domain name associated with an IP address? I know it can
> be done programatically, but is there a command line utility, like whois?

You can use

nslookup -q=ptr x.x.x.x.in-addr.arpa.

although this will only use DNS (and not /etc/hosts, NIS, etc).

Alternatively, try the attached program.

-- 
Glynn Clements <glynn@sensei.co.uk>

--pewMm1/jao Content-Type: text/plain Content-Description: gethostbyaddr.c Content-Disposition: inline; filename="gethostbyaddr.c" Content-Transfer-Encoding: 7bit

#include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h>

int main(int argc, char **argv) { struct hostent *host; struct in_addr addr;

if (argc != 2) { fprintf(stderr, "Usage: %s <IP address>\n", argv[0]); return 1; }

if (inet_aton(argv[1], &addr) == 0) { fprintf(stderr, "Invalid IP address: %s\n", argv[1]); return 2; }

host = gethostbyaddr((const char *) &addr.s_addr, sizeof(addr), AF_INET); if (!host) { herror("gethostbyaddr"); return 3; }

printf("%s\n", host->h_name);

return 0; }

--pewMm1/jao-- - To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.rutgers.edu