Skip to content

Instantly share code, notes, and snippets.

@nukeador
Last active December 19, 2020 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nukeador/5748d486ba1f7586f40c7edcfafabe93 to your computer and use it in GitHub Desktop.
Save nukeador/5748d486ba1f7586f40c7edcfafabe93 to your computer and use it in GitHub Desktop.
Disconnects from VPN on Linux, killing apps first and reseting the firewall
#!/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
@nukeador
Copy link
Author

nukeador commented Jul 6, 2017

Use it with vpn-firewall.sh to enable the vpn and firewall.

Blog post about these scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment