Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
You have to NAT it. –  poige Apr 20 '13 at 7:33
Isn't the following command enough? iptables -t nat -A POSTROUTING -j MASQUERADE -o eth-isp2 –  bbc Apr 20 '13 at 7:41
I think you shouldn't check outgoing interface, but marks only in this NAT rule. –  poige Apr 20 '13 at 7:43
I don't understand what you mean by "marks only in this NAT rule". Maybe I was not clear. It is NATed, and leaves on the right output interface, but with the wrong source address (the one assigned to eth-isp1 in lieu of the eth-isp2 one). –  bbc Apr 20 '13 at 7:50
You try and see. Then we'll continue. –  poige Apr 20 '13 at 7:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.