Split DNS on OpenVPN
I have found some old threads regarding this, but they seems to be some years old. E.g. openVPN - Split-tunneling DNS priority
I'm on Windows.
I'm connected to a local network with local DNS.
I use OpenVPN to connect to another network, this network have resources available at *.example.com.
Is it even possible to have one DNS for *.example.com and another for everything else? I know I can setup a local DNS on my machine to solve it, or enter all the hostnames of example.com in my local hosts-file.
Solution 1:
I am afraid it is not possible as DNS resolver do the work independently on what you are resolving...
On Windows there is one "feature" that default metric on interface is used also to priority (order) setting related to DNS server(s) which to use for resolving. So based on which DNS server (if local one or on VPN reachable network) you are planning to use you should set up default metric on TAP interface before the connection is established.
Only option could be (depends on specific behaviour of resolver) to set up DNS server on VPN to resolve only specific domains and not do recursion. So once the DNS server doesn't offer answer "for the rest of zones" it may be possible that local DNS resolver on the system can try next DNS server. So for sure once the VPN's DNS server (at least for the view) will do the recursion the other DNS server will not be used... Anyway this behaviour on DNS resolver side (client) may vary on implementation :-(.
Solution 2:
Most VPN clients have a setting to override the DNS server settings when you open the VPN connection, but this will forward all DNS queries to the corporate DNS servers. Having different conditional forwarders for different domains is only possible if you run a DNS server on the machine running the VPN.