How to specify the DNS server in host command

6,777

Just use:

host -a google.com my.dns.server.com

host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W wait] [-m flag] [-4] [-6] {name} [server]

Share:
6,777
None
Author by

None

Updated on September 18, 2022

Comments

  • None
    None over 1 year

    I want to use linux host command to query all records (A, TXT, etc.) of a domain. I find this possible using -a option as in: host -a google.com

    However, I need to specify my own DNS server by its IP. I could not find any way to specify the resolver or the name server. I find this in dig as in: dig MX google.co.uk @ns1.google.com where the string after @ is the name server. But I did not find a way to query all records (TXT, A, etc.) in dig.

    I prefer to use host. How can I specify the name server n host command?

  • tripleee
    tripleee about 6 years
    +1 though I'm not entirely sure this is completely portable; I have seen some pesky differences between different versions of the host command.
  • tripleee
    tripleee about 6 years
    For example, Debian has two distinct packages bind-host (which is arguably the more popular, given how widespread BIND is) and knot-host but I believe there are version differences within different versions of BIND, too.
  • None
    None about 6 years
    I ma using ubuntu. It did not work with me. When I use dig with the name server (I use its IP), it works. So I am sure my name server is up and running. When I used your suggested command format, It get: ~$ host -a mywerver.com mydns1.com Trying "myserver.com" ;; connection timed out; no servers could be reached
  • None
    None about 6 years
    For some reason the vm got into aborted state. After starting it again the command worked successfully.
  • Aubs
    Aubs about 6 years
    Glad to hear it. I tried it myself on Ubuntu first to make sure it worked!