问题描述
使用C ++,我想获得主机为三个操作系统使用的DNS服务器:OS X,FreeBSD和Windows。我想确认下面的方法确实是最佳实践,如果没有,那是一个优秀的选择。
- OS X :
- Windows :
- FreeBSD :
/etc/resolv.conf
感谢您的帮助!
在许多unix系统(linux,bsd)上,您可以使用解析器函数获取DNS服务器列表:。
调用 res_init();
后,初始化解析器结构。解析器结构存储您需要的所有信息。 DNS服务器的列表存储在结构条目 nsaddr_list
中。
解析器结构的确切规格可以可能在 resolve.h
中找到。
使用解析器函数是获取DNS列表的首选方式服务器。 res_init()
将很可能用 /etc/resolv.conf
中的信息填充解析器结构。 p>
Using C++, I would like to obtain the DNS servers being used by a host for three operating systems: OS X, FreeBSD, and Windows. I'd like confirmation that the approaches below are indeed best practice, and if not, a superior alternative.
- OS X: already answered; updated link at developer.apple.com
- Windows:
GetNetworkParams
- FreeBSD:
/etc/resolv.conf
Thanks in advance for your help!
On many unix systems (linux, bsd) you can use the resolver functions to obtain the list of DNS servers: man 3 resolver.
After calling res_init();
the resolver structure is initialized. The resolver structure stores all the information you need. The list of DNS servers are stored in the struct entry nsaddr_list
.
The exact specification of the resolver structure can most likely be found in resolve.h
.
Using the resolver functions is the preferred way to obtain the list of DNS servers. res_init()
will most likely fill the resolver structure with the information found in /etc/resolv.conf
.
这篇关于以编程方式获取主机的DNS服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!