Thursday, November 29, 2012

Using host command as an alternative to nslookup

host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa. When no arguments or options are given, host prints a short summary of its command line arguments and options.

Common basic Usages

Using host command to check resolving DNS Servers
# host www.google.com.sg

www.google.com.sg has address 173.194.38.159
www.google.com.sg has address 173.194.38.151
www.google.com.sg has address 173.194.38.152
www.google.com.sg has IPv6 address 2404:6800:4003:802::1018

Using host command with "-a" to display a query of type ANY

# host -a google.com.sg

Trying "google.com.sg"
;; ->>HEADER<<- 51686="51686" br="br" id:="id:" noerror="noerror" opcode:="opcode:" query="query" status:="status:">;; flags: qr rd ra; QUERY: 1, ANSWER: 14, AUTHORITY: 4, ADDITIONAL: 3

;; QUESTION SECTION:
;google.com.sg.                 IN      ANY

ANSWER SECTION:
google.com.sg.          177     IN      TXT     "v=spf1 -all"
google.com.sg.          86277   IN      SOA     ns1.google.com. dns-admin.google.com. 2012032600 21600 3600 1209600 300
google.com.sg.          177     IN      AAAA    2404:6800:4003:801::101f
google.com.sg.          177     IN      A       74.125.235.63
google.com.sg.          177     IN      A       74.125.235.55
google.com.sg.          177     IN      A       74.125.235.56
google.com.sg.          10677   IN      MX      10 google.com.s9b1.psmtp.com.
google.com.sg.          10677   IN      MX      10 google.com.s9b2.psmtp.com.
google.com.sg.          10677   IN      MX      10 google.com.s9a1.psmtp.com.
google.com.sg.          10677   IN      MX      10 google.com.s9a2.psmtp.com.
google.com.sg.          345477  IN      NS      ns2.google.com.
google.com.sg.          345477  IN      NS      ns3.google.com.
google.com.sg.          345477  IN      NS      ns1.google.com.
google.com.sg.          345477  IN      NS      ns4.google.com.

;; AUTHORITY SECTION:
google.com.sg.          345477  IN      NS      ns2.google.com.
google.com.sg.          345477  IN      NS      ns3.google.com.
google.com.sg.          345477  IN      NS      ns1.google.com.
google.com.sg.          345477  IN      NS      ns4.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.         188413  IN      A       216.239.32.10
ns2.google.com.         188413  IN      A       216.239.34.10
ns3.google.com.         188413  IN      A       216.239.36.10

Using host -t parameter to select the query type
# host -t MX google.com.sg

google.com.sg mail is handled by 10 google.com.s9b2.psmtp.com.
google.com.sg mail is handled by 10 google.com.s9a1.psmtp.com.
google.com.sg mail is handled by 10 google.com.s9a2.psmtp.com.
google.com.sg mail is handled by 10 google.com.s9b1.psmtp.com.

No comments: