Use fwmark in iptables on a container running in Azure K8S
Solution 1:
So i finally got to the solution. The issue was with the mangling of the packets in PREROUTING. Mangling the packets in POSTROUTING (so, on the exit of eth0) they were then able to return from tap0 to eth0 and then to the client. The end result looks like this:
/sbin/iptables --table mangle --insert POSTROUTING --destination "192.168.0.100" -o eth0 -p tcp --dport "10" --jump MARK --set-mark "10"
/sbin/iptables --table nat --insert PREROUTING --destination "192.168.0.100" -i eth0 -p tcp --dport "10" --jump DNAT --to-destination "10.0.0.4:80"
/sbin/ip rule add prio "10" from all fwmark "10" lookup "10"
/sbin/ip route add "10.0.0.4" via "10.118.0.2" table 10