Tuesday, March 24, 2015

How To Perform DNS Lookup On OS X Terminal

Let's learn how to perform DNS lookup on OS X terminal. Here is all useful detailed information how to do it.

Being it a website, mail server, or whatever else all such domains are associated with an IP address. Nslookup introduces a simple way to get DNS information and an IP for specific website or domain. But if you want to get significantly more detailed retrieval, you can use the host command.

The host command does an extensive DNS lookup for whatever domain it’s pointed at, which makes it much more useful than nslookup. This can be really useful in different situations, whether to troubleshoot and discover DNS propagation issues or simply to get an actual IP address, CNAME, IPv6 address, or otherwise.

The host command usage is easy, as it is included in Mac OS X and Linux, so you can use it wherever necessary to do a DNS lookup. Command syntax is simple, launch Terminal and just use the following:

  • host [domain]

To get any DNS details you can also use the -a flag:

  • host -a [domain]

For instance, replacing [domain] with google and running host -a on google.com gives an extensive listing of DNS lookup details of multiple IP addresses and mail servers.
Air% host -a google.com
Trying "google.com"
;; Truncated, retrying in TCP mode.
Trying "google.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64673
;; flags: qr rd ra; QUERY: 1, ANSWER: 27, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;google.com.    IN    ANY
;; ANSWER SECTION:
google.com.    299    IN    A    1.2.3.208
google.com.    299    IN    A    1.2.3.213
google.com.    299    IN    A    1.2.3.210
google.com.    299    IN    A    1.2.3.212
google.com.    299    IN    A    1.2.3.215
google.com.    299    IN    A    1.2.3.209
google.com.    299    IN    A    1.2.3.214
google.com.    299    IN    A    1.2.3.221
google.com.    299    IN    A    1.2.3.218
google.com.    299    IN    A    1.2.3.211
google.com.    299    IN    A    1.2.3.220
google.com.    299    IN    A    1.2.3.219
google.com.    299    IN    A    1.2.3.216
google.com.    299    IN    A    1.2.3.217
google.com.    299    IN    A    1.2.3.207
google.com.    21599    IN    NS    ns3.google.com.
google.com.    599    IN    MX    40 alt3.aspmx.l.google.com.
google.com.    21599    IN    TYPE257    \# 19 000714981749824711982818926F6D
google.com.    21599    IN    SOA    ns1.google.com. dns-admin.google.com. 2015031701 7200 1800 1209600 300
google.com.    599    IN    MX    50 alt4.aspmx.l.google.com.
google.com.    3599    IN    TXT    "v=spf1 include:_spf.google.com ip4:21.71.93.70/31 ip4:211.24.93.2/31 ~all"
google.com.    21599    IN    NS    ns1.google.com.
google.com.    21599    IN    NS    ns2.google.com.
google.com.    599    IN    MX    10 aspmx.l.google.com.
google.com.    599    IN    MX    20 alt1.aspmx.l.google.com.
google.com.    21599    IN    NS    ns4.google.com.
google.com.    599    IN    MX    30 alt2.aspmx.l.google.com.
Received 613 bytes from 8.8.8.8#53 in 98 ms
Air%
You will see in the end that the DNS servers utilized for the lookup will be outlined at the same timewithout having to question them directly, even though that's still advised if you want a full list of all the DNS servers a particular machine is using. If they were modified just recently and the data you are seeing does not match what it should, flushing DNS cache can be necessary.

You can also get specific record types with the -t flag, for instance, if you want a CNAME or ANAME, or NameServer (NS) record, the syntax would look as follows:
host -t NS [domain]

To use google.com as an example, querying the name server would result in:
% host -t NS google.com
google.com name server ns3.google.com.
google.com name server ns2.google.com.
google.com name server ns1.google.com.
google.com name server ns4.google.com.
As you see DNS lookup on OS X terminal with the host command, it's a good networking toolkit to use.

Source

0 comments:

Post a Comment