There are many VPN providers out there but while they offer easy to use Windows or Mac clients with various features, command line Linux feels left out. Most providers provide OpenVPN configuration files as well as simple scripts but they lacked the features I wanted and needed.
I needed a solution that did IP Bind to disallow connections when the VPN connection drops and automatic reconnect. These features are relatively standard in Windows clients but most providers only offer shell scripts on Linux. Astrill is the only provider I’ve found that had a custom GUI client on Linux.
I currently use HideMyAss as my VPN provider and like other providers, only a simple shell script was given. I took already made scripts and modified them to my purposes.
The following scripts work on my Ubuntu Server 12.04 system and may need minor modification to work on yours. The OpenVPN settings for each server are included with the archive but since I do not connect to US servers, I have not included US servers. The server randomly connects to a random from my current server list so running
ipbind.sh will reset and randomly connect you to another server.
- Unpack the archive to
/root. The scripts are set to be executed from
/root/hma/client.credand enter HideMyAss username and password.
crontab -eto edit the system cron job file to check if OpenVPN is running and if not, to connect to a VPN server. Adding the following line will check for the VPN connection every five minutes.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /root/hma/hma-ipbind-start.sh
- You are done!