Question

From a Mac OS X app, I want to resolve some domain names using a specific DNS server (that has not been set in System Preferences), and easily retrieve the resolved addresses.

I can do this in Terminal with nslookup google.com DNS_SERVER but can't find a simple way to accomplish it in Objective-C. I though NSHost would have a similar way to specify the DNS server to resolve with, but unfortunately it doesn't.

Any suggestions as to how to go about this?

Was it helpful?

Solution

In general, on the platforms I have used including OSX, the OS built in functions to do host lookups do not allow bypassing of the system DNS configuration. If you really want to do this, you either need to try and hack the OS settings (like some windows apps unfortunately do) or connect directly to the DNS servers using sockets and your own DNS framework code.

I cant say this definitively, but Im pretty sure thats the case on OSX as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top