HowTo Test or Check Reverse DNS on a Linux / Unix

I am a new Linux and Unix command line user. How do I test or check reverse DNS for given IP address under Linux, OS X, BSD, Unix-like or Windows XP/Server 2003 based systems?

Reverse DNS lookup (also known as rDNS) is a process to determine the hostname associated with a given IP address.

Typically, the DNS is used to determine what IP address is associated with a given hostname; so to reverse resolve a known IP address is to lookup what the associated hostname for it. A reverse lookup is often referred to simply as reverse resolving, or more specifically reverse DNS lookups.

Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time 1m
[/donotprint]The most common uses of the reverse DNS are:
  1. Anti-spam
  2. Network troubleshooting
  3. Avoid spammers and phishers using a forward confirmed reverse DNS etc

You can use standard UNIX / Linux utilities such as nslookup command, dig command or host command to find out reverse DNS of a given IP address.

Task: Find Reverse DNS for IP under Linux/UNIX

Type the following host command:
$ host ip-address-here
$ host

Sample outputs: domain name pointer

In this example output, IP is reverse mapped to Here is another reverse lookups done using dig command:
$ dig -x ip-address-here
$ dig -x

Sample outputs:

; > DiG 9.8.3-P1 > -x
;; global options: +cmd
;; Got answer:
;; ->> 20975 IN	PTR

;; Query time: 32 msec
;; WHEN: Sat Feb  8 04:40:28 2014
;; MSG SIZE  rcvd: 76

Hiding additional display info while doing reverse ip lookup using dig command

You can only display the answer section of a reply with +answer option and clear all other display info with +noall option as follow:

dig +noall +answer -x

Sample outputs: 80127 IN	PTR

Task: Find Reverse DNS for IP under Linux/UNIX/Windows

nslookup works under Windows and UNIX like oses:
nslookup ip-address-here



Non-authoritative answer:      name =

Authoritative answers can be found from:

Demo: Reverse IP lookup on Linux, Unix, OS X and MS-Windows

