With the recent passing of the Cybersecurity Information Sharing Act (CISA) here in the US, concerns over privacy on the Internet have taken center stage again. As most readers probably know already, a VPN is a good way to help protect your privacy online (or is it?). VPN Killswitch is a simple bash script that increases protection by preventing your real IP address and Internet activities from being revealed in the event that you lose connection to your VPN.
How does VPN Killswitch work?
VPN Killswitch uses
nmcli to make sure you’re still connected to a VPN. If you lose connection to your VPN, then VPN Killswitch issues an
ifconfig down command on the ethernet adapter that you set, effectively terminating all access to the Internet (and preventing your information from being revealed).
1. Download the script
Download as a zip file: https://github.com/plasticbrain/vpnkillswitch/archive/master.zip
Or clone the github repository:
git clone firstname.lastname@example.org:plasticbrain/vpnkillswitch.git
2. Set your internet device
vpnkillswitch.sh, find and edit the
device variable. (If you’re not sure what to use, run
ifconfig and use whichever device shows your external IP)
3. Move the script to /usr/bin (optional)
sudo mv vpnkillswitch.sh /usr/bin/vpnkillswitch
4. Make the script executable
sudo chmod +x /usr/bin/vpnkillswitch
Connect to your VPN, then open a terminal and run VPN Killswitch:
Note: VPN Killswitch needs to be ran as
root so it can terminate your Internet connection
If you lose connection to your VPN then VPN Killswitch will run
ifconfig down on the ethernet adapter that you defined in step 2 above.
Restore Internet Connection
To restore your Internet connection after it’s been stopped by VPN Killswitch just run the script with the
sudo vpnkillswitch up