How do I get similar functionality to the host
command using a c api (or any other language for that matter)? I need more information than just an IP address given by gethostbyname()
; specifically, the SMTP-related data.
The dig command in Linux is used to gather DNS information. It stands for Domain Information Groper, and it collects data about Domain Name Servers. The dig command is helpful for troubleshooting DNS problems, but is also used to display DNS information.
Go to Start and type cmd in the search field to open the command prompt. Alternatively, go to Start > Run > type cmd or command. Type nslookup and hit Enter. The displayed information will be your local DNS server and its IP address.
nslookup (from name server lookup) is a network administration command-line tool for querying the Domain Name System (DNS) to obtain the mapping between domain name and IP address, or other DNS records.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With