Last active
December 19, 2020 22:43
-
-
Save nukeador/5748d486ba1f7586f40c7edcfafabe93 to your computer and use it in GitHub Desktop.
Disconnects from VPN on Linux, killing apps first and reseting the firewall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Your VPN name on Network Manager, to list all connections you can use: nmcli con | |
VPN_NAME="your.vpn.name" | |
# List of apps you want to kill before disconnecting from the VPN, if you don't kill them, they will leak traffic | |
KILL_APPS="firefox thunderbird transmission-gtk" | |
# Killing apps | |
killall $KILL_APPS | |
# VPN disconnect | |
nmcli con down id $VPN_NAME | |
# Reset Firewall to defaults | |
sudo ufw --force reset | |
sudo ufw default deny incoming | |
sudo ufw default allow outgoing | |
sudo ufw enable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use it with vpn-firewall.sh to enable the vpn and firewall.
Blog post about these scripts.