2

I have a container which routes all its traffic via OpenVPN. This is done by OpenVPN via a combo of

0.0.0.0/1 via 10.8.8.17 dev tun0 
128.0.0.0/1 via 10.8.8.17 dev tun0 

which masks the default route (which is still there when OpenVPN shuts down)

I need to explicitly add a route for a local network which would direct packets via eth0 and not tun0.

This is manually done via

ip route add 10.10.10.0/24 via 10.10.11.254 dev eth0

after OpenVPN has started.

How can I do that automatically upon OpenVPN start?

I tried to add

route 10.10.10.0 255.255.255.0

to mu .ovpn config file, but this leads to a new route via tun0 (which is quite understandable as there was no specific information about the NIC to route through - but I did not see anything available in the doc either)

# ip route
(...)
10.10.10.0/24 via 10.8.8.17 dev tun0 

Is what I want to achieve doable though OpenVPN configuration or do I need to do it somehow outside the OpenVPN startup process?

1
  • 1
    One thing is not clear. If it is a locally reachable network, why you can't have a persistent local route to it irrespective of openvpn?
    – Diamond
    Mar 31 '16 at 9:01
2

If it is a locally reachable network, then you can just have a persistent local route to it irrespective of openvpn and should work as expected. Depending on your system, you can configure the route so that it will be loaded when the relevant interface is up.

1
  • I was hoping to be able to keep that information in the .ovpn file (to keep it in a source management system) but otherwise, yes, this is what I meant by I need to do it somehow outside the OpenVPN startup process. Thanks.
    – WoJ
    Mar 31 '16 at 13:37
0

OpenVPN files can reference shell scripts to be executed when a tunnel is enabled or disabled using the up and down directives.

Example:

up on-up.sh
down on-down.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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