dnsname — look up the domain name(s) of an IP address


dnsname {addr...}


dnsname looks up PTR resource records, for the reverse-lookup domain name corresponding with addr, in the Domain Name System and prints (only) the first domain name of addr on a single line. If addr has no domain names, dnsname prints a blank line. You can list several addrs; dnsname prints each result on a separate line.

Note that the DNS protocol itself makes no guarantee of any particular ordering within a PTR resource record set. If there are multiple PTR resource records, what name is the first is determined by the actions of the content DNS server, what proxy DNS servers are in the path, and the local DNS client library; and is unspecified.

Normally dnsname exits 0. If it encounters a temporary problem that prevents it from determining the list of IP addresses, it prints an error message and exits 111.

dnsname makes all DNS lookups using the locally configured DNS proxy server. See dnsqr(1) for how this server is found.

See also


a similar tool that prints all of the domain names


a filter that looks up the domain name(es) for multiple IP addresses in parallel


dnsname was originally part of Daniel J. Bernstein's djbdns toolset in 1999.


Original code and documentation by Daniel J. Bernstein. Documentation modernizations by Jonathan de Boyne Pollard.