What's the reverse DNS command line utility?

Solution 1:

dig and host should be what you're looking for ;)


On *nix system you can do this command : dig -x [address]

Alternatively you can add +short at the end of the dig command to output only the dns result.

On Windows, use nslookup

EDIT : nslookup work too on *nix systems. More infos on nslookup command whether it seems to have been replace since a while now : http://linuxreviews.org/man/nslookup/

Solution 2:

On *nix you can use:

dig -x [address]

Solution 3:

On most of the Linux systems that I am aware of you can use:

 nslookup <ip-number EX:>

will work on the command line.

Come to think of it, isn't nslookup available on Windows XP?

Solution 4:

Try "host"

  • Forward lookup with host:

    $ host google-public-dns-b.google.com.
    google-public-dns-b.google.com has address
    google-public-dns-b.google.com has IPv6 address 2001:4860:4860::8844
  • Reverse lookup with host:

    $ host domain name pointer google-public-dns-b.google.com.

Similar to dig

  • Forward lookup with dig:

    $ dig google-public-dns-b.google.com. +short
  • Reverse lookup with dig:

    $ dig -x +short

Try "rdt"

It takes a little more setup. But if you do this, then you can run this "rdt" PHP script from the command line and it's quite wonderful. It does a few back and forth trips between forward and reverse lookups.

Download from here: https://github.com/grawity/code/blob/master/net/rdt

Example. This is what it looks like when it's working:

$ rdt google-public-dns-b.google.com.
google-public-dns-b.google.com. = 2001:4860:4860::8844,
   2001:4860:4860::8844 = dns.google
      dns.google = 2001:4860:4860::8844, 2001:4860:4860::8888,,
         2001:4860:4860::8888 = dns.google = dns.google = dns.google

Solution 5:

This question already has a million answers, but I'm gonna add another one. Here's a little function I wrote for easily doing reverse DNS with dig. Add this to your ~/.bashrc file, reload your shell, and then you can do reverse DNS lookups with revdns

function revdns() {

    # split the IP address into an array of octets
    IFS="." read -r -a octets <<< "$1"

    # add each octet to our $addr string in reverse order
    for octet in "${octets[@]}"; do

    # run a DNS pointer lookup with dig
    # `+short` makes dig's output very terse (un-verbose)
    # `"${@:2}"` passes any extra params from this command to dig
    dig ptr +short $addr "${@:2}"

Reverse DNS lookups are done by checking the pointer (PTR) records. If you wanna do reverse DNS for "", you have to lookup pointer records for "". My function takes in an IP address, reverses the order of the octets (i.e. changes it from to, and then uses dig to execute the PTR lookup I just described.

You can, of course, just use nslookup if you have it, but I prefer this dig-based solution because it uses the OS' DNS servers instead of nslookup-provided ones (if you want, by the way, you can add additional dig flags when you call revdns, and they will get passed to dig)