Linux host Command Explained for Beginners (8 Examples)

Host command is a simple utility for performing DNS lookups in Linux. With this command, we can translate names into IP Addresses and vice versa.

Here in the article I will show you some examples of using host command in Linux system.

1) Run host command 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 91.189.90.59

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

DNS SOA

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

Unfortunately, at the time this article is written, there is not yet a native IPv6 DNS root server. 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 make 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 the 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 91.189.89.103
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.

As usual, we can always type man host or host --help to explore more detail about host command usage.

Pungki Arianto 3:00 am

About Pungki Arianto

Pungki , currently working as a Linux / Unix administrator for a banking company. He love to work in Linux / Unix since it's fun for him. He is also interested in information technology, information security and writing.

Author's All Posts
Like to become part of Linoxide Team and contribute tips? Contact us here.

Comments

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.

1 Comment