ANSI C How to get name server (DNS) address in linux? [duplicate]
I want to use in my code local DNS addresses and am looking for a library that would produce it. Is there anything like it or do I have to parse /etc/resolv.conf myself?
Thanks
You can use the resolver functions as described in the answer to this question or read the addresses of name servers from the file /etc/resolv.conf
which is a simple text file, such as
# Generated by NetworkManager
nameserver x.x.x.x
nameserver y.y.y.y
where x.x.x.x
and y.y.y.y
are ip addresses.
Check http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Fresninit.htm for some sample code.
精彩评论