how can I get the original dns information on iOS.

Hello,

I am developing a Network Extension on iOS, I have a problem. After my VPN started, I want to know whether the original dns changed. I know that the functions in <resolv.h> can get the current dns information, but it seems these functions are based on file resolv.conf, after the VPN established, the dns will be replaced by the VPN settings, so I can not get the original dns settings any more. Is there a workaround to get the information.

Then


Thanks!

I know that the functions incan get the current dns information …

That’s not true, alas. There is no API that will get you a full view of the device’s DNS setup. The legacy

<resolv.h>
API doesn’t suffice because it can only return a single list of DNS servers, and iOS’s is much more complex than that.

What you’re high-level goal here? What do you need the original DNS configuration for?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hello eskimo,


Thanks for your quick reply. I am trying to implement a dns proxy on iOS(you can think add some policy on dns resolving), I need the original dns information to do the real DNS resolving, and for some reason, I can not use the high level functions such as gethostbyname or getaddinfo. Are there workaround?


thanks.

Have you looked at

NEDNSProxyProvider
? That’s the recommended way forward here, and it does give you access to the system’s basic DNS configuration (via the
systemDNSSettings
property).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

it seems NEDNSProxyProvider can only be used on managed devices, right?

it seems NEDNSProxyProvider can only be used on managed devices, right?

Actually, it’s worse than that )-: Currently

NEDNSProxyProvider
is only available on supervised devices. I’m hoping that we will lift that restriction (r. 34843801) but, alas, I can’t predict when it’ll happen.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
how can I get the original dns information on iOS.
 
 
Q