Today we will add one more handy DNS tool – host command on Linux. For the purpose, we will use the latest Linux Mint 19.1 (based on Ubuntu Linux). For those of you who are used to Windows, Linux host command is very similar to nslookup, but a bit more advanced. Host command replaced the nslookup on Linux-based operating systems. You can use it to check different types of DNS records.
Host command syntax
If you want to see the syntax of the host command and the options that it has, you can simply write “host” and press “Enter.”
host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W time] [-m flag] [-4] [-6] hostname [server]
Host command Options
Here you can see all the available options. Whenever you forgot them, just write “host” in the Terminal.
Host command examples
For all the cases we will use Google.com. You can change Google.com with your domain or whichever else domain that you are interested in. We will give you several examples that can be useful for your work.
Search for the IP address of the domain.
You will get IPv4 and IPv6 results for the domain.
See the Start of Authority records with this command.
host –C google.com
Check the name servers of the domain
host –t ns google.com
It will display the name servers of the host. The –t, we use to specify the type of query.
Check a particular name server
You want, for example, to review the ns1, so you type:
host google.com ns1.google.com
host –t cname mail.google.com
You can use it to find CNAME record
Check the incoming mail server with this query
host –n –t mx google.com
You can also check TXT records
host –t txt google.com
Decide the Waiting time for a query
You can use –w to wait forever or –W and time in seconds to decide how long to wait for a reply.
host –T –W 10 google.com
You can also check the IP and see the host
Host command to see all of the DNS records for a domain
host –a google.com
You will get information about various types of records – NS, AAAA, MX, etc.
This was the host command. Now you have one more way to troubleshoot your DNS. If you are interested in DNS diagnostic we recommend you the following articles too: Dig command, Nslookup, Traceroute and Ping. They will expand your knowledge in DNS diagnostic.