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
But we may have a different result. Take a look at the picture below.
$ host www.ibm.com
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 184.108.40.206
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
$ host -t NS ibm.com
$ host -t MX ibm.com
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
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.
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
If we combine it with -a option, it will print all records.
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
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 220.127.116.11
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/