Animated gif: host, dig, and nslookup command in action

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 22 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
22 comments… add one
  • Sha8e Sep 29, 2007 @ 14:22


    How r u man?
    Vivek, how can I do a reverse ip check to a domain or box in order to know what websites is hosted on that box ?

    I need a linux COMMAND not solving it using a website. Can u help me ?

  • Mohammad Mateen Mar 13, 2008 @ 9:25

    its very simple

    dig -x IP (

  • Paul Seminario Jul 13, 2009 @ 2:47

    Hi… Please help me… Can u tell me a commands to make a reverse dns record in my server?
    Paul S.

  • Wisut Petsakul Aug 4, 2009 @ 9:03

    Very userful , Thanks.

  • mccalni Dec 21, 2009 @ 11:26

    Excellent. Thank you.

  • Nime Jun 3, 2010 @ 22:10

    @echo off

    REM //NSLOOKUP batch check utility v1.0
    REM //Author: Emin Akbulut
    REM //Date: 03 June 2010
    REM //This code is freeware
    REM //Usage: Modify the DNS and host lists below, at line 23, then simply run the batch file.

    SET timeout=5

    IF “%1” == “/check” GOTO loopit

    if exist %0.log del %0.log > nul %2>nul
    if exist %0.bat.log del %0.bat.log > nul %2>nul
    echo —————————————
    echo Starting… %date% %time:~0,8%
    echo —————————————
    echo Report created on %date% %time:~0,8% >> %0.log
    REM %%A for DNS Servers list, %%B for target hosts to be checked
    FOR %%A IN ( DO FOR %%B IN ( DO CALL %0 /check %%A %%B

    echo ————————————— >> %0.log
    echo —————————————
    echo Done. Press any key to examine the log file…
    Pause > nul
    start notepad “%~0.log”
    GOTO done

    echo ————————————— >> %0.log
    echo nslookup %3 %2
    echo nslookup %3 %2 >> %0.log
    nslookup -timeout=%timeout% %3 %2 >> %0.log 2>nul


  • michal Jul 14, 2010 @ 12:33

    nslookup has been obsolete for loooong time. I advise to not to waste your precious time learning utility, that is not supported any more.

  • Mpho Oct 26, 2010 @ 13:54

    Please tell me how do i monitor DNS, DHCP, Wins on my server

  • Nime Oct 26, 2010 @ 15:05

    To monitor DNS you may use my script.

    To test DHCP LOCALLY, the commands to inspire are:

    REM Set automatic IP
    netsh interface ip set address name=”LAN” dhcp
    REM Set automatic DNS
    netsh interface ip set dns “LAN” dhcp

    I don’t know much about WINS…

  • techie talks Mar 4, 2011 @ 1:37

    dig -x is good enough. Thanks!

  • J_S_P May 24, 2011 @ 17:36

    This might be silly… but I have to ask!

    So the output is “ domain name pointer”

    Is “” the CNAME in this case? If you look up other IP’s you get crazy outputs with dashes and long names which look like a CNAME. Is it too redundant to have yet another reverse entry for a CNAME?

    • 🐧 nixCraft May 24, 2011 @ 19:25

      No that is actual reverse entry. Our IP was changes some time ago. To get desired output try

       host domain name pointer
  • Rocky Jun 14, 2011 @ 14:50

    Hi Vivek,

    for reverse lookup, do i need to provide domain name or hostname of my server to my isp from which i got public ip?
    Domain name is
    hostname is


  • Digital Extreme Media Group Jul 11, 2011 @ 23:34

    Thanks for sharing. This is a good way to see if your ns1. and ns2 are set correctly.

  • Akula Aug 14, 2011 @ 8:33


    Can you please tell me how to create this reverse to records? I have 2 dedicated servers, 203.230 (ns1) / 200.254 (ns2), from localhost command ‘nslookup ip’ reply’s succes but from internet still not working, can you please create an full example?

    Kind Regards

    • David Amormino Sep 27, 2011 @ 2:15

      This bash example should print all the hosts from throught .254. (You could edit the IP address lines to suit your network, perhaps.)


      I use this to generate rdns (reverse dns) files for my bind9 name server:

      bash >> /etc/bind/db.192

      I still need to put the correct lines in at the top of the db.192 file (from db.empty), but it accomplishes most of what I am after.

      • Jesse Bethke May 18, 2015 @ 17:04

        *Borrowing* Thanks!

    • DotMG Sep 27, 2011 @ 7:56

      As far as I know, the fastest and simplest way to set rDNS is to ask your Server Provider. They do it manually.

  • Akula Sep 27, 2011 @ 12:09

    You are right only the provider can create rdns.

    Thank You

  • Tommy Joe Feb 7, 2012 @ 22:37

    I have been asked to check our own DNS and WINS servers to make sure we have all the correct controller details for the ???? Domain are present.
    Reason is We are currently arranging to move the PDC emulator role this week from IC?????? to BD??????

  • Bob Pelerson Dec 27, 2012 @ 18:40

    note that you can use drill or dig on BSD too – not just Linux

  • Waqas Apr 16, 2013 @ 4:14

    Q1) I want to block the users to access the website for some user and only for a time while like 1/3 it is possible?
    Q2) other user can not use the internet I want to block the internet of the it is possible?
    Q3) some user can open only permission webistes which I want to allow them like google/gmail/hotmail etc etc but can not access the yahoo/wwe it is possible?
    Q4) how to block the USB storage devices in Win Xp because when we make a policy to remove all storage device deny all then the option shows that atleast Win Vista. what does it mean?
    Q5) how DNS can take direct IP in the forward and reverse zone?
    Q6) why we use router in DHCP server?
    Q7) I saw if someone is uses in DNS server
    DNS IP
    subnet mask
    default gateway
    preferred DNS
    alternate DNS
    then it uses in DHCP server
    router IP
    why it uses this IP only in the router?why DHCP server can not validate the alternate DNS when we install the DHCP server?
    Q8) I want to allow only 2 user they can change the time and it is possible?

    give me the full description on my email id
    with each step should be mention in the snapshot
    thank you
    for an advance to help me

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum