[unknown]
One way to make it easier to switch, would be to install Tilda (drop down terminal activated with F12), then make some aliases in .bashrc that will make it fast & easy, to activate the killswitch script and the normal mode script:
Killswitch script (in this example named Firewall_killswitch.sh):
#!/bin/bash
sudo ufw reset
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw allow out on tun0 from any to any
sudo ufw enable
echo ""
echo ">>> Killswitch Activated <<<"
echo ""
Normal mode script (in this example named Firewall_normal.sh):
#!/bin/bash
sudo ufw reset
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
sudo rm /etc/ufw/after.rules.20* /etc/ufw/after6.rules.20* /etc/ufw/user.rules.20* /etc/ufw/user6.rules.20* /etc/ufw/before.rules.20* /etc/ufw/before6.rules.20*
echo ""
echo ">>> Normal Mode Activated <<<"
echo ""
(The reason for removing some .rules files in the last script is that, when going back to normal mode the killswitch mode will accumulate some leftover .rules files, if they are not deleted there will just be more and more files left in /etc/ufw/ )
Then edit .bashrc to add the scripts (this is just an example):
alias fk="bash /path/to/your/script/Firewall_killswitch.sh"
alias fn="bash /path/to/your/script/Firewall_normal.sh"
(After editing .bashrc you need to run source ~/.bashrc
in the terminal, or reboot for it to take effect)
All you need to do from now on, is to press F12 and type fk (= firewall killswitch) after connecting to the VPN, and fn (= firewall normal mode) when you have disconnected from the VPN..
A simpler solution could be to make script with a menu, for switcing between the two modes:
#!/bin/bash
# Script Menu
while true
do
PS3='Enter your choice: '
options=("Firewall Killswitch" "Firewall Normal" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Firewall Killswitch")
echo ""
echo ">>> Firewall Killswitch <<<"
sudo ufw reset
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw allow out on tun0 from any to any
sudo ufw enable
echo ""
echo ">>> Killswitch Activated <<<"
echo ""
break
;;
"Firewall Normal")
echo ""
echo ">>> Firewall Normal <<<"
sudo ufw reset
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
sudo rm /etc/ufw/after.rules.20* /etc/ufw/after6.rules.20* /etc/ufw/user.rules.20* /etc/ufw/user6.rules.20* /etc/ufw/before.rules.20* /etc/ufw/before6.rules.20*
echo ""
echo ">>> Normal Mode Activated <<<"
echo ""
break
;;
"Quit")
exit
;;
*) echo "invalid option $REPLY";;
esac
done
done