在Mac OS X上以编程方式查找DNS服务器设置 [英] Finding DNS server settings programmatically on Mac OS X
问题描述
我有一些跨平台的DNS客户端代码,我用来做端到端SMTP和Windows我可以通过查看注册表找到当前的DNS服务器的IP地址。在Mac上,我可以使用第一个答案中提到的SystemConfiguration框架,但是这样做的确切方法并不明显。
I have some cross platform DNS client code that I use for doing end to end SMTP and on windows I can find the current DNS server ip addresses by looking in the registry. On the Mac I can probably use the SystemConfiguration framework as mentioned in the first answer, however the exact method of doing so is not immediately obvious.
例如SCDynamicStoreCopyDHCPInfo返回一些动态DHCP相关数据而不是DNS服务器地址。
For instance SCDynamicStoreCopyDHCPInfo returns some of the dynamic DHCP related data but not the DNS server addresses.
推荐答案
他们也可以从
/ etc / resolv .conf
They are also available from /etc/resolv.conf
这篇关于在Mac OS X上以编程方式查找DNS服务器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!