Host command – how to use it?

What is Host command?

The Host command is a built-in utility software with a command-line interface that you can find on Linux or macOS and serves for network diagnostics. The most common use of host command is to perform DNS lookups and find different information about a domain name and its DNS records.

Access the command through the Terminal. 

Before we see how to use the Host command, let’s understand it better by seeing the purpose, syntax, and options for better results.

Purpose of the host command

You can use the Host command for the following purposes:

  • DNS lookups to check performance or troubleshoot your DNS servers
  • Get the IP address of a host that you only know the name.
  • Get the hostname if you know the IP address only.
  • See the full list of DNS records for a particular domain.
  • Probe individual DNS records and see the speed of response and their content.

Host command syntax

To see the Host command’s syntax, open the Terminal, write host and press the Enter button.

What you will see is the following:

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

A simplofied host syntax:

Host [option/options] name/ IP address 

Host – to indicate the command you are using.

Option/options – these are all the additional options that you would like to add to the standard host command. 

Hostname/ IP address – you could use a domain name/hostname or an IP address of a device. This will be the target of your host probe.

Host command options

You can easily see all the available options that could improve your host probe. Just open the Terminal application, write down host and press the Enter button.

How to use the host command?

To use the host command, you will need to open the Terminal first. The host command will be present on your Linux or macOS device.

For the purpose of these examples, we will be using: – Wikipedia’s domain name as our hostname. – Wikipedia’s IPv4 address for IP address.

Just replace the hostname or the IP address with the one you want to check.

1. Get the IPv4 and IPv6 addresses of a host

To get the IP addresses of the servers of a host, just use the following command:


2. Reverse lookup

You can also see the other way around, starting from the IP address and searching for the hostname.


3. See all DNS records

You can list all the available DNS records.

host -a

4. Check who is the authoritative name server (SOA record)

There is a DNS record called Start of Authority (SOA). Inside it, you can see who is the authoritative name server for the zone.

host -C

5. See the CNAME records for the subdomains

The subdomains usually have CNAME records that relate them to the domain name. You can check various subdomains that your site has, like mail, FTP, etc.

host -t cname

6. See if the Incoming mail servers are set correctly (MX record)

You can check which are the responsible mail servers for receiving emails for a particular domain name.

host -n -t mx

7. View TXT DNS records that are usually used for verification or authentication

There are various TXT records, so this command can help you see them.

host -t txt

8. List of all the name servers that a domain has

You can see a complete list of all the name server that a particular domain has.

host -t ns

9. See more information about a particular name server

Now that you have the list of all name servers, you can probe them individually.


10. Set a limited time to wait for a response

Use the “-W” to set how long you are willing to wait for a response. In our example, 20 seconds.

host -T -W 20

Leave a Reply

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