I'm using OpenVPN on Windows with a TAP adapter.

I know you can specify a route to a specific ip address to go to your local internet connection. However it can't do the same for a hostname/domain.

Is there a way to keep my traffic on the VPN but route requests to www.google.com for example through my default gateaway at home ( in my case)?

I was thinking that I could set www.google.com in my HOSTS file and run a local apache and deal with a ruleset in there, but I'd rather not have to run a local webserver/proxy if there is another way I don't know about.


You can specify a route to a host name only if you use --allow-pull-fqdn details can be found in The OpenVPN Manual

  • 1
    Looks like something I'm looking for but the documentation isn't very clear on how to use this. Do you maybe have an example on how I would route traffic to lets' say www.google.com through my local adapter instead of the openvpn one? Do I edit the .ovpn file with: push "route www.google.com" --allow-pull-fqdn – Jack Skinner Sep 24 '15 at 2:44

You can add this to the .ovpn file:

route www.google.com net_gateway

Then on openvpn startup this will lookup www.google.com, get it's IP address, and then add a route for that using the net (not VPN).

The problem is, google uses multiple IP addresses, so when you try to visit google it will still use the VPN unless you happen to hit the same IP address it looked up when it started.

One hack is to get one of the IP addresses that google uses and add it to your /etc/hosts, so then your machine will always use the same IP address for google, and the openvpn route command will accomplish what you want.

Problem is, of course, if google ever stops using that IP address or, for whatever reason, wants to route you to a different IP address. Then it fails.

  • what if it is a CDN and multiple domains use the same IP address, but you want to use the VPN only for one of them? – Karthik T Jul 25 '18 at 2:18
  • Don't know - you'd have to test it to see if openvpn is storing the IP or the domain name for comparison - I would assume it's the IP address. – David Ljung Madison Jul 27 '18 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.