Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 1.2.3.4 through OpenVPN server. So what route option will be? I tried this modification of client's config:

route-gateway MY_ISP
route 1.2.3.4 255.255.255.255 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 5.5.10.1,dhcp-option DNS 5.5.10.1,
register-dns,comp-lzo yes,ifconfig 5.5.10.91 255.255.254.0

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

share|improve this question

migrated from serverfault.com Apr 12 '13 at 16:47

This question came from our site for professional 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

1 Answer 1

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 109.203.99.14 5.5.12.1 if 19 where 109.203.99.14 ip of getmyipaddress.org (for testing), 5.5.12.1 is gateway in OpenVPN adapter and interface 19 is interface of OpenVPN TAP adapter. This command adds route but nothing changes - getmyipaddress.org 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 109.203.99.14 is destination network (with mask 255.255.255.255), and 5.5.12.1 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 64.20.55.138) 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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