I have a vpn application that connects to vpn server with a tcp socket. I have marked tcp socket packets with setsockopt and SO_MARK. I can ping vpn gateway ping 10.0.0.1 successfully.Then I try to route my whole traffic through the vpn. I create a different table and add default gateway with ip route add default via 10.0.0.1 dev tun0 table 200 and ip rule add lookup 200.But then vpn's own packets start to go through vpn. I run ip rule add fwmark 1234 lookup main and vpn's own packets are excluded from vpn. I can see them with tcpdump going through eth0 and vpn servers answering them.But incoming packets are not being delivered to tcp socket. Kernel seems to be dropping them. Why?
Incoming packet does not delivered to socket
linux;iptables;socket;iproute