My router is the default gateway of a LAN and is multihomed.
ISP2 is used for HTTP, HTTPS and
ISP1, the default gateway of the default routing table, for the rest of the traffic.
Similar questions have been answered on that topic (iproute2, fwmark with iptables, MASQUERADE, rp_filter, etc), like Linux port based routing : reponse packets discarded but mine is a little bit different.
In my case, I would also like ICMP packets to go through
ISP2, that is, ICMP packets use the special routing table associated with rules and iptables marks. I have achieved that by adding iptables rules with
-p icmp instead of
-p tcp --dport 80 and the ICMP packets follow these rules like HTTP packets do. The problem is that unlike these HTTP packets, the ICMP ones leave the gateway with the IP address of the
ISP1 (default) interface as source address.
Is there something different that's applied to ICMP? Am I missing some fundamental ICMP property?