Using the host command to perform DNS queries


The command host is a DNS lookup utility that can be used to make DNS queries. Check this tutorial to learn how to use the host command.

Using host command

Host command can be used to query like the next example:


This will output: has address has IPv6 address 2800:3f0:4002:807::2005 mail is handled by 40 mail is handled by 20 mail is handled by 30 mail is handled by 10 mail is handled by 5

You can use the "all" flag -a, which will request DNS entry type ANY.

host -a

The output will be:

Trying ""
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3582
;; flags: qr rd ra; QUERY: 1, ANSWER: 14, AUTHORITY: 0, ADDITIONAL: 0

;         IN  ANY

;; ANSWER SECTION:      299 IN  A      299 IN  AAAA    2800:3f0:4002:804::2005      3599    IN  MX  30      59  IN  SOA 205611210 900 900 1800 60      3599    IN  MX  5      21599   IN  NS      299 IN  TXT "v=spf1"      3599    IN  MX  10      21599   IN  NS      21599   IN  CAA 0 issue ""      3599    IN  MX  20      3599    IN  MX  40      21599   IN  NS      21599   IN  NS

As you can see the previous command returned ANY type, you can filter them using -t with the type to filter like: AAAA, MX, TXT, etc.

Let's try to use -t TXT:

host -t TXT

The output was: descriptive text "v=spf1"


The command host is very useful to debug and found problems in your DNS configurations.