Host command is a minimal and easy-to-use the command line interface, or CLI utility for performing DNS lookups which translate domain names to IP addresses and vice versa. It can also be used to list and verify various types of DNS records such as NS and MX, test and validate ISP DNS server and Internet connectivity, spam and blacklisting records, detecting and troubleshooting DNS server issues among others.
In this article, we will learn how to use host command with a few useful examples in Linux to perform DNS lookups. In previous articles, we showed the most used 8 Nslookup commands for testing and troubleshooting DNS servers and to query specific DNS resource records (RR) as well.
We also explained 10 Linux Dig (Domain Information Groper) commands to query DNS info, it works more like the Nslookup tool. The host utility also works in a similar way and comes preinstalled on most if not all mainstream Linux distros.
With that said, let’s look at these 14 host commands below.
Find the Domain IP Address
This is the simplest host command you can run, just provide a domain name such as google.com
to get the associated IP addresses.
Find Domain Name Servers
To find out the domain name servers use the -t option.
Find Domain CNAME Record
To find out the domain CNAME, run.
Find Domain MX Record
To find out the MX records for a domain.
Find Domain TXT Record
To find out the TXT records for a domain.
Find Domain SOA Record
You can make host attempt to display the SOA records for specified zone, from all the listed authoritative name servers for that zone with the -C
flag.
Query Particular Name Server
To query a particular domain name server.
Find All Information of Domain Records and Zones
To make a query of type ANY, use the -a
(all) option which is equivalent to setting the -v
option.
Get Domain TTL Information
To find out domain TTL information.
Use Either IPv4 or IPv6
The -4
or -6
option forces host to use only IPv4 or only IPV6 query transport respectively.
Perform Non-Recursive Queries
The -r
option performs non-recursive queries, note that setting this option clears the RD (recursion desired), the bit in the query which host makes.
Set UDP Retries for a Lookup
By default the number of UDP tries is 1, to change it, use the -R
flag.
Set Query Time Wait for Reply
Using the -W
switch, you can instruct host to wait for a reply for the specified time in seconds and if the -w
flag is used, it makes host to wait forever for a reply: