ANSI C How to get the name server (DNS) address in Linux?

I want to use local DNS addresses in my codes and am looking for the library that created it. Is there something similar or do I need to analyze /etc/resolv.conf myself?

thank

+5
source share
2 answers

You can use the recognizer functions as described in the answer to this question or read the nameserver addresses from a file /etc/resolv.conf, which is a simple text file, for example

# Generated by NetworkManager
nameserver x.x.x.x
nameserver y.y.y.y

where x.x.x.xand y.y.y.yare the IP addresses.

+5
source

All Articles