Configuration flexibility enhancement suggestion.
Hello, James!
First and foremost - THANK YOU! for the great product OpenVPN is.
Some background. Often I have to connect from the LANs where the only outbound traffic allowed is HTTPS through their proxy. But if I'm on a more user-friendly environment, I use plain UDP. On my server I have the separate instances of OpenVPN running and waiting for it's own type of connection each.
So, on my laptop (winXP-SP2) as a roadwarrior, often I need to tune the service mode on the run. This happens when I must switch to TCP from the default UDP mode. In TCP mode I must remove "fragment XXXX" for example. Also, when in TCP, I must uncomment the proxy-related section.
This is rather inconvinient and insecure - I run OpenVPN as non-admin with "client.ovpn" being protected from mortals by file permissions.
The way to radically improve the configuration flexibility and convinience might be as follows:
rather than naming the "remote" side list where each entry is just an IP:port and is tryed in turn with all the rest of configuration file common - introduce the list of "contexts" - the logical name of the whole settings needed to connect to the particular remote service. If the first entry fails - try the next.
The possible layout of the configuration file might look like this:
[contexts]context_name_1context_name_2
....context_name_N
[context_name_1]
...here go all the relevant settings to use with this particular connection...
[context_name_2]
...again the whole set of what must be used for that one...
[context_name_N]
...and so on...
The "context_name_N" is just a label. With this scheme it would be possible to have even the conflicting settings (relevant for different connections) in one file without a need to edit it in the field.
Further improvement could be a "context_policy" parameter that would switch between the round-robin and "try again from the top of the list" behaviour (or even have a "try context_name_K next" command). I place my connections in the order of preference.
Please comment on the idea.
Tony.
Why not just have separate config files for each possible configuration, rather than stuffing several configurations in one file?
The configurations could be set to exit on failure, and a wrapper script (supervised by runit or a similar tool) could be responsible for rotating between them.
Quoted 1 line · Charles Duffy
Why not just have separate config files for each possible configuration, rather than stuffing several configurations in one file?
I did not know if it is possible on the client.
Quoted 1 line
The configurations could be set to exit on failure, and a wrapper script (supervised by runit or a similar tool) could be responsible for rotating between them.
The idea is based on what I see in the openssl configuration file regarding the certificate generation of different types ("client" vs "server"), for example.
Tony.
Quoted 4 lines · Tony
Quoted 1 line · Charles Duffy
Why not just have separate config files for each possible configuration, rather than stuffing several configurations in one file?
I did not know if it is possible on the client.
Well, there's nothing about OpenVPN itself that makes it possible, and plenty about what folks can do with shell scripts or small, easy-to-write snippets of 3rd-party wrapper code that makes it possible.
Since OpenVPN tends to rely quite a bit on shelling out to hooks to add new functionality, having OpenVPN itself be started by a wrapper that rotates configurations isn't a very big leap.
Now, if your clients are on Windows and don't have something like Cygwin installed (and if the Windows Scripting Host isn't flexible enough for this kind of thing, which it may or may not be), writing that wrapper may be a little bit trickier than it would be otherwise... but it still should be a fairly straightforward exercise.
Another option -- if clients are using the OpenVPN GUI -- is just to have the different .conf files be named after the different locations they may be at, and let them manually select the one to start from the menu.
Quoted 1 line · Charles Duffy
Another option -- if clients are using the OpenVPN GUI -- is just to have the different .conf files be named after the different locations they may be at, and let them manually select the one to start from the menu.
I'm indeed a GUI user!
What a shame I did not try this simple method first... Thank you for the advise!
Gone testing...
Tony.