Auto-connecting a VPN on a Wi-Fi connection from a mobile router on Debian 11

I'm travelling for work a little more now than I have been for a couple of years. I tether my laptop to my phone, rather than rely on Wi-Fi, and I need more data than I currently have in my phone's plan.

A pre-paid SIM and a Mi-Fi

I could upgrade the plan - for another £12ish per month, I could get "unlimited" data - but £144/year seemed a lot for occasional connectivity.

I could move providers, but that's not really an option for me at the moment.

So, since I've got a Mi-Fi - a small, battery-powered, router - I thought I'd try a pre-paid SIM with a reasonable amount of data.

I used this handy blogpost, "Best Bulk Data PAYG SIMs in the UK", by Terence Eden to identify a suitable pre-paid SIM.

I went for the first item in his table: 120GB of data, valid for 12 months, for £50, pre-paid.

(Yes, I could have done this more cheaply if I were willing to take out a contract for an additional SIM. If I blitz through the 120GB, perhaps.)

Reminder for future me, when the data stops work:

One gotcha that hit a couple of us recently with the EE 120GB SIMs: approx 6 months after first use, they got deactivated for inactivity.

Needed temporarily moving to a device that could make voice calls, and a call to 150 followed by "dial 1 to reactivate"...

Auto-connecting a VPN

I'm using Debian 11, with GNOME.

The Wi-Fi connectivity tab in the normal "Settings" application does not allow me to automatically connect to a VPN when connecting to a specific Wi-Fi access point.

Oddly - to me, at least - I can do this when tethering to a mobile device. But not a Wi-Fi connection.

Fortunately, the Advanced Network Configuration tool does have this functionality. To do this, you:

  • Select the network name, under "Wi-Fi"
  • Click the settings icon - the cog - at the bottom of the pane, to edit the network's settings
  • Select the "General" tab
  • And set "Automatically connect to VPN" to whatever VPN connection you want. (In the screenshot, it is wg0, a WireGuard profile.)

Screenshot of GNOME settings

You might need to turn Wi-Fi off then on again, or connect to another network and back to the one you've configured to connect to the VPN automatically, before this takes effect.

A better Mi-Fi?

The Mi-Fi I have is quite old. It works, and it is such a shame to ditch working electronics.

But it has not had security updates for quite a few years, and that's not great.

I quite like the GL.iNet routers. In particular, I like the fact that they use OpenWRT, and have Tor and WireGuard clients built in.

Hmm...


Author: neil

I'm Neil. By day, I run a law firm, decoded.legal, giving advice on Internet, telecoms, and tech law. This is my personal blog, so will be mostly about tech stuff, cycling, and other hobbies.

You can find me (and follow me) on Mastodon and Twitter.