Useful host command examples for DNS queries. Host Command CLI utility Linux. 4k.

Опубликовано: 15 Июнь 2026
на канале: Puzo It
161
3

Useful host command examples for DNS queries

The Host Command is a minimally easy-to-use CLI utility for performing DNS queries that translate domain names to IP addresses and vice versa. It can also be used to enumerate and check various types of DNS records such as NS and MX, check the ISP's DNS server and internet connections, detect and troubleshoot DNS server problems, etc.

In this article, we will learn how to use the Host command and walk through some helpful examples for performing DNS lookups. The Host utility comes preinstalled on most, if not all major Linux distributions.
Domain IP address lookup

This is the simplest host command you can run, just provide a domain name like google.com to get the IP addresses associated with it.

$ host google.com

Find Domain Name Servers

To find the domain name server, use the -t parameter:

$ host -t ns google.com

Finding a CNAME Record on a Domain

To find out the CNAME domain, run:

$ host -t cname mail.google.com

mail.google.com is an alias for googlemail.l.google.com.

Finding an MX Domain Record

To find the MX records for a domain:

$ host -n -t mx google.com

Find TXT Domain Record

To find TXT records for a domain:

$ host -t txt google.com

Find the SOA record of a domain

You can tell the host command to display SOA records for the specified zone, from all listed nameservers, with the -C option.

host -C google.com

Using an alternate name server for queries

You can query a specific domain name server using:

$ host google.com ns4.google.com

Find all information about domains and zones

To execute an ANY query, use the -a (all) option, which is equivalent to the -v option.

$ host -a google.com

Get domain TTL information

To find out information about the TTL of a domain:

$ host -v -t a google.com


How to use only IPv4 or IPv6

The -4 or -6 option causes the host utility to use only IPv4 or only IPV6, respectively.

$ host -4 google.com
OR
$ host -6 google.com


Executing non-recursive queries

The -r option performs non-recursive queries, note that setting this option clears the RD (recursion desirable).

$ host -rR 5 google.com

Changing the number of UDP requests for searches

The default UDP request count is 1, to change the number of retries use the -R option:

$ host -R 5 google.com

Using the -W parameter, you can tell the host utility how long to wait for a response (in seconds). And if the -w option is used, it tells host to wait for a response all the time:

$ host -T -W 10 google.com

That's all! In this article, we learned how to use the host command and looked at some useful examples of using the host command in Linux.

Thank you for taking the time to read the article!

If you have any questions, ask them in the comments.

Subscribe