Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 如何找到Mac机器的DNS服务器IP地址?_Cocoa_Ip Address - Fatal编程技术网

Cocoa 如何找到Mac机器的DNS服务器IP地址?

Cocoa 如何找到Mac机器的DNS服务器IP地址?,cocoa,ip-address,Cocoa,Ip Address,我可以使用: [[[NSHost currentHost] addresses] objectAtIndex:0] 但我还需要我的Mac机器的DNS服务器IP地址。知道如何使用Cocoa应用程序获取Mac电脑的DNS服务器IP地址吗???Amrinder 我想我找到了一个可以帮助你解决问题的链接。检查 您应该能够从那里为本地MAC检索所需的信息。我通过运行命令“netstat-rn”并读取该命令的输出来实现。并从该命令的输出中查找默认网关。您想做什么?请更准确地解释你的需求。为什么您需要在应用

我可以使用:

[[[NSHost currentHost] addresses] objectAtIndex:0]
但我还需要我的Mac机器的DNS服务器IP地址。知道如何使用Cocoa应用程序获取Mac电脑的DNS服务器IP地址吗???

Amrinder

我想我找到了一个可以帮助你解决问题的链接。检查


您应该能够从那里为本地MAC检索所需的信息。

我通过运行命令“netstat-rn”并读取该命令的输出来实现。并从该命令的输出中查找默认网关。

您想做什么?请更准确地解释你的需求。为什么您需要在应用程序中使用DNS服务器???@QwertyBob 1)我接受了对我有用的答案。你可以看到我的问题。2) 我的系统通过LAN卡连接到网络。我们网络中的每个系统都有一个系统的IP地址和一个服务器的DNS服务器IP,DNS服务器IP与系统的IP地址不同。我可以在系统首选项>网络>以太网中看到这一点。@LivingSkull我在应用程序中使用了LAN同步的概念。为此,我需要服务器的IP地址,以便确定两个或更多系统是否来自同一网络。