Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Owner

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