{"id":13329,"date":"2019-04-01T20:27:22","date_gmt":"2019-04-01T20:27:22","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13329"},"modified":"2019-04-01T20:27:22","modified_gmt":"2019-04-01T20:27:22","slug":"useful-host-command-examples-for-querying-dns-lookups","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/useful-host-command-examples-for-querying-dns-lookups\/","title":{"rendered":"Useful \u2018host\u2019 Command Examples for Querying DNS Lookups"},"content":{"rendered":"<p><strong>Host<\/strong>\u00a0command is a minimal and easy-to-use CLI utility for performing DNS lookups which translate domain names to IP addresses and vice versa. It can also be used to list and verify various types of DNS records such as NS and MX, test and validate ISP DNS server and Internet connectivity, spam and blacklisting records, detecting and troubleshooting DNS server issues among others.<\/p>\n<p>In this article, we will learn how to use\u00a0<strong>host<\/strong>\u00a0command with a few useful examples in Linux to perform DNS lookups. In previous articles, we showed the most used\u00a0<a href=\"https:\/\/www.tecmint.com\/8-linux-nslookup-commands-to-troubleshoot-dns-domain-name-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">8 Nslookup commands for testing and troubleshooting DNS<\/a>\u00a0servers and to query specific DNS resource records (RR) as well.<\/p>\n<p>We also explained\u00a0<a href=\"https:\/\/www.tecmint.com\/10-linux-dig-domain-information-groper-commands-to-query-dns\/\" target=\"_blank\" rel=\"noopener noreferrer\">10 Linux Dig (Domain Information Groper)<\/a>\u00a0commands to query DNS info, it works more like the Nslookup tool. The host utility also works in a similar way and comes preinstalled on most if not all mainstream Linux distros.<\/p>\n<p>With that said, let\u2019s look at these 14 host commands below.<\/p>\n<h3>Find the Domain IP Address<\/h3>\n<p>This is the simplest host command you can run, just provide a domain name such as\u00a0<code>google.com<\/code>\u00a0to get the associated IP addresses.<\/p>\n<pre><strong>$ host google.com<\/strong>\r\n\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has IPv6 address 2a00:1450:4009:80b::200e\r\ngoogle.com mail is handled by 20 alt1.aspmx.l.google.com.\r\ngoogle.com mail is handled by 30 alt2.aspmx.l.google.com.\r\ngoogle.com mail is handled by 10 aspmx.l.google.com.\r\ngoogle.com mail is handled by 40 alt3.aspmx.l.google.com.\r\ngoogle.com mail is handled by 50 alt4.aspmx.l.google.com.\r\n<\/pre>\n<h3>Find Domain Name Servers<\/h3>\n<p>To find out the domain name servers use the -t option.<\/p>\n<pre><strong>$ host -t ns google.com<\/strong>\r\n\r\ngoogle.com name server ns1.google.com.\r\ngoogle.com name server ns2.google.com.\r\ngoogle.com name server ns3.google.com.\r\ngoogle.com name server ns4.google.com.\r\n<\/pre>\n<h3>Find Domain CNAME Record<\/h3>\n<p>To find out the domain CNAME, run.<\/p>\n<pre><strong>$ host -t cname mail.google.com<\/strong>\r\n\r\nmail.google.com is an alias for googlemail.l.google.com.\r\n<\/pre>\n<h3>Find Domain MX Record<\/h3>\n<p>To find out the MX records for a domain.<\/p>\n<pre><strong>$ host -n -t mx google.com<\/strong>\r\n\r\nogle.com mail is handled by 50 alt4.aspmx.l.google.com.\r\ngoogle.com mail is handled by 10 aspmx.l.google.com.\r\ngoogle.com mail is handled by 40 alt3.aspmx.l.google.com.\r\ngoogle.com mail is handled by 30 alt2.aspmx.l.google.com.\r\ngoogle.com mail is handled by 20 alt1.aspmx.l.google.com.\r\n<\/pre>\n<h3>Find Domain TXT Record<\/h3>\n<p>To find out the TXT records for a domain.<\/p>\n<pre><strong>$ host -t txt google.com<\/strong>\r\n\r\ngoogle.com descriptive text \"v=spf1 include:_spf.google.com ~all\"\r\n<\/pre>\n<h3>Find Domain SOA Record<\/h3>\n<p>You can make host attempt to display the SOA records for specified zone, from all the listed authoritative name servers for that zone with the\u00a0<code>-C<\/code>\u00a0flag.<\/p>\n<pre><strong>$ host -C google.com<\/strong>\r\n\r\nNameserver 216.239.38.10:\r\n\tgoogle.com has SOA record ns1.google.com. dns-admin.google.com. 156142728 900 900 1800 60\r\nNameserver 216.239.32.10:\r\n\tgoogle.com has SOA record ns3.google.com. dns-admin.google.com. 156142728 900 900 1800 60\r\nNameserver 216.239.34.10:\r\n\tgoogle.com has SOA record ns4.google.com. dns-admin.google.com. 156142728 900 900 1800 60\r\nNameserver 216.239.36.10:\r\n\tgoogle.com has SOA record ns2.google.com. dns-admin.google.com. 156142728 900 900 1800 60\r\n<\/pre>\n<h3>Query Particular Name Server<\/h3>\n<p>To query particual domain name server.<\/p>\n<pre><strong>$ host google.com ns4.google.com<\/strong>\r\n\r\nUsing domain server:\r\nName: ns4.google.com\r\nAddress: 216.239.38.10#53\r\nAliases: \r\n\r\ngoogle.com has address 172.217.19.46\r\ngoogle.com has address 172.217.19.46\r\ngoogle.com has address 172.217.19.46\r\ngoogle.com has IPv6 address 2a00:1450:4005:808::200e\r\ngoogle.com mail is handled by 30 alt2.aspmx.l.google.com.\r\ngoogle.com mail is handled by 20 alt1.aspmx.l.google.com.\r\ngoogle.com mail is handled by 50 alt4.aspmx.l.google.com.\r\ngoogle.com mail is handled by 10 aspmx.l.google.com.\r\ngoogle.com mail is handled by 40 alt3.aspmx.l.google.com.\r\n<\/pre>\n<h3>Find All Information of Domain Records and Zones<\/h3>\n<p>To make a query of type ANY, use the\u00a0<code>-a<\/code>\u00a0(all) option which is equivalent to setting the\u00a0<code>-v<\/code>\u00a0option.<\/p>\n<pre><strong>$ host -a google.com<\/strong>\r\n\r\nTrying \"google.com\"\r\n;; -&gt;&gt;HEADER&lt;<\/pre>\n<h3>Get Domain TTL Information<\/h3>\n<p>To find out domain TTL information.<\/p>\n<pre><strong>$ host -v -t a google.com<\/strong>\r\n\r\nTrying \"google.com\"\r\n;; -&gt;&gt;HEADER&lt;<\/pre>\n<h3>Use Either IPv4 or IPv6<\/h3>\n<p>The\u00a0<code>-4<\/code>\u00a0or\u00a0<code>-6<\/code>\u00a0option forces host to use only IPv4 or only IPV6 query transport respectively.<\/p>\n<pre>$ host -4 google.com\r\nOR\r\n$ host -6 google.com\r\n<\/pre>\n<h3>Perform Non-Recursive Queries<\/h3>\n<p>The\u00a0<code>-r<\/code>\u00a0option performs non-recursive queries, note that setting this option clears the RD (recursion desired), the bit in the query which host makes.<\/p>\n<pre><strong>$ host -rR 5 google.com<\/strong>\r\n\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has IPv6 address 2a00:1450:4009:80b::200e\r\ngoogle.com mail is handled by 30 alt2.aspmx.l.google.com.\r\ngoogle.com mail is handled by 40 alt3.aspmx.l.google.com.\r\ngoogle.com mail is handled by 50 alt4.aspmx.l.google.com.\r\ngoogle.com mail is handled by 20 alt1.aspmx.l.google.com.\r\ngoogle.com mail is handled by 10 aspmx.l.google.com.\r\n<\/pre>\n<h3>Set UDP Retries for a Lookup<\/h3>\n<p>By default the number of UDP tries is 1, to change it, use the\u00a0<code>-R<\/code>\u00a0flag.<\/p>\n<pre><strong>$ host -R 5 google.com<\/strong>\r\n\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has IPv6 address 2a00:1450:4009:80b::200e\r\ngoogle.com mail is handled by 30 alt2.aspmx.l.google.com.\r\ngoogle.com mail is handled by 40 alt3.aspmx.l.google.com.\r\ngoogle.com mail is handled by 50 alt4.aspmx.l.google.com.\r\ngoogle.com mail is handled by 20 alt1.aspmx.l.google.com.\r\ngoogle.com mail is handled by 10 aspmx.l.google.com.\r\n<\/pre>\n<h3>Set Query Time Wait for Reply<\/h3>\n<p>Using the\u00a0<code>-W<\/code>\u00a0switch, you can instruct host to wait for a reply for the specified time in seconds and if the\u00a0<code>-w<\/code>flag is used, it makes host to wait forever for a reply:<\/p>\n<pre><strong>$ host -T -W 10 google.com<\/strong>\r\n\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has address 216.58.201.46\r\ngoogle.com has IPv6 address 2a00:1450:4009:80b::200e\r\ngoogle.com mail is handled by 10 aspmx.l.google.com.\r\ngoogle.com mail is handled by 40 alt3.aspmx.l.google.com.\r\ngoogle.com mail is handled by 30 alt2.aspmx.l.google.com.\r\ngoogle.com mail is handled by 20 alt1.aspmx.l.google.com.\r\ngoogle.com mail is handled by 50 alt4.aspmx.l.google.com.\r\n<\/pre>\n<p>That\u2019s it! In this article, we learned how to use\u00a0<strong>host<\/strong>\u00a0command with a few useful examples in Linux. Use the feedback form below to share any thoughts with us concerning this guide.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/linux-host-command-examples-for-querying-dns-lookups\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Host\u00a0command is a minimal and easy-to-use CLI utility for performing DNS lookups which translate domain names to IP addresses and vice versa. It can also be used to list and verify various types of DNS records such as NS and MX, test and validate ISP DNS server and Internet connectivity, spam and blacklisting records, detecting &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/useful-host-command-examples-for-querying-dns-lookups\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Useful \u2018host\u2019 Command Examples for Querying DNS Lookups&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13329","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13329"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13329\/revisions"}],"predecessor-version":[{"id":13332,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13329\/revisions\/13332"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}