My Raspberry Pi (Raspbian 2015-05-05) should always be connected to a VPN server.
It works quite well. However, it
doesn't always reconnect back to the VPN server if there is a
networking problem, i.e.:
- A cable (e.g. LAN) gets removed (and later reconnected)
- DSL Router loses internet connection (and later connects back to the internet)
My setup:
[[Raspberry Pi]] -----> [[DSL Router]] -----> [[Internet]]
OpenVPN version:
$ openvpn --version
OpenVPN 2.3.7 armv6l-unknown-linux-gnueabihf [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Jun 14 2015
library versions: LibreSSL 2.2.0, LZO 2.09
Originally developed by James Yonan
Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
Compile time defines: enable_crypto=yes enable_crypto_ofb_cfb=yes enable_debug=yes enable_def_auth=yes enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown enable_fast_install=yes enable_fragment=yes enable_http_proxy=yes enable_iproute2=no enable_libtool_lock=yes enable_lzo=yes enable_lzo_stub=no enable_management=yes enable_multi=yes enable_multihome=yes enable_pam_dlopen=no enable_password_save=yes enable_pedantic=no enable_pf=yes enable_pkcs11=no enable_plugin_auth_pam=yes enable_plugin_down_root=yes enable_plugins=yes enable_port_share=yes enable_selinux=no enable_server=yes enable_shared=yes enable_shared_with_static_runtimes=no enable_small=no enable_socks=yes enable_ssl=yes enable_static=yes enable_strict=no enable_strict_options=no enable_systemd=no enable_win32_dll=yes enable_x509_alt_username=no with_crypto_library=openssl with_gnu_ld=yes with_mem_check=no with_plugindir='$(libdir)/openvpn/plugins' with_sysroot=no
git revision: refs/heads/master/47ae6fd123cf1ca2
OpenVPN gets started like this (on the Raspberry Pi):
sudo openvpn --client --config /my-path/myconfig.ovpn --script-security 2 --log-append /my-path/mylog.txt --keepalive 6 30 &
/my-path/myconfig.ovpn:
client
dev tun
proto udp
remote 111.111.111.111 8080
remote 222.222.222.222 8080
remote-random
resolv-retry infinite
nobind
persist-key
persist-tun
tls-client
remote-cert-tls server
comp-lzo
verb 1
ca /my-path/ca_rsa4096.crt
crl-verify /my-path/ca.crl
auth-user-pass /my-path/auth.txt
route-up /my-path/route-up.sh
down-pre
down /my-path/down.sh
/my-path/route-up.sh:
#!/bin/sh
sudo iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE
/my-path/route-up.sh:
#!/bin/sh
sudo iptables -t nat -D POSTROUTING -o tun0 -j MASQUERADE
If there are said networking issues,
/my-path/mylog.txt logs:
Sun Jun 14 18:49:09 2015 [VPN Provider Name Here] Inactivity timeout (--ping-restart), restarting
Sun Jun 14 18:49:09 2015 SIGUSR1[soft,ping-restart] received, process restarting
Sun Jun 14 18:49:11 2015 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sun Jun 14 18:49:11 2015 UDPv4 link local: [undef]
Sun Jun 14 18:49:11 2015 UDPv4 link remote: [AF_INET]111.111.111.111:8080
Sun Jun 14 18:49:41 2015 [UNDEF] Inactivity timeout (--ping-restart), restarting
Sun Jun 14 18:49:41 2015 SIGUSR1[soft,ping-restart] received, process restarting
Sun Jun 14 18:49:43 2015 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sun Jun 14 18:49:43 2015 UDPv4 link local: [undef]
Sun Jun 14 18:49:43 2015 UDPv4 link remote: [AF_INET]222.222.222.222:8080
Sun Jun 14 18:50:13 2015 [UNDEF] Inactivity timeout (--ping-restart), restarting
Sun Jun 14 18:50:13 2015 SIGUSR1[soft,ping-restart] received, process restarting
Sun Jun 14 18:50:15 2015 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sun Jun 14 18:50:15 2015 UDPv4 link local: [undef]
Sun Jun 14 18:50:15 2015 UDPv4 link remote: [AF_INET]222.222.222.222:8080
Sun Jun 14 18:50:46 2015 [UNDEF] Inactivity timeout (--ping-restart), restarting
Sun Jun 14 18:50:46 2015 SIGUSR1[soft,ping-restart] received, process restarting
Sun Jun 14 18:50:48 2015 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sun Jun 14 18:50:48 2015 UDPv4 link local: [undef]
Sun Jun 14 18:50:48 2015 UDPv4 link remote: [AF_INET]111.111.111.111:8080
.. These similar 5 lines repeat forever, until I quit openvpn
In the example above, I plugged the DSL cable from the Router at around
18:49:00 (= Internet connection lost).
Internet connection came back ~30 seconds later. However OpenVPN never connected back to the server (I waited for 60 minutes)
Also I can't
ping 8.8.8.8 while OpenVPN produces above log lines. As soon as I quit OpenVPN (killall openvpn) the
ping 8.8.8.8 works.
Ping to local network (e.g.
ping 192.168.1.1) always works.
I really don't know what the problem is. Can you please help me?