在 Mac OS X 上以编程方式查找 DNS 服务器设置 [英] Finding DNS server settings programmatically on Mac OS X

查看:25
本文介绍了在 Mac OS X 上以编程方式查找 DNS 服务器设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些跨平台 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