简体   繁体   中英

Where can I find a C++ DNS Library?

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 (eg 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.

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.

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.

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.

djbdns contains a DNS client library which you could use:

http://cr.yp.to/djbdns/dns.html

This is independent of the system DNS resolver libraries and will generate the right UDP packets. If you really wanted to get clever, you could combine it with dnscache, or look at the dnstrace utility to resolve names from root servers and see what is really going on.

You'd need to make it work on Windows, of course. Shouldn't be that hard.

I'd suggest libunbound which (together with ldns ) is a standalone library included with the Unbound recursive resolver.

It has DNSSEC validation support too, which will become useful as DNSSEC continues to get deployed.

See http://unbound.net/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM