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.
What is the purpose of the Linux Host command?
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:
|-a||Displays all DNS records.|
|-c||Non-In data specific query class.|
|-d||Same as –v.|
|-i||Reverse DNS lookups.|
|-l||Display list of all hosts in a domain.|
|-N||Number of dots allowed before root lookup.|
|-r||Stop the recursive process.|
|-R||Put a number of retries for UDP packets|
|-s||If SERVFAIL is received, stop the query.|
|-t||Specify the type of DNS record.|
|-T||TCP/IP mode enabled.|
|-v||Enable verbose output.|
|-V||Display version number.|
|-W||Wait specific time in seconds.|
|-6||Just 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).
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.
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.