How I Run Experiments for My PhD from Anywhere

Using WireGuard and a VPS

October 2, 2022

How I Run Experiments for My PhD from Anywhere

Using WireGuard and a VPS

Published: October 2, 2022, Last updated: October 10, 2022.

As a part of my PhD I conduct experiments that are not practical to run on my university-issued laptop. At the same time, my university’s computing cluster is in high-demand, requires connection to their unreliable VPN, and requires users configure experiments with Singularity containers instead of the more popular Docker containers that I’m familiar with.

Instead of using my school’s cluster, I run my experiments at home on a computer I built for gaming 5 years ago. It’s more capable than my laptop, and I get exclusive use of and autonomy over its resources. The main downside of this approach is that the computer is at my home, and I don’t always work from home. Using a remote machine to do my work is not an issue for me, since I’m quite familiar with using remote unix servers via ssh to do my work from my time in industry. The main consequence of the machine’s location is network configuration.

To be able to access my computer from outside my home, I needed to make the machine reachable somehow over the internet. After some struggle, I learned what I needed to learn to get this setup working. The process looked something like this:

This setup was working well for me until I needed to move homes, where access to the router at my new address was not possible. Not wanting to spend much time and effort finding another solution, I’d just accepted that I’d need to be at home to run my experiments.

But recently, I came across this video on YouTube from Wolfgang. In this video, he sets up a virtual private network (VPN) on a virtual private server (VPS) using an Ansible playbook that he created. Stunned by how easy it looked, and instilled with confidence by the answer to this question, I decided to spend a bit of time setting this up.

My idea was to run a WireGuard VPN on a VPS, and connect my laptop and home server together via this VPN. If configured correctly, this should give me a secure means of running my experiments via ssh, and it would work so long as my laptop and server have internet access.

To my delight, it works flawlessly! Wolfgang’s ansible playbook was able to configure the VPN without any issues, and I configured VPN clients on my laptop and home server with a simple change to the WireGuard configuration to only route traffic from certain IP addresses through the VPN tunnel. This means I that my normal browsing traffic is routed as normal (no annoying captchas when browsing), and I can just configure WireGuard to connect to my VPS whenever my laptop or server boot.

Edit: Turns out that the internet connection at my university was a little picky about allowing network traffic on WireGuard’s default port (51820). But this issue was easily resolved by reconfiguring the VPN to run on a different port. 😉

I now have a more secure, more flexible, and more scalable solution to my remote experimentation needs. Happy days! 😊

Huge thanks to Wolfgang for his Ansible playbook, and to the WireGuard developers!