[OpenVPN] Verbindungsreihenfolge für mehrere Server

RedSkall

Cadet 4th Year
Registriert
Sep. 2005
Beiträge
91
Hi,

habe folgende Situation:

im Büro steht ein Rechner zu dem ich mich entweder unterwegs über Internet oder lokal im Büro verbinde (Baue in beiden Fällen eine OpenVPN Verbindung auf).
Je nach dem ob ich mich lokal oder übers Internet zum Rechner verbinde hat er unterschiedliche IP Adressen (entweder 192.168.0.100 oder ein DNS-Name).

Kann ich in der OpenVPN Konfiguration nicht einstellen dass er erst versuchen soll nach 192.168.0.100 zu verbinden und wenn das nicht geht zum DNS-Namen? Am besten noch mit Timeout ;)

Gruß,
Marco
 
dat ganze liesse sich mit batch recht einfach loesen

z.b. if ping 192.168.0.1 timed ( errorlevel ) out call openvpn externnetwork.conf
brauchste halt 2 configs die identisch sind, bis auf die server ip.

annerseits kannse die configs auch einfach kopieren
dir 2 batch dateien anlegen aufm desktop und je nachdem wo du bist, eine der beiden aufrufen :P
wäre eh die schnellste lösung.
 
Das mit der Batchdatei gefällt mir :) könnte man sich ja sogar nen kleines Programm für schreiben..

Zur Zeit hab ich zwei Verknüpfungen aufm Desktop liegen. Auch nur unterschiedliche IP's drin ;)

Aber ne "professionellere" Lösung gibts ehr nicht? Meine etwas was OpenVPN selber macht, ohne Hilfe einer Batch-Dateo o.Ä.?

Sonst probier ich das mal so..

Gruß,
Marco
 
ist zwar "professioneller", aber beachte auch, das eine verbindung länger dauert, da ja erst eine überprüfung vorgenommen werden muss. ich würd sagen mit den 2 verknüpfungen wäre mann besser bedient :-)
 
Würde bestimmt gar nicht mal so lange dauern:

Pinge erst die lokale Adresse. Wenns möglich ist stelle ich da ein Timeout von zwei Sekunde ein (muss im lokalen Netz ja sehr schnell gehen). Wenn er nichts findet dann versucht er es über den DNS..

Aber bin doch bestimmt nicht der Erste der nach so ner Lösung sucht!? Was machen alle Anderen? ^^
 
naja, allein das testen des pings..also ne sekunde verzoegerung haste bestimmt :-)

vll hilft auch einfach das: openvpn doku lesen
mplementing a load-balancing/failover configuration
Client

The OpenVPN client configuration can refer to multiple servers for load balancing and failover. For example:

remote server1.mydomain
remote server2.mydomain
remote server3.mydomain

will direct the OpenVPN client to attempt a connection with server1, server2, and server3 in that order. If an existing connection is broken, the OpenVPN client will retry the most recently connected server, and if that fails, will move on to the next server in the list. You can also direct the OpenVPN client to randomize its server list on startup, so that the client load will be probabilistically spread across the server pool.

remote-random

If you would also like DNS resolution failures to cause the OpenVPN client to move to the next server in the list, add the following:

resolv-retry 60

The 60 parameter tells the OpenVPN client to try resolving each remote DNS name for 60 seconds before moving on to the next server in the list.

The server list can also refer to multiple OpenVPN server daemons running on the same machine, each listening for connections on a different port, for example:

remote smp-server1.mydomain 8000
remote smp-server1.mydomain 8001
remote smp-server2.mydomain 8000
remote smp-server2.mydomain 8001

If your servers are multi-processor machines, running multiple OpenVPN daemons on each server can be advantageous from a performance standpoint.

OpenVPN also supports the remote directive referring to a DNS name which has multiple A records in the zone configuration for the domain. In this case, the OpenVPN client will randomly choose one of the A records every time the domain is resolved.
Server

The simplest approach to a load-balanced/failover configuration on the server is to use equivalent configuration files on each server in the cluster, except use a different virtual IP address pool for each server. For example:

server1

server 10.8.0.0 255.255.255.0

server2

server 10.8.1.0 255.255.255.0

server3

server 10.8.2.0 255.255.255.0

dasopenvpn so eine funktion besitzt, hätt eigentlich au klar sein muessen..
 
Zuletzt bearbeitet:
Das mit der Doku lesen ist ne super Idee :D Hab da was gefunden...

<connection>
Define a client connection profile. Client connection profiles are groups of OpenVPN options that describe how to connect to a given OpenVPN server. Client connection profiles are specified within an OpenVPN configuration file, and each profile is bracketed by <connection> and </connection>.

An OpenVPN client will try each connection profile sequentially until it achieves a successful connection.

--remote-random can be used to initially "scramble" the connection list.

Here is an example of connection profile usage:

client
dev tun

<connection>
remote 198.19.34.56 1194 udp
</connection>

<connection>
remote 198.19.34.56 443 tcp
</connection>

<connection>
remote 198.19.34.56 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>

<connection>
remote 198.19.36.99 443 tcp
http-proxy 192.168.0.8 8080
http-proxy-retry
</connection>

persist-key
persist-tun
pkcs12 client.p12
ns-cert-type server
verb 3

First we try to connect to a server at 198.19.34.56:1194 using UDP. If that fails, we then try to connect to 198.19.34.56:443 using TCP. If that also fails, then try connecting through an HTTP proxy at 192.168.0.8:8080 to 198.19.34.56:443 using TCP. Finally, try to connect through the same proxy to a server at 198.19.36.99:443 using TCP.

The following OpenVPN options may be used inside of a <connection> block:

bind, connect-retry, connect-retry-max, connect-timeout, float, http-proxy, http-proxy-option, http-proxy-retry, http-proxy-timeout, local, lport, nobind, port, proto, remote, rport, socks-proxy, and socks-proxy-retry.


A defaulting mechanism exists for specifying options to apply to all <connection> profiles. If any of the above options (with the exception of remote ) appear outside of a <connection> block, but in a configuration file which has one or more <connection> blocks, the option setting will be used as a default for <connection> blocks which follow it in the configuration file.

For example, suppose the nobind option were placed in the sample configuration file above, near the top of the file, before the first <connection> block. The effect would be as if nobind were declared in all <connection> blocks below it.

Für mich wär dann bestimmt der Parameter connect-timeout wichtig. Das werde ich dann erstmal testen :)

Gillt allerdings nur für OpenVPN 2.1!

Hier nochmal die ganze Doku: Link

Danke!!

Gruß,
Marco
 
Zurück
Oben