0

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

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

2 Answers 2

0

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>
6
  • 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, 2013 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, 2013 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, 2013 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, 2013 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, 2013 at 12:06
0

To access different paths as you want, just change the file clent.ovpn or clien.conf depending on whether it is windows or linux and open the path you want to reach

route 192.168.100.0 255 255.255.255.0

with this command you should be able to connect

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Feb 11, 2023 at 17:18

You must log in to answer this question.

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