using the very informative and detailed answer to this topic, Route the traffic over specific interface for a process in linux, I was able to selectively choose whether to run a process through a 3rd party VPN or not. The only issue I have is that all processes will still use the 3rd party VPN's DNS servers since /etc/resolv.conf is updated when the VPN connection is established. How can I have traffic directed through the VPN's gateway use its DNS server and traffic directed through my LAN's gateway use it or Google's nameservers as the DNS server?
So long as you use a single program, there will be no way to achieve that.
You may however run two separate instances of the DNS program, say
dnsmasq, specifying for either program a different listening interface. For instance, n
and in /etc/dnsmasq2.conf
Make sure you start the second copy of
dnsmasq only when you activate the VPN.