tags:

views:

783

answers:

3

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.

For instance SCDynamicStoreCopyDHCPInfo returns some of the dynamic DHCP related data but not the DNS server addresses.

+4  A: 

You can use the SystemConfiguration framework. It's in C.

Update: apparently the rest of the web is harder to use than I thought. Search for the key "State:/Network/Service/ServiceID/DNS" where ServiceID is the ID of the service.

Graham Lee
Ok, I've initially trying SCDynamicStoreCopyDHCPInfo and that gets me the current IP address and netmask + a few other things I don't understand, but not the DNS servers. Is there any chance you can be more specific?
A: 

They are also available from /etc/resolv.conf

Rizwan Kassim
A: 

You could read from /etc/resolv.conf.

Sherm Pendley