Skip to content

Instantly share code, notes, and snippets.

@whoamiTM
Last active August 7, 2018 03:25
Show Gist options
  • Save whoamiTM/94ecb2f088f39d83a8dd10377618cb05 to your computer and use it in GitHub Desktop.
Save whoamiTM/94ecb2f088f39d83a8dd10377618cb05 to your computer and use it in GitHub Desktop.
VPN Kill Switch For Mac OS | Terminal User Interface | Requires killswitch.pf.conf
#! /bin/bash
echo off
defgw=$(route get 0.0.0.0 2>/dev/null | awk '/gateway: / {print $2}';)
def_int=$(route get 0.0.0.0 2>/dev/null | awk '/interface: / {print $2}';)
clear
:start
clear
echo Simple VPN KillSwitch, ver. 1.2 - by whoami
echo
echo Your default gateway is "$defgw" on interface "$def_int"
echo
echo USAGE:
echo
PS3='Please enter your choice: '
options=("Enable Kill Switch (IP "$defgw")" "Disable Kill Switch (IP "$defgw")" "Exit Kill Switch")
select opt in "${options[@]}"
do
case $opt in
"Enable Kill Switch (IP "$defgw")")
sudo pfctl -Fa -f ~/Documents/killswitch.pf.conf -e
echo Kill Switch Enabled...
sleep 1
;;
"Disable Kill Switch (IP "$defgw")")
sudo sudo pfctl -Fa -f /etc/pf.conf -e
echo Kill Switch Disabled...
sleep 1
;;
"Exit Kill Switch")
break
;;
*) echo "invalid option $REPLY";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment