VPN L2TP/IPsec VPN Kill Switch for Linux using UFW Firewall
From what I can tell so far this application works 100% con is having to disable/enable firewall every time VPN drops. If someone with 1st hand experience with Linux UFW firewall can tell me if I'm missing any thing I would appreciate it.
L2TP/IPsec VPN Kill Switch for Linux Ubuntu with UFW firewall.
1. Need IP of VPN Server = 100.000.00.000
2. Need to find port of VPN Server = TCP 443 (port @ top of list for TCP protocol)
3. Connect to VPN
4. Find what interface VPN uses ( tun0 or ppp0 ) by running cmd: ifconfig
5. Find IP address of local network (Should look like 100.0.0.1/8) by running cmd : ip addr show
6. Set up UFW firewall sudo apt-get install ufw
sudo ufw enable
sudo ufw default deny outgoing
sudo ufw default deny incoming
You can test connection is blocked by pinging google server. Run cmd: ping 8.8.8.8
Ctrl+c to kill cmd sudo ufw allow out to 100.0.0.1/8
sudo ufw allow in to 100.0.0.1/8
sudo ufw allow out to 100.000.00.000 port 443 tcp
sudo ufw allow out on ppp0
To check the status of the firewall ( will not show default policies ) run cmd: sudo ufw status numbered
7. Block all ipv6 by by deleting the rule number for ipv6 ( #5 ) sudo ufw delete 5
To check rule is deleted run cmd: sudo ufw status numbered
When you lose VPN connection you must run cmd: “sudo ufw disable” to connect back to VPN: sudo ufw disable
Once connected back to the VPN run cmd: “sudo ufw enable" to turn firewall killswitch back on. sudo ufw enable
These cmds have been modified to work with SoftEther L2TP/IPsec form original source: |