Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know it is possible to resolve IP addresses to host names but can IPs be resolved to domain names?

share|improve this question
up vote 23 down vote accepted

Yes, you can (sometimes) resolve an IP Address back to a hostname.

Within DNS, an IP Address can be stored against a PTR record. You can use nslookup to resolve both hostnames and IP addresses, though use of nslookup has been deprecated for quite some time.

For best results, you should really get a hold of the dig tool. If you're a linux user, this is available as part of dnsutils (debian), or similar package. If you're a windows user, you can follow instructions such as these to install dig.

You can then do:

dig A <hostname>

To lookup the IPv4 address for a host, or:

dig AAAA <hostname>

To lookup the IPv6 address for a host, or:

dig PTR

To lookup the hostname for IPv4 address WWW.XXX.YYY.ZZZ (note the octets are reversed), or:

dig PTR

To get the hostname for the IPv6 address 2001:db8::567:89ab.

share|improve this answer
Just figured it'd be good to mention: When you ask a DNS server to resolve an IP to a hostname, the technical name for it is a reverse lookup. – LawrenceC Jul 27 '11 at 11:12
Indeed - the reverse lookup is achieved via a PTR Resource Record, PTR being shorthand for pointer. – Mike Insch Jul 27 '11 at 11:18
What's wrong with dig -x <ipaddress>? On my Linux system, it speaks both IPv4 and IPv6. dig -x and dig -x fe80::1. – Michael Kjörling Jul 27 '11 at 11:22
@hyperslug, ping's -a option is listed as Resolve addresses to hostnames on Win7 at least, so I don't see why it wouldn't work. However, nslookup or even better dig are actually meant for things like this. Ping isn't. – Michael Kjörling Jul 28 '11 at 6:26
@TheLQ: I quote from the BIND 9.4 Administrators Reference Manual, "Due to its arcane user interface and frequently inconsistent behavior, we do not recommend the use of nslookup. Use dig instead.". In many cases, use of nslookup also results in "nslookup is deprecated and may be removed from future releases. Consider using the dig or host programs instead". Google could easily have informed you of this had you cared to look. – Mike Insch Aug 1 '11 at 17:15

nslookup <ipaddress> or nslookup <hostname>

share|improve this answer

You can use nslookup, dig, or other network tool to possibly get a domain name for an IP address, but it's not necessarily going to be the one you're expecting.

Unlike normal DNS lookups, where many names can resolve to a single IP address, reverse DNS lookups can only resolve to a single name, and that's handled by whomever controls the reverse DNS information for the IP block in question. Nobody else can set up a PTR record on a random IP address block. This is in contrast to "normal" DNS lookups, where anyone can set up a domain name and create A records pointing at whatever IP addresses they'd like.

This ServerFault question has a bit more info on this topic.

My point is that just because you can do it doesn't mean that you'll get what you're expecting or that it will be useful.

share|improve this answer
+1: This had to be said. Often for well-known internet sites where the A record and the PTR record are both under control of the same person, the PTR record still refers to some internal machine name. The PTR record may also be nonexistant, for example if you try to dig then dig -x one of the IP addresses that maps to. – Ken Bloom Jul 27 '11 at 14:03
It should be said that a common situation is shared servers, where the reverse lookup will be the domain assigned by whatever company owns the server. Or, for shared IPs, whatever company owns the ISP. for example, if you do a reverse lookup on a website's IP, you might get something odd like "". You're probably seeing a shared server. If you do a reverse on a random IP, you might see something like "". This is an IP belonging to, an ISP, so it must be some random home user. – jcrawfordor Aug 16 '11 at 7:57
There is no technical limit on how many PTR records a single IP address can resolve to; the one PTR is just a convention (also security/privacy reasons). – grawity Aug 21 '11 at 20:35

Another way to "resolve" IP-addresses to hostnames is possible using the bing search engine. If the host runs a public webserver and some sites served by the host are indexed, you can query it using the ip: prefix.

Just enter ip: into the search form to get a list of hostnames behind that ip.

share|improve this answer

You can get the host name either IPv4 or IPv6 address by making use of the gethostbyaddr() function in sockets.



share|improve this answer

How about host? I use it on a daily basis at work

#host has address mail is handled by 5 mail is handled by 10 mail is handled by 15

#host domain name pointer
share|improve this answer
But this is for Linux. – Boris_yo Sep 6 '11 at 17:56
@boris_yo, here is one for windows:… - I know there is a better one out there, I just need to find it. – MaQleod Sep 6 '11 at 18:21
Thanks. I will find by myself later. – Boris_yo Sep 7 '11 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .