libresolv

Retrieve IPv4 and IPv6 nameservers programmatically

ⅰ亾dé卋堺 提交于 2019-12-02 18:13:53
问题 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

Retrieve IPv4 and IPv6 nameservers programmatically

谁说胖子不能爱 提交于 2019-12-02 10:10:24
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.h> int main(int argc, char** argv) { res_state res = malloc(sizeof(struct __res_state)); res_ninit(res)