Skip to content

Instantly share code, notes, and snippets.

@mrjamiebowman

mrjamiebowman/hack-off.sh

Last active Sep 15, 2019
Embed
What would you like to do?
VPN Killswitch
#!/bin/bash
sudo ufw reset
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 4444/tcp
sudo ufw enable
# restart network manager
sudo service network-manager restart
./hack-off.sh
# connect to vpn
nordvpn c
# take all connections down as a precaution before resetting ufw
sudo ifconfig eth0 down
sudo ifconfig wlan0 down
# reset ufw settings
sudo ufw --force reset
# set default behaviour of and enable ufw
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw enable
# allow local traffic
sudo ufw allow to 192.168.0.1/24
sudo ufw allow in from 192.168.0.1/24
# bring connections back up
sudo ifconfig eth0 up
sudo ifconfig wlan0 up
# allow vpn connection to be established
sudo ufw allow out 1194/udp
# allow vpn ip address
#sudo ufw allow in from $MY_IP to any
# allow all traffic over VPN interface
sudo ufw allow in on tun0 from any to any
sudo ufw allow out on tun0 from any to any
# restart network manager
sudo service network-manager restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment