Custom DNS for specific domains

Hello, I have a company laptop thats connected to the internet without a VPN. I need to be able to resolve my company's sub domains using a specific dns server, and have all other domains resolved by the system wide name server.

In windows, this is trivial to do. In an admin powershell I run "Add-DnsClientNrptRule -Namespace ".foo.mycompany.com" -Nameserver "127.0.0.1" and resolution requests for *.foo.mycompany.com is sent to a name server running on the localhost. All other dns resolution requests are handled by the system configured resolver.

MacOS does have the /etc/resolver/ solution for this, but my understanding from these forums is that this is not the recommended approach. Note - I have tried it and it works.

AFAIU, the recommended approach is to create a system Network extension using NEDNSProxyProvider, override handleNewFlow() and do what's necessary. The issue with this solution is that it requires

  1. handling all the dns flow
  2. parsing of DNS datagrams to extract the host
  3. forwarding the datagrams to the appropriate dns server
  4. Handle responses.
  5. Deal with flow control
  6. Handle edge cases.

I was hoping for something much simpler than us needing to implement datagram parsing.

Could you please shed light on our options and how we could proceed ?

A NE DNS proxy provider could do this, but creating such a product is a non-trivial exercise. If you’re really committed to that path, let me know and we can dig into that API.

However, there are probably better ways to solve what is essentially ‘user-level’ problem. For example, you could run a local DNS server, point your Mac at that, and configure it to use different ‘upstream’ servers for different domains.

I’m not the right person to advise you about that. I have a lot of expertise in APIs, but Mac admin topics are definitely not my forte. You might have more luck over in Apple Support Community, run by Apple Support.

Another ‘user-level’ option might be deploy a com.apple.dnsSettings.managed configuration profile.

Oh, wait, there’s an NE API that’s roughly equivalent to that. Have you looked at the NEDNSSettingsManager type?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Custom DNS for specific domains
 
 
Q