I have a network like this: A is connected to a router(R) which is connected to a server(S)through 2 interfaces: eth0 and eth1. One of them is for backup. Consider that the server has IP SIP0 on eth0 and IP SIP1 on eth1, and the router has RIP on the interface connected to A.

How do I configure iptables so that all the requests made on port x on router R are redirected to the server S port y, even if only one of the interfaces ( eth0 or eth1 ) is down?

Consider that all the routes are working, and eth0 has a metric 1 route, and eth1 metric 2. I have thought to add 2 rules like this:

 iptables -t nat -A PREROUTING -p tcp --source-port x -j DNAT --to-destination SIP0 --dport y -d RIP
 iptables -t nat -A PREROUTING -p tcp --source-port x -j DNAT --to-destination SIP1 --dport y -d RIP

I think this won't work since when eth0 will fail, the 1st rule will always be matched by iptables and the packets will never reach destination.

I have found the answer myself: When an interface fails I run a script which will delete the corresponding iptables rules, and that's it.

link|improve this question
feedback

closed as not a real question by splattne Dec 23 '11 at 19:38

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. See the FAQ for guidance on how to improve it.

Browse other questions tagged or ask your own question.