Perform DNS Lookups with the host command

By | 2012/04/26

The dig command is commonly used to make DNS queries. However, a much overlooked command is the host command. Here are some quick tips for a useful tool to add to your bag of tricks or to impress your friends.

The syntax is:

$ host []

When run with no options, a simple quick summary is output:

$ host has address has address has address has address has address mail is handled by 10 mail is handled by 50 mail is handled by 40 mail is handled by 30 mail is handled by 20

Using tack a is the equivalent of any ANY request:

$ host -a
Trying ""
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57800
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 0

;                    IN      ANY

;; ANSWER SECTION:             296     IN      MX      10             296     IN      MX      50             296     IN      MX      40             296     IN      MX      30             296     IN      MX      20             170005  IN      NS             170005  IN      NS             170005  IN      NS             170005  IN      NS

Received 208 bytes from in 59 ms

Tack t followed by the type desired such as CNAME, NS, A, AAAA and so forth is a quick way to check for a specific type. This is a quick way to check for an ipv6 record, as one example:

$ host -t AAAA is an alias for has IPv6 address 2001:4860:800a::69


3 thoughts on “Perform DNS Lookups with the host command

  1. Henry

    Thanks Scott, I remember the first I started doing DNS queries. I wish i would of found this article way back then!

    1. scott Post author

      Command line tools query DNS directly rather than going through a web page that does the query to its own pre-defined DNS server (and website ads…). Also, hundreds of more options are available with commands such as host or dig that a website is not able to provide. My blog example is very tame on purpose, but you can get quite in depth on the command line as needed!

      With command line tools you can even specify the exact DNS server you want to test against, say, if you are a DNS admin. For example, perhaps you wanted to test if particular DNS information has reached a particular DNS server. Or test why users on your network cannot reach a particular domain. You would use dig or host to verify this for your mission critical company’s DNS servers.

      Here I am querying opendns directly:

      $ host



Leave a Reply

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

Notify me of followup comments via e-mail. You can also subscribe without commenting.