Linux host command, troubleshot your DNS

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 syntax

Host command Options

Here you can see all the available options. Whenever you forgot them, just write “host” in the Terminal.

options for the command

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.

host google.com

You will get IPv4 and IPv6 results for the domain.

host google.com

SOA Record

See the Start of Authority records with this command.

host –C google.com

SOA record

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.

host ns record

Check a particular name server

You want, for example, to review the ns1, so you type:

host google.com ns1.google.com

particular name server

 CNAME record

host –t cname mail.google.com

You can use it to find CNAME record

host cname

MX record

Check the incoming mail server with this query

host –n –t mx google.com

mx record host command

TXT Record

You can also check TXT records

host –t txt google.com

txt host command

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

select time for host command

Reverse lookup

You can also check the IP and see the host

host 216.58.194.142

reverse dns lookup with host command

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.

all records host command

Conclusion:

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.

Linux dig command

Linux dig command, how to install it and use it

Dig command (Domain Information Groper) is one of the most popular DNS testing tools. You can use it to troubleshoot your DNS and make sure everything works fine. You can try it on Linux, Mac OS, and Windows. For this demonstration, we will use a random old laptop with the latest version of Linux Mint (19.1). Linux Mint is based on Ubuntu Linux. Many old laptops can get a new life as a diagnostic tool.

How to install the dig command on Linux?

First, let’s check if you already have the dig command installed. You can do that by opening the terminal and writing dig -v. If you have it, your computer will show a message similar to this one:

DiG 9.11.3-1ubuntu1.7-Ubuntu.

Many new Linux distros have it pre-installed. In case you don’t have it, you will get the following message:

dig command not found

For Linux Mint, Ubuntu and other Ubuntu-based Linux distributions you can use the following command:

sudo apt install dnsutils

If you are using Fedora or CentOS you should use:

sudo yum install bind-utils

And for Arch Linux users:

sudo pacman -S bind-tools

Understanding the dig command

Let’s start with a simple example to understand it. We will use google.com for the testing. You can try it directly with your domain, by simply replacing google.com with your domain.

dig google.com

dig command

The first line will inform you about the version of the dig command and the second about the global option.

After that, you will get technical information provided by the DNS nameserver. The header shows you what did you do and was it successful. If there is “NOERROR” that there was no problem.
You will see the answer for the EDNS.
Following line shows that by default you are requesting the A record.
You will get the answer for the A record – the correspondent IP address and you will get statistic about the query.

More dig command examples:

dig google.com +short

dig command short

This will show you just the IP address without any additional information.

dig google.com MX

dig command MX record

You can query different types of records like the mail exchanger ones. MX records show the responsible mail server for accepting emails. 

dig google.com SOA

dig command SOA record

SOA – the start of authority, shows the authoritative DNS server.

dig google.com TTL

dig TTL

TTL – time to live. It shows how long the data should be kept. You can read more about TTL HERE

dig google.com +nocomments +noquestion +noauthority +noadditional +nostats

dig only answer query

Only answer query. Use it if you don’t want to receive extra information.

dig google.com ANY +noall +answer

Query all types of DNS records. It will show all the different types of DNS records.

dig -x 172.217.1.142

dig reverse dns lookup

Reverse DNS lookup. You can also do the opposite and check the IP address. The rDNS is used for verification. The result will be a PTR record that verifies the nameserver.

dig @8.8.8.8 +trace google.com

dig trace

Trace DNS Path. It will show the whole route that a DNS query takes. Every hop from a server to server. It can show you where exactly server is not working.

11 dig -p 5300 google.com

dig port check

Specify Port Number. If you have changed the standard port 53 to another for increased security, you can make a dig command to check if it is working correctly.

Now you know the basics of the dig command on Linux. You can start experimenting by yourself.
You can get some additional information about the dig command and a few more options to try in our Wiki.

We can recommend you a few more tools that can be useful for your DNS diagnostic Nslookup, Traceroute and Ping.

Sources used:
Linuxize.com
Tecmint.com

Traceroute command and its options

Traceroute

Many network administrators use the traceroute command daily. It is a convenient tool that you can use under different operation systems – Windows (Tracert), MacOS, Linux (traceroute) and even on mobile (Android and iOS).

You can use traceroute, and see the full route that the packets take to their destination (domain or IP address). Apart from that, you will see the hostnames and IPs of the routers on the way and the latency, the time it takes for each device to receive and resend the data.

You can see which gateway is discarding your data and later you can fix it.

Traceroute

Continue reading “Traceroute command and its options”