Re: question about VPN killswitch using Linux iptables rules
I got it to work. But if anyone could tell me if I'm missing anything or if there is a better way to do it I'd appreciate the info. I didnt need to add any ipv6 rules. A test on test-ipv6 shows no ipv6 detected.
Delete all rules in a chain or all chains iptables –F
Allow all input and output on local host iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
Allow traffic input and output from VPN Server iptables -A INPUT -s 123.123.123.123 -j ACCEPT
iptables -A OUTPUT -d 123.123.123.123 -j ACCEPT
Allow traffic via VPN network adapter (L2TP/IPsec) iptables -A INPUT -i ppp0 -j ACCEPT
iptables -A OUTPUT -o ppp0 -j ACCEPT
Drop everything else iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
iptables -P INPUT DROP
iptables -P OUTPUT DROP
When I run cmd: iptables -S it shows
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT DROP
-A INPUT -i lo -j ACCEPT
-A INPUT -s 123.123.123.123/32 -j ACCEPT
-A INPUT -i ppp0 -j ACCEPT
-A INPUT -j DROP
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -d 123.123.123.123/32 -j ACCEPT
-A OUTPUT -o ppp0 -j ACCEPT
-A OUTPUT -j DROP
|