0

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.

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 (or better without making any changes at all).

I've looked at Poco::Net::DNS and c-ares, however they both seem to use OS DNS settings and don't allow to point queries to other DNS servers (correct me if I'm wrong).

Groosha
  • 2,897
  • 2
  • 22
  • 38
  • 2
    You can use the [DNS](https://en.wikipedia.org/wiki/Domain_Name_System) protocol to query any arbitrary nameserver you want. – Some programmer dude Dec 21 '17 at 15:24
  • @Someprogrammerdude could you please point me to any relevant piece of code? I'm afraid I'm not skilled enough to write a proper "clean" solution in lack of time – Groosha Dec 21 '17 at 15:35

1 Answers1

0

Yes. DNS is a protocol that is on top the TCP protocol, so you can do DNS queries anywhere you can send and receive TCP packets (assuming there are no firewall rules that prevent this or other network problems).

However, C++ does not have a standard library for DNS protocol. Neither does C++ have a standard library for sending or receiving TCP packets (although, this is considered for addition in C++20). You can depend on the operating system specific API for network communication (or as always, you can use a library that wraps the system API).

eerorika
  • 232,697
  • 12
  • 197
  • 326