Options for DNS lookup using Linux host command

What is host command

Host command is a simple utility for performing DNS lookups. With host we can translate names into IP Addresses and vice versa. Here’s some examples about using host command in day-to-day operation

1. Run host without any options

To use host command just type host and the target address. Let say you want to know the address of www.ubuntu.com. We can type :

$ host www.ubuntu.com

Host with no options

But we may have a different result. Take a look at the picture below.

$ host www.ibm.com

Another result of host output

We see that www.ibm.com is an alias for another address. The last line which has an IP Address is the original address.

As mentioned before, host can also translate an IP Address into a name.

$ host

Reverse output

2. Display SOA record

When we use -C option, we tell the host to display SOA (Start of Authority) record from the domain name.

$ host -C ubuntu.com


As we see above, ubuntu.com has SOA record ns1.canonical.com which placed in 3 different DNS servers.

3. Specify the query

DNS is built from some records. Some of the records are SOA, CNAME, NS, A, MX, etc. When we want to query specific record, we can use -t option. Here’s some examples.

$ host -t CNAME ibm.com

CNAME query

$ host -t NS ibm.com

NS query

$ host -t MX ibm.com

MX query

4. Force host to query using IP version 4 transport only

By default, host will use IP version 4 and IP version 6 to query a target host. To force only use IP version 4, we can use -4 option.

$ host -4 www.debian.org

IP ver 4 query only

5. Force host to query using IP version 6 transport only

If we want to tell host command to query using IP version 6 only, we can use -6 option.

$ host -6 www.debian.org

At the present time the DNS implementations available all run on top of IPv4, and the DNS system supporting IPv6 is linked to IPv4 information. So if we push to use -6 option, we will get this message.

IP ver 6 query

6. Print in list mode

With -l option, we can makes host perform a zone transfer for zone name. This will will print NS, PTR and address records.

$ host -l workshopdev.com

Print in list mode

If we combine it with -a option, it will print all records.

Host using -la options

7. Print information in verbose output

Verbose output will print all information about the target host. This information is similar with -a option below. Another option that similar with -a option is -d option.

8. Reveal all detail about the address

We can use -a parameter to reveal more detail about specific address.

$ host -a www.ubuntu.com

Display detail information

Here’s how to read the information :

Question Section ; inform us that the Host command ask everything
Answer Section ; inform us that the address of www.ubuntu.com is
Authority Section ; inform us that ubuntu.com has 3 responsible DNS. NS means Name Server
Additional Section ; inform us the addresses of the three DNS above

-a parameter is equivalent with -v for verbose output and -t ANY for specifies the query type.

– See more at: http://  linoxide.com/linux-command/learn-host-command/