How might I perform DNS lookups using C/C++ on Linux? How might I perform DNS lookups using C/C++ on Linux? linux linux

How might I perform DNS lookups using C/C++ on Linux?


If a blocking (synchronous) query is ok, just use res_query(), and link your program with -lresolv.

 len = res_query(host, C_IN, T_MX, &answer, sizeof(answer));


I'd suggest FireDNS. It's a very fast C library for all kinds of dns queries.


I know that the question is old, but I have long searched a dns library, and all answers here just stubs me. I think libraries like adns/udns have written not for human beings. And FireDNS for a long time have not working download links.

I have found poslib as the best dns library with very easy interface.