Retrieve IPv4 and IPv6 nameservers programmatically
问题 I'm trying to use libresolv to read both the IPv4 and IPv6 nameservers in my /etc/resolv.conf file: # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run "systemd-resolve --status" to see details about the actual nameservers. nameserver 127.0.0.53 nameserver 2001:4860:4860:0:0:0:0:8888 This is my C program: #include <resolv.h> #include <stdlib