How does the Host command work?

Host command explained

The Host command is a built-in utility software with a command-line interface (CLI) for DNS probing. You could find it pre-installed on most Linux distros like – Ubuntu, Linux Mint, Red Hat, or macOS. It serves perfectly for network diagnostics. In addition, the most common use of host command is to complete DNS lookups and check different information about a domain name and its DNS records.

 It is a very light and quick tool that can give you data about different DNS records, such as A, AAAA, MX, NS, SOA, and more. In addition, it can provide you with information for the host, for instance, its IP addresses or check nameservers.

Purpose

The Host command is a very handy tool, and it has the following purposes:

  • You are able to view all of the DNS records for a specific domain name.
  • If you know only the name of a particular host, you can get the IP address.
  • If you know only the IP address of a particular host, you can get the hostname.
  • For performing DNS lookups to view the performance or troubleshooting your DNS servers.
  • You can probe precise DNS records and examine the speed of reply and their content.

Syntax of the Host command

If you want to see the Host command’s syntax, first you have to open the Terminal, then type “host” and press the Enter button.

You are going to see the following:

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

Here is a more simple version of the host syntax:

Host [option/options] name/ IP address 

Host – It indicates the particular command you are performing.

Option/options – These are every one of the extra options that you would prefer to combine with the standard host command. 

Hostname/ IP address – You are able to use a domain name/hostname or an IP address. Here is your target of the host probe.

How to use the Host command?

The host command will be available on your Linux or macOS device, so you just have to open the Terminal. Here are some simple examples.

*Just change the hostname or the IP address with the one you want to probe.

See the IPv4 and IPv6 addresses of a host.

To get the available IP addresses, simply type the following:

host exampledomain.com

Reverse lookup

If you want to search for the hostname starting from the IP address, just type the following:

host 91.148.134.192

View all available DNS records

You can list all the available DNS records.

host -a exampledomain.com

Examine the authoritative name server (SOA record)

Inside the DNS SOA record, you can understand which is the authoritative name server for the zone.

host -C exampledomain.com

Check the CNAME records for the subdomains

The subdomains typically have CNAME records that link them to the domain name. You can examine different subdomains that your website has, such as mail, FTP, etc.

host -t cname ftp.exampledomain.com

Check incoming mail servers (MX record)

If you want to see which are the accountable mail servers for receiving emails for a specific domain name, type the following:

host -n -t mx exampledomain.com

See TXT records for authentication

There are multiple TXT records. Therefore this command is going to help you examine them.

host -t txt exampledomain.com

View all the name servers for a domain

You could examine an entire list of all the nameservers that the domain has.

host -t ns exampledomain.com

See additional data for a precise name server

After you have the list of all name servers, you are able to examine them separately.

host wikipedia.org ns1.exampledomain.com

Limit the time for waiting for an answer

To establish how long you want to wait for a response, use the “-W”. In this case, 30 seconds.

host -T -W 30 exampledomain.com

Leave a Reply

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