12

For my task, I need to block some hostnames, but since some websites may reply with different IP addresses to different DNS queries (for example, Google DNS and any other DNS server), I'd like to resolve same hostname using different DNS servers to get as many possible IP addresses as possible.

Can I solve this task using command line utilities on Ubuntu 16+? Are there any alternative solutions?

In short: I'd like to resolve "example.com" to IP using DNS #A and resolve "example.com" to IP using DNS #B without making any serious changes to my network configuration.

4
  • 2
    man host, man nslookup or man dig - any of those should help
    – pawel7318
    Dec 21, 2017 at 14:15
  • Have you considered how the client subnet DNS option can interfere with your results?
    – kasperd
    Dec 21, 2017 at 18:58
  • While this is not what you asked about, still it might be useful in the context. There are online services which query different DNS worldwide and give you a list of the answers - e.g. whatsmydns.net (I am not affiliated) Dec 21, 2017 at 20:53
  • 1
    If you need to block a hostname, it may be easiest to set up your own DNS resolver and have it return a "NXDOMAIN" error whenever someone tries to look up the hostname in question. I do this to reduce Facebook's tracking abilities.
    – Mark
    Dec 21, 2017 at 23:49

2 Answers 2

15

Yes you can with the tools @pawel7318 mentioned.

dig

dig @nameserver hostname

nslookup

nslookup hostname nameserver

host

host hostname nameserver
1
  • Just use dig and you can forget all the others. Dec 23, 2017 at 3:32
3

I believe

nslookup -q= < record type > < host > < DNS server >

will make the trick for you.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .