This tool provides an IP-based killswitch using iptables
to block outgoing traffic if your public IP changes. It also allows you to configure VPN traffic, block or unblock specific IP addresses, and monitor real-time IP changes. The script is customizable and can save/load configurations for easy use.
To install and run the killswitch tool, execute the following command in your terminal:
bash <(curl -Ls https://raw.githubusercontent.com/samankhalife/killswitch/refs/heads/main/install.sh)
Note: Make sure that
curl
is installed on your system. If not, you can install it using the following command:
- On Ubuntu/Debian:
sudo apt-get install curl
- On CentOS/RedHat:
sudo yum install curl
The script provides an interactive menu where you can choose the following options:
-
Activate killswitch:
Activate the killswitch and block all traffic if your public IP changes. -
Deactivate killswitch:
Remove the killswitch and allow traffic as normal. -
View iptables rules:
Display the currentiptables
rules to see active traffic restrictions. -
Block an IP:
Manually block outgoing traffic to a specific IP address. -
Unblock an IP:
Remove the block for a specific IP address. -
Configure VPN interface:
Set your VPN interface (e.g.,tun0
) to allow VPN traffic while the killswitch is active. -
View available network interfaces:
List all available network interfaces on your system. -
Monitor IP changes:
Monitor real-time IP changes and activate the killswitch automatically if your public IP changes. -
Save current configuration:
Save the current IP and VPN interface settings to a configuration file (killswitch.conf
). -
Load saved configuration:
Load a previously saved configuration to restore your killswitch settings. -
Exit:
Exit the script.
You can choose options either by typing the number or by entering the associated keyword:
- Example: Type
1
oractivate
to activate the killswitch.
-
Activate the killswitch:
Run the script:killswitch
Select option
1
or typeactivate
. -
Block a specific IP:
Choose option4
, then enter the IP address you want to block. -
Monitor IP changes:
Enable real-time monitoring by selecting option8
. If your public IP changes, the killswitch will automatically engage. -
Save the configuration:
Use option9
to save your current IP and VPN interface settings for future use.
The script saves the following settings in the killswitch.conf
file:
- MY_IP: Your current public IP address, used for blocking traffic if it changes.
- VPN_INTERFACE: The VPN interface to allow traffic when the killswitch is active.
To load the saved configuration:
killswitch
Then select option 10
or type load
to apply the previously saved settings.
If you encounter any issues with the killswitch, ensure that:
- Your
iptables
is properly configured. - The
killswitch.conf
file has been correctly saved. - You have the necessary permissions to execute the script (use
chmod +x killswitch.sh
if needed).