Akaks Akaks - 6 months ago 39
Linux Question

What are the APIs to get SOA record from a dns query in linux c programming?

I have used dig to see dns query related information but now I need to find some APIs for dns query by which I would be able to get specifically SOA record of my query programatically in C. Last option I can try by reading socket and parsing the format.

But if someone tell me about any function and APIs of c on linux which can provide me to fetch SOA record then that will be great for me. Thanks for the Help.


The first thing to try is the res_* API. This is part of the Unix C library since 4.3BSD, which means it's very portable (as long as you don't care about Windows) but it's also somewhat, er, inconvenient to work with (in particular you have to parse query responses with only minimal library assistance) and doesn't support shiny modern things like DNSSEC.

If you want something a little more polished you're going to have to go for a third party library; I have heard good things about Unbound but have never used it myself.