VPN Split DNS behaviour

I encountered an undesired DNS behaviour when using L2TP/ipsec VPN.

I have DHCP configured Wi-Fi connection, which send dns servers and search domain (192.168.0.10, lan) VPN sends its own DNS server (10.0.0.2), search domain (intranet) is added manually in VPN DNS config settings.

I expect, when VPN is connected, to be still able to resolve local names, i.e some-host.lan. However, they become unresolvable.

quick check shows that the remote dns server is used to resolve local names.

shilishper@mac ~ % host -v some-host.lan     
Trying "some-host.lan"
Host some-host.lan not found: 3(NXDOMAIN)
Received 106 bytes from 10.0.0.2#53 in 16 ms
Received 106 bytes from 10.0.0.2#53 in 16 ms

Actually, all dns queries are going to the remote server. I would expect that only queries for the configured domain (intranet) should go to that server. I played with the service order, but it didn't change anything.

Is anything can be done about this, programmatically?

PS new to macOS, but have extensive linux knowledge

VPN Split DNS behaviour
 
 
Q