• United States
Unix Dweeb

Using the Linux host command to dig out DNS details

Feb 17, 20225 mins

The Linux host command can retrieve a lot of useful information from the domain name service, but has a lot of options that you need to understand to get started.

global communication network concept smart city internet of things picture id1152954877
Credit: iStock

The host command on Linux systems can look up a variety of information available through the Domain Name System (DNS). It can find a host name if given an IP address or an IP address if given a host name plus a lot of other interesting details on systems and internet domains.

The first query below tells us that the system associated with the address is named “dragonfly”. The second tells us that is the default router.

$ host domain name pointer dragonfly.
$ host domain name pointer router.

To do the reverse, you can use commands like these:

$ host dragonfly
dragonfly has address
$ host router
router has address

These commands were run on my home network, and they only show a small part of the information that the host command can retrieve.

Viewing the host command’s options

Any time you type “host” with no additional arguments, you will see the available command options with a brief explanation of each.

Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] [-m flag] [-p port] hostname [server]
       -a is equivalent to -v -t ANY
       -A is like -a but omits RRSIG, NSEC, NSEC3
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -m set memory debugging flag (trace|record|usage)
       -N changes the number of dots allowed before root lookup is done
       -p specifies the port on the server to query
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -s a SERVFAIL response should stop query
       -t specifies the query type
       -T enables TCP/IP mode
       -U enables UDP mode
       -v enables verbose output
       -V print version number and exit
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only

For almost every option, you need to supply additional information—a host name, an IP address, a domain name, or maybe some additional data to describe what you are looking for. The only option that will NOT simply provide the list shown above when no argument is provided is the -V option which reports the version information for the command itself.

$ host -V
host 9.16.24-RH

Now let’s look at some of the other useful information that the command can provide.

IP addresses

Some important details for a specific domain can be retrieved using just the domain name:

$ host has address has address has address has address mail is handled by 0

We can see that this domain employs multiple servers as is common among many commercial sites.

Verbose report

If you add the -v (verbose) option, you will see a lot of additional details. For, we would see 33 lines of output if the head command didn’t limit this to the top ten lines.

$ host -v | wc -l
$ host -v | head -10
Trying “”
;; ->>HEADER

You can, however, always pass the host command’s output to grep to pare it down to just what you want to see.

Mail exchange (MX)

To focus on the mail exchange (MX) records, you could use a command like this:

$ host -v | grep MX
;                   IN      MX            2189    IN      MX      0

Alternately, you can retrieve MX records using the host command’s -t (type) mx option:

$ host -t mx mail is handled by 0

SOA records

To focus on SOA (start of authority) records, you can use a command like this one:

$ host -v | grep SOA            342     IN      SOA 2021092901 28800 7200 604800 600

Alternately, you can also use a command like this with the -t (type) SOA option:

$ host -t SOA has SOA record 2022021100 1800 900 1209600 86400


To see CNAME (canonical name) records, you can use a command like this one that tells you that is an alias for Google’s mail server:

$ host -t cname is an alias for

Name server

In the command below, we are just looking for name servers using the ns type with the host command:

$ host -t ns name server name server name server name server name server name server


The host command has so many options that it may take a while to get used to them and decide which are the most useful. They can be very handy depending on what you are looking for from the vast DNS knowledge bank.

Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author