Problem is, my university's ISP is super restrictive. My Pi is behind at least 2 levels of NAT. No port forwarding. Inbound connections are blocked. Also, they reboot their router at 4AM (or something else that makes me lose connectivity). Oh, and once in a while, I'll find I can't connect to anything, unless I load a non-secure webpage first (as if they forgot I registered my MAC address and send me to their captive portal, and then realize I am registered and change their mind).
So, anyways, it's difficult to connect from outside my room! I believe my best option is to use a paid VPN service which offers port forwarding. I'm currently looking at AirVPN, which provides both port forwarding, and a dynamic DNS service.
How can I go about getting the Pi to connect to the VPN on boot, and more importantly, to reconnect when disconnected? Furthermore, if it is unable to connect due to the captive portal thing, to load a webpage (any non-secure one will work) and then retry the connection?
My idea is to write a Python/Bash script that runs every hour, that does this (obviously not actual code):
Before I go ahead and waste a ton of time on this.... is there a better way? Any suggestions, improvements?
Code: Select all
(if OpenVPN is running) && (if internet connection eth0 is working) && (VPN tunnel tun0 is working): exit else: kill any OpenVPN process try downloading an HTML file from a non-secure site start OpenVPN try downloading an HTML file over tun0 cleanup