iansison
Hello anyone who can help -
I've been using openvpn for quite a while now and only noticed this recently - Whether I put my route commands in a script specified in 'route-up', or 'up' or simply placing route commands in the configuration file, i noticed these routes already appear in the host server's routing table even before the connection is initiated with the peer (aka "Peer Connection Initiated") . The net result is there are entries in the routing table which will not work until the point to point connection is established with the server.
My question is, is there a way for me to change this behavior so that i can have these routes go up only when there is indeed a usable connection between the client and the server (aka i can ping the remote tunnel IP) I'm asking this so that i can have several routes with a metric included, and these routes would just disappear if i cannot establish a vpn between the client and the server. If that happens, lesser priority routes (higher metrics) will take over, giving better redundancy.
Is this possible at all?
Mimiko
Use client-connect, client-disconnect and route-up to add routes after client is connected.
iansison
Thanks for the tip. I'll try it out!
iansison
Hi - I took a look at client-connect, client-disconnect, and it doesn't seem to be what I need, as these settings can only be used on openvpn running as a server. What I've been trying to do is have an openvpn client connect to a server, and once the peer session is established, call a script which will set up the routes.
This is pretty much like what pppd does when a pppd client connects to a server, there is a ip-up.local script on the client which can contain route commands that configures all the routes going through the established link. The ip-up script gets called only when there is a valid connection
The closest i can see in openvpn is the route-up, up openvpn scripts, wherein one basically ends up with routes going to tun devices which are non-functional if the connection to the peer is down or drops.
Mimiko
For client you can use up and down options.