I have a MacBook Pro running macOS 10.14.6 that is frequently connected to a privacy-focused VPN that tunnels all non-local traffic and handles all DNS requests. However there is one hostname that I would like my local network's DNS server to handle (as specified by the local DHCP server). The reason is that depending on which local network my MacBook Pro is connected to this hostname may resolve to a local IP address, and in that case I don't want traffic to it to be tunneled through the VPN.
I've learned that I can override what DNS server is used to resolve a domain name by creating a file at
/etc/resolver/hostname.domain and with the contents
nameserver [ip address] where
hostname.domain is the fully qualified domain name. However that only works if the IP address of the DNS server I want to use remains consistent. What I want it to do is use whatever DNS server is served by my local network's DHCP server.
Is there any way I can accomplish this using existing features of macOS or third party software?
In case it's relevant, the VPN's DNS server is provided and setup at connection time, and is not guaranteed to be the same IP address every time.
(I could write a script to do this by having it run whenever the network connection changes, checking the system's current local IP address, and then changing the
/etc/resolver/hostname.domain file to point to the correct server but I'm trying to avoid having to do that work if possible!)