Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find a C++ DNS Library?

Tags:

c++

dns

winapi

I know DNS is typically handled by the operating system, but I'm working under the assumption that DNS has been broken on the target system (this is a tool to diagnose DNS misconfiguration). I therefore need to implement DNS myself, to check the results I get back from the system against a known good DNS server.

You can do this with the NSLookup or Dig tools, specifying a DNS server address manually, but it appears the Windows API calls for doing this (e.g. GetAddressByName) don't allow me to specify a server to query, and use the system's configured target instead.

I tried to look for the RFCs on DNS, but unfortunately they are clear as mud to me -- they make the HTTP spec look like the clearest and most well written spec ever produced.

I also don't want to reinvent something that someone else has already done several times before.

like image 484
Billy ONeal Avatar asked Jul 19 '11 22:07

Billy ONeal


3 Answers

You might try: http://25thandclement.com/~william/projects/dns.c.html . Also, see Need To Build Simple DNS Resolver in C

Actually, a Google search of "DNS resolver C" reveals several possibilities.

like image 71
Robᵩ Avatar answered Oct 09 '22 14:10

Robᵩ


Try the c-ares library, which as I understand it does implement its own DNS stack. I've used it successfully on linux, and they say that it supports Windows, though I haven't tried it myself. It isn't C++, just plain C, but you can easily enough write a C++ wrapper for it.

It gets bonus points for being asynchronous, and providing hooks by which you can integrate it with an existing event loop.

like image 45
acm Avatar answered Oct 09 '22 14:10

acm


I know that the question is old, but I haven't found good answer for me here. I have found poslib as the best dns library with very easy interface.

like image 31
unDEFER Avatar answered Oct 09 '22 14:10

unDEFER