Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to connect to various streaming sites from outside US. So I using one of OpenVPN provider to do so. Default config file from provider redirects through OpenVPN all traffic. I want to change config file to redirect through OpenVPN server only selected ip addresses. All other traffic must go through my ISP. How can I archive this? Can you give me real examples? For example, I need to redirect ip through OpenVPN server. So what route option will be? I tried this modification of client's config:

route-gateway MY_ISP
route vpn_gateway
redirect-gateway def1

But I failed.

Pushed options from OpenVPN provider:

PUSH_REPLY,explicit-exit-notify,topology subnet,route-delay 5 30,
dhcp-pre-release,dhcp-renew,dhcp-release,route-metric 101,ping 5,
ping-restart 40,redirect-gateway def1,redirect-gateway bypass-dhcp,
redirect-gateway autolocal,route-gateway,dhcp-option DNS,
register-dns,comp-lzo yes,ifconfig

P.S. : Client OS is Windows 7/8

share|improve this question

migrated from Apr 12 '13 at 16:47

This question came from our site for system and network administrators.

What's the client OS? – MadHatter Apr 12 '13 at 16:17
Client OS is Windows 7/8 – Tarhan Apr 12 '13 at 16:56

I think you'll have to insert routing entries by hand, or write a batch file doing this and stick it into the client's config:

script-security 2
up yourscript.bat

(or route-up yourscript.bat instead).

In the script, you should do something like

route add <dest_network> mask <dest_net_mask> %route_vpn_gateway%

See the manual for more info (the environment variables are explained in the "Environmental Variables" section).

You might want to also set up a matching down script which would delete the routes the up script installed — using

route delete <dest_network>
share|improve this answer
OK. About bat files i understand. But what about decrease default priority of vpn_gateway? I do like you said default gateway is still VPN. But I want my ISP to be default, and VPN only for routes that i add manually like you said. – Tarhan Apr 12 '13 at 20:20
@Tarhan, two points: first, the route-nopull seems to enable the client to ignore any routing information passed by the server. Second, the route directive allows to set routes without resorting to up scripts. – kostix Apr 12 '13 at 21:31
route-nopull indeed disable vpn server as default gateway. But now i could not create correct route to redirect connection to specific destination via VPN. I tried commands like route add if 19 where ip of (for testing), is gateway in OpenVPN adapter and interface 19 is interface of OpenVPN TAP adapter. This command adds route but nothing changes - still displaying my ISP ip address. – Tarhan Apr 12 '13 at 23:22
@Tarhan, that's not how IP routing works! You should set specific routing entries for destination networks you want to be accessed using VPN. There's no sense in specifying the public IP address provided by your VPN connection as a routing entry. Also please note what I've written in my previous comment: OpenVPN seems to allow setting up routes directly -- see it's route directive. – kostix Apr 13 '13 at 11:06
I think we do not understand each other. In mentioned route command example is destination network (with mask, and is internal VPN gateway ip address as it seen in VPN network adapter properties (public ip provided by OpenVPN provider and as seen by destination is About latter sentence. I already know about route directive within OpenVPN. But in Windows it just calls Windows' route command like I wrote. – Tarhan Apr 13 '13 at 12:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .