C
C
CAJAX2010-10-12 20:42:33
openvpn
CAJAX, 2010-10-12 20:42:33

Limit OpenVPN routing to one network

There is an Ubuntu machine that connects via OpenVPN to a working network, the IP is given by DHCP and is always different. Now all traffic goes through the VPN server, regardless of destination. For example, surfing or torrents.

I would like to restrict routing so that traffic intended directly for the work network and no other goes through the VPN connection.
In theory, I can write a simple script that will delete the paths created by the OpenVPN client and recreate new ones, but I think there is already some kind of ready-made solution that I simply did not find.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
digreen, 2010-10-12
@digreen

configure routing on the destination host. default through the provider, routes to "tunneled" networks through vpn-peer. in general, it seems like, by default, openvpn works like that. if at you it gives a default to the client it is corrected in a config.

P
pietrovich, 2010-10-12
@pietrovich

so in OpenVPN it is possible to do settings per user.
set client-config-dir, add personal configs for different users in it. we write common routes in the server config, additional to each as needed, and when connecting, the client receives only what is set for him. who does not need a gateway will not receive it. True, you will have to move the distribution of gateways to individual settings if it was previously pushed from the general config. or look for how to “overwrite” it in the client, maybe there is such an opportunity, yes, I don’t know about it

F
faust0, 2010-10-12
@faust0

Try adding to the client config:
route-nopull
route 192.168.0.0 255.255.255.0
where 192.168.0.0 255.255.255.0 is your work network.

S
Sergey, 2010-10-12
@bondbig

on the openvpn server:
* remove (comment) the option push "redirect-gateway"
* restart the openvpn service
* rejoice.

A
asm0dey, 2010-10-12
@asm0dey

I did like this:

sudo apt-get install network-manager-openvpn-gnome<pre>
In the network manager, import the .ovpn file (with OpenVPN settings)
In the properties of the VPN connection, go to "IPv4 Settings", there routes (Routes) -\u003e Put a checkmark on "Use this connection only for resources ..."

If you need DNS - In the IPv4 settings In the profile, set (Automatic, VPN - only the address) and prescribe the DNS server.
In order for my DNS to work, I had to reboot. The routes started working immediately after the connection.

C
CAJAX, 2010-10-13
@CAJAX

Thank you all very much! :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question