Amrinder Singh
Amrinder Singh

Reputation: 215

How to find DNS Server IP address of Mac machine?

I can find IP address of my Mac machine using:

[[[NSHost currentHost] addresses] objectAtIndex:0]

But I also want DNS Server IP address of my Mac machine. Any idea how can I get DNS Server IP address of my Mac machine with my Cocoa application??

Upvotes: 0

Views: 1015

Answers (2)

Amrinder Singh
Amrinder Singh

Reputation: 215

I did it by running command "netstat -rn" and read output of this command. And find default gateway from output of this command.

Upvotes: 0

Living Skull
Living Skull

Reputation: 136

Amrinder,

I think I have found a link that could help you to solve the problem. Check Apple's System Configuration Framework

You should be able to retrieve the needed information from there, for you local MAC.

Upvotes: 1

Related Questions