I'm trying to redirect a subsection of incoming traffic to a different destination using fwmarks.
The procedure
1) Mark matching incoming packets:
iptables -t mangle -A PREROUTING -i pppoe0 -p tcp -m tcp --dport 80 -j MARK --set-xmark 6
2) Add a rule to direct the marked packets to routing table "200".
ip rule add fwmark 6 table 200
3) Add a default route on routing table "200" to the new destination.
ip route all default via 192.168.33.2 table 200
The problem
iptables -L PREROUTING -t mangle -v
shows packets matching the rule I made in step 1, however they never get forwarded to where I expect.
I think the problem is that the traffic is destined for an address which is considered local to the host, and the local
ip rules are matching being the rule I added in step 2, e.g.
~# ip rule show
0: from all lookup local <--- taking priority...
32765: from all fwmark 0x6 lookup 200 <--- ... over this.
32766: from all lookup main
32767: from all lookup default
Question: is there a way to make my rule take priority over the local
rules?