Server Fault is a question and answer site for system and network administrators. 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 have a local network on 192.168.1.0 with netmask 255.255.255.0. When I connect to a VPN though OpenVPN (as a client), it pushes a route for 192.168.1.0 that clobbers the existing one, making my local network inaccessible. I don't to access anything on 192.168.1.0 on the remote machine; I'd like to just ignore it, while accepting the other routes that are pushed. My client is Ubuntu 10.10.

How can I skip the one offending route?

share|improve this question
up vote 3 down vote accepted

Use the

--route-up --route-noexec

option in openvpn and completely ignore the routes being pushed to you, instead adding static routes to the specific hosts you want to access through the tunnel.

openvpn --route-noexec --route-up /tmp/myscript --config ./client.ovpn

where /tmp/myscript is

route add -host 192.168.1.69 gw ${route_net_gateway}

Something similar to that, I haven't actually tested this but it should work. You probably want to remove the routes when you disconnected as well.

share|improve this answer

Is your local network very big? It might be simplest just to renumber your network to a non-conflicting range.

Otherwise, you could wrap your openvpn startup command in a script that fixes the route after OpenVPN is started up.

share|improve this answer

In addition to @hellomynameisjoel's answer, note that you can access the pushed routes in the route-up script via environmental variables. So you can add necessary routes only.

Alternatively, you can add a route using the default gateway in the OpenVPN config file:

route 192.168.1.0 netmask 255.255.255.0 net_gateway

After this, adding an identical pushed route will fail.

P.S. Tested on ArchLinux/OpenVPN 2.3.5.

share|improve this answer

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.