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 /etc/dnsmasq.conf1,


and in /etc/dnsmasq2.conf


Make sure you start the second copy of dnsmasq only when you activate the VPN.

  • thanks. I use a purely resolv.conf solution. is it possible to run two separate instances of that each using a different interface? – onlinespending Mar 27 '16 at 16:13
  • @onlinespending No, it is not possible to do that. – MariusMatutiae Mar 27 '16 at 19:04
  • thanks. I was able to get this to work in a slightly different fashion, though running a second instance of dnsmasq. Complete solution is detailed here http://serverfault.com/a/766290/345463 – onlinespending Mar 31 '16 at 16:40

Your Answer

