Page 1 of 1

Raspbian - OpenVPN checking and automatical reconnect

Posted: Mon Jul 01, 2019 10:55 am
by sunshineh
Hi,
OpenVPN is running on my new raspbian installation.
How can I be sure, that it is running correctly and how can the internet traffic be stopped, when the connection is broken? Is there a tool for it?

Re: Raspbian - OpenVPN checking and automatical reconnect

Posted: Sat Aug 31, 2019 9:43 pm
by fdisk
This solutions works for me for ages:

1) delete defaultroute on your vpn client machine
2) add static host routes for every single vpn endpoint
Example:

Code: Select all

ip route add your.vpn.server.ip/32 via ip.of.gate.way dev eth0
3) use vpn providers dns with update-resov-conf script to prevent dns leaks

Keep in mind that you are not be able to resolve anything unless you are connected to vpn. To get around this you may need to:
- replace fqhn in openvpn configuration by their according IPs
or:
- edit /etc/hosts and add according entry

This way full internet access is only available while vpn is successfully connected. As soon as vpn is off or fails to connect there will be no access (including DNS) but to hosts having host routes (which are required to connect to tunnel).

Re: Raspbian - OpenVPN checking and automatical reconnect

Posted: Mon Sep 30, 2019 5:43 am
by JastrebJ21
Okay, thanks for the explanation, this will help me with my home automation network!

Re: Raspbian - OpenVPN checking and automatical reconnect

Posted: Mon Nov 15, 2021 12:43 pm
by josefferencik64@gmail.com
fdisk post_ wrote:
Sat Aug 31, 2019 9:43 pm
Tato řešení mi fungují po celé věky:

1) odstranit defaultroute ve vašem vpn klientském počítači 2
) přidat statické trasy hostitele pro každý jednotlivý vpn koncový
bod Příklad:

Code: Select all

ip route add your.vpn.server.ip/32 via ip.of.gate.way dev eth0

3) použijte vpn provider

dns s update-resov-conf skriptem, abyste zabránili únikům dns Mějte na paměti, že nejste schopni nic vyřešit, pokud nejste připojeni k vpn. Abyste to obešli, možná budete muset:
- nahradit fqhn v konfiguraci openvpn jejich podle IPs
nebo:
- editovat /etc/hosts a

přidat podle položky Tímto způsobem je plný přístup k internetu k dispozici pouze při úspěšném připojení vpn. Jakmile je vpn vypnuto nebo se nepřipojí, nebude k němu přístup (včetně DNS), ale k hostitelům, kteří mají hostitelské trasy (které jsou nutné pro připojení k tunelu).