Centos7 VPN Killswitch Support
So I have spent the last 2-3 days researching everything I can on getting a VPN killswitch working on centos7. I have read almost all the threads in this category and tried everything I could but nothing seems to work. I can connect with openvpn just fine and get that working, but whenever the vpn connection dies, everything just starts running over the eth0 interface and my data is exposed. Anytime I restrict eth0 interface the tun0 connection also seems to get restricted. Below is what I started working on, but as soon as I run this, I can no long ping or curl anything. Does PIA have any support for a centos killswitch? I tried using the directions here (https://www.privateinternetaccess.com/forum/discussion/22605/vpn-killswitch) but the iptables command is invalid and doesn't work.
#flush existing rules
iptables -F
#set default to drop
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
#allow ssh
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
#Accept all TUN connections (tun = VPN tunnel)
iptables -A OUTPUT -o tun0 -j ACCEPT
iptables -A INPUT -i tun0 -j ACCEPT
Comments
the thread appears to be a very well-developed discussion and collaboration.
https://www.privateinternetaccess.com/forum/discussion/comment/44686/#Comment_44686
The result: iptables v1.4.21: unexpected ! flag before --match
cheers!
#clear existing rules
iptables -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
iptables -Z
#allow ssh
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
#allow only vpn traffic
iptables -A OUTPUT -m mark ! --mark 0x1 ! -o tun+ -j DROP
sleep 2
nohup openvpn --config /etc/openvpn/client.conf --mark 1 > /dev/null 2>&1 &