I need to a little program in C++ that takes the type and hostname as commandline parameters and then makes the DNS lookup. For example:
DNSapp AAAA www.google.com
would return the IPv6 address from http://www.google.com and so on.
I can do the simple A lookup just by using the gethostbyname, but I have no idea how to perform those other lookups. I’ve tried to google them, but with no success. Any ideas how to do that?
gethostbynameis obsolete, usegetaddrinfoforA / AAAAlookups.For
SRVetc I recommendldns, or the relatedlibunbound. The latter is a full resolver in a library.You could also just use
res_searchfrom the Linux standard library.