May 1, 2026

DNS Africa Resource Center

..sharing knowledge.

Using the Linux host command to dig out DNS details – Network World

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.

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 192.168.0.18 is named “dragonfly”. The second tells us that 192.168.0.1 is the default router.
To do the reverse, you can use commands like these:

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

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

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.
Now let’s look at some of the other useful information that the command can provide.
Some important details for a specific domain can be retrieved using just the domain name:
We can see that this domain employs multiple servers as is common among many commercial sites.

If you add the -v (verbose) option, you will see a lot of additional details. For networkworld.com, we would see 33 lines of output if the head command didn’t limit this to the top ten lines.
You can, however, always pass the host command’s output to grep to pare it down to just what you want to see.
To focus on the mail exchange (MX) records, you could use a command like this:
Alternately, you can retrieve MX records using the host command’s -t (type) mx option:
To focus on SOA (start of authority) records, you can use a command like this one:
Alternately, you can also use a command like this with the -t (type) SOA option:
To see CNAME (canonical name) records, you can use a command like this one that tells you that mail.google.com is an alias for Google’s mail server:
In the command below, we are just looking for name servers using the ns type with the host command:
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.

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.

source

About The Author