How can I intercept DNS requests?

Hi,

What I want to do is be able to intercept all DNS requests a user would make. After intercepting the request, I would then send the request to my server which would then check if the domain name matches one in it's list. If it does match I want to send back another domain name or IP address.

I've looked briefly at NEDNSProxyManager. Will I be able to intercept DNS requests with this? Are there any other libraries I can use to intercept DNS requests?

Example:

  1. User tries to access "test.fakedomain.com"
  2. Intercept DNS request and send request to Server (through established web socket connection)
  3. Server responds with "not in list go to testsite.com" message if the domain name is not in it's list and the User can continue to proceed to the specified URL
  4. If the Server responds with "in list" message the User does not proceed to go to "test.fakedomain.com" and the user will go to the specified URL in the Server's message instead.

This is probably a subject that should go to Apple-specific forums, like the Apple Developer forums, or StackOverflow forums. However, based on my research, for a Release configuration, NEDNSProxyProvider/NEDNSProxyManager only work for managed Apple devices (Macs, iPhones, iPads, etc.). If you are writing this for a managed device environment, you should be all set.

jonprescott wrote:

This is probably a subject that should go to Apple-specific forums,
like the Apple Developer forums

Quite.

And when you post over on DevForums:

  • Describe your platform requirements. The story here is different for macOS, iOS, tvOS and watchOS.

  • Tag your post with NetworkExtension so that Matt and I see it.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple