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.
What is the Host command?
The Host command is a software with a command-line interface that serves to test DNS. Internet Systems Consortium created it, and it is distributed as a permissive free software with an ISC license.
As we mentioned already, the Host command is a utility tool for network diagnostic that you can use to probe different DNS records. You can see the A or AAAA records to get the IP address of a domain, see the name servers, find the start of authority, MX records, and more.
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.
This command will show the content of the A and AAAA records. You will get IPv4 and IPv6 results for the domain.
See the Start of Authority records with this command. The SOA record is used for zone transfer. There could be only one SOA record per zone file. If you see more, then you need to fix the problem.
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. When you know all of the available name servers, you can test them individually.
Check a particular name server
You want, for example, to review the ns1. To see if it is responsive or is there any problem, so you type:
host google.com ns1.google.com
host –t cname mail.google.com
You can use it to find CNAME record. Those records will link one alias to the true name, the canonical.
Check the incoming mail server with this query. You can see if they are responding correctly.
host –n –t mx google.com
You can also check TXT records. There are various TXT DNS records that serve for authentication or verification. One of them is the SPF record that shows who can send emails from the particular domain.
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. It is a must to set the Reverse Lookup Zone for your mail server to work properly.
Host command to see all of the DNS records for a domain
host –a google.com
Change the default number of tries from 1 to the number you desire
host -R 8 google.com
In this example of host command, we changed from 1 to 8, the number of tries. The domain will have 8 chances to respond. When it manages to answer, it will stop the retries.
-R : In order to specify the number of retries you can do in case one try fails. If anyone try succeeds then the command stops.
This was the host command. Now you have one more way to troubleshoot your DNS. If you are interested in diagnostic tools, we recommend you the following articles too: Dig command, Nslookup, Traceroute, MTR and Ping. They will expand your knowledge in DNS diagnostic.
Hi, I’m Martin Pramatarov. I have two degrees, a Technician of Computer Networks and an MBA (Master of Business Administration). My passion is storytelling, but I can’t hide my nerdish side too. I never forgot my interest in the Hi-tech world. I have 10 years and thousands of articles written about DNS, cloud services, hosting, domain names, cryptocurrencies, hardware, software, AI, and everything in between. I have seen the Digital revolution, the Big migration to the cloud, and I am eager to write about all the exciting new tech trends in the following years. AI and Big Data are here already, and they will completely change the world!
I hope you enjoy my articles and the excellent services of ClouDNS!