hosted by liquidweb

Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Hosting Talk Tutorials : Hosting Security and Technology Tutorials : Fun with DNS: Three Useful Commands

Forum Jump

Fun with DNS: Three Useful Commands

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
Send news tip View All Posts Thread Tools Search this Thread Display Modes
Junior Guru Wannabe
Join Date: Mar 2005
Posts: 72

Fun with DNS: Three Useful Commands


These days most people manage their hosting using powerful and easy-to-use control panels that automate most tasks. But for some things, it is hard to beat the power of the command-line. These DNS commands are powerful tools, and this article should provide you enough information to get you started or offer a quick refresher if you already use these commands.

The Domain Name System (DNS) is a distributed, hierarchical database where authority flows from the top (or root) of the hierarchy downward. When thinking of the structure of the DNS, imagine an inverted tree. Each branch of the tree is within a zone of authority; however, multiple branches of the tree can be within a single zone.

The software (Bind being the most common) that stores domain name information is called a domain name server. A single name server can be authoritative for multiple zones. All zones have a primary master and a secondary master name server that provides authoritative responses for their zones.

If you query a name server not authoritative for a particular zone, that name server will most likely have up-to-date information. This is because zone information propagates throughout the Internet at regular intervals, and name servers cache zone information for which they are not authoritative.

DNS Commands

There are three crucial commands that can put all the DNS information you need at your fingertips. The way to use this article is to try each of the commands listed on a domain name, so you can see what the output looks like. Learn by doing.

Zone file database records divide DNS information into three primary types: NS (Name Server) records, MX (Mail Exchange) records, and A (Address) records. NS records indicate the name servers. MX records indicate the hosts that handle email delivery; the priority (pri) number indicates the order in which mail servers are used, with the lowest number receiving the highest priority. The A (Address) records map hostnames to IP addresses, the real names of machines.


This is the simplest of the DNS commands. It is a quick way to determine the IP address of a hostname:

:~$ host
The -a option will return all of the DNS information in verbose format:

:~$ host -a
Now that you know the IP address for, try a reverse lookup:

:~$ host <IP address>
dig (domain information groper)

This command gathers and returns DNS information in a format the name server can use directly. You will find it easy to query specific name servers with dig.

You can quickly determine the Name servers of your host or any other host:

:~$ dig ns
Then you check your (or another) website against the host's name servers:

:~$ dig
Dig can provide output that is in the same format as the zone file itself. Here is how to get the whole zone file:

:~$ dig any
Here are the most useful dig query types: dig any (gathers all DNS information), dig ns (gathers name server information), dig mx (gathers mail exchanger information) and dig a (gathers network address information).

The dig command can also do reverse lookups with output formatted for the zone file:

:~$ dig -x <IP Address>

You can use this tool as a single line command, or you can use it interactively, which distinguishes it from the other DNS commands. Once you have started nslookup, type set all to list the default options. As with dig you can choose the server (name server) you want to query, and you can decide the type of DNS information on which to focus.

Just as you can issue commands to nslookup interactively, you can also change the initial defaults by starting a .nslookuprc file. The format of the .nslookup is one command per line:

set type=NS
set timeout=10


Understanding the Internet requires a solid working knowledge of the Domain Name System. One way to increase your knowledge is to regularly use the three commands outlined in this article: host, dig, and nslookup.

Try the StreamSend Email Marketing Service. StreamSend is a permission-based email marketing service that offers both a private label reseller program and an affiliate program.

Sponsored Links
Join Date: Aug 2005
Posts: 439
Nice tutorial, thanks for posting this. One of the first things you learn in this business is that so many issues come down to one thing: DNS, DNS, DNS. With just a little knowledge of DNS, the most seemingly complex issues can be uncovered almost immediately. I also find the online DNS utility websites very handy (such as dnsstuff), as they can give an excellent alternate perspective when DNS information is being cached on your end by your ISP. There are utilities of course that can do non cached lookups, dnstracer being one of them.


Related posts from
Title Type Date Posted
Docker Buys Kitematic, a Startup Focused on Making it Easy to Run Docker on Macs Web Hosting News 2015-03-12 09:10:10
Another Xen Hypervisor Security Issue Pushes AWS, Rackspace to Reboot Cloud Servers Web Hosting News 2015-02-27 14:25:07
DIY Website Builder Launches Integrated Email Newsletter Tool Web Hosting News 2014-07-10 11:51:24
Facebook's Recently Acquired Mobile App Platform Parse Launches Web Hosting for Developers Web Hosting News 2013-05-08 10:49:17
Host Europe Group Launches Domain Management Service for SMEs Web Hosting News 2013-04-24 14:31:28

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Log in with your username and password

Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Web Hosting News:
WHT Membership
WHT Membership



Welcome to

Create your username to jump into the discussion! is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.

(4 digit year)

Already a member?