Linux host command explained

What is the Linux host command?

The Linux Host command is utility software for DNS probing that you get pre-installed on most Linux distros like – Ubuntu, Linux Mint, Red Hat, CentOS, Arch Linux, and more.

Linux Host command can show you different information for the host, its IP addresses, DNS records, and check name servers.

It does not have a graphical interface, but its CLI is enough to display all the information needed. It is a very light and fast tool that can show you information about DNS records like A, AAAA, MX, NS, SOA, and more. You could have already guessed. It can show you information about the host like its IP addresses and more.

Syntax of Linux host command

Type “host” inside the Terminal and you will see the syntax of it:

host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W time] [-m flag] [-4] [-6] hostname [server]

Options for the Linux host command

Again, types “host” in the Terminal will show you all the options too:

OptionDescription
-aDisplays all DNS records.
-cNon-In data specific query class.
-dSame as –v.
-iReverse DNS lookups.
-lDisplay list of all hosts in a domain.
-mMemory debugging.
-NNumber of dots allowed before root lookup.
-rStop the recursive process.
-RPut a number of retries for UDP packets
-sIf SERVFAIL is received, stop the query.
-tSpecify the type of DNS record.
-TTCP/IP mode enabled.
-vEnable verbose output.
-VDisplay version number.
-wWait indefinitely.
-WWait specific time in seconds.
-4Just IPv4.
-6Just IPv6 only.

For what and how to use it?

To use the host command on Linux, you simply need to open the Terminal app and directly start using it from there since it is a built-in command. Here below, you will see examples of the host command that you can easily copy and paste for your needs. Don’t forget to change the IP addresses or hostnames with those that you want to probe.

See the IP addresses of a host (IPv4 and IPv6 addresses).

host domain.com

That one will do a general DNS query for A and AAAA records and show the domain name’s addresses.

See a list of all of the available DNS records and their values.

host -a domain.com

Now you will see records like A, AAAA, CNAME, MX, and more with their values.

Check a particular type of DNS record by using the “type” option. Here you will see 4 different examples.

  • host -t cname domain.com to see if there any canonical names for the domain.
  • host -t txt domain.com – to see TXT DNS records like DMARC, DKIM or TXT. 
  • host -t mx domain.com – check the MX records and the incoming mail servers’ IP addresses. 
  • host -t ns domain.com – see the name servers. 

See information (IPv4, IPv6, and if it does respond at the moment) for a particular name server before you can use the “-t ns” to see the name servers.

host domain.com ns1.domain.com

Do a reverse DNS check and start with the IP address.

host –i 123.456.789.001

You can trace back the IP address and see to who does it belong. Useful to see if there is a PTR record for the domain.

Conclusion

Now you know what the Linux host command is and its options. Go ahead and try it out. Probe your domain and get familiar with the way it functions. It could be a nice little tool for your DNS diagnostic. 

Write a Comment

Your email address will not be published. Required fields are marked *