Ports die nicht durch den VPN laufen extra freischalten, und ein Fallback falls der VPN down geht einrichten sodass dann die Connection gedroppt wird. Hab das ganze mit iproute2 gemacht. Geht bestimmt auch noch etwas eleganter aber naja es funktioniert.
Code:
echo "201 novpn" >> /etc/iproute2/rt_tables
ip rule add fwmark 65 table novpn
// GATEWAY = network gateway
ip route add default via GATEWAY dev eth0 table novpn
ip route flush cache
// Ports without VPN = ssh port etc
iptables -t mangle -A OUTPUT -p tcp --sport 22 -j MARK --set-mark 65
// drops connection when tun0/openvpn goes down
// MAIN_IP = Server IP
// 1337 = Port of application which should always goes through openvpn
iptables -A OUTPUT -o eth0 -p tcp --destination-port 1337 -s MAIN_IP -j DROP