iptables: marking packets for routing to two default gateways
I am new to iproute2 and iptables and want to ask the experts here a question:
I have a machine on one network and two routers on the same network. I have to give an "application" (written in C) the choice of using any of the two routers as default gateways.
Right now I am changing the default gateway on the machine using system() call in C, based upon the input to the application. But I would like to have some nice solution.
I thought of creating two default routes using iptables with different tables numbers, marking the packets using iptables and setting the routing rules accordingly for the different marked packets. But the problem is that I cannot mark the packets in C code or can I? Usuallly, they are marked using iptables command.
I wonder if there is a best way to do this. I would really appreciate the responses.
Last edited by obaidmushtaq; 12-22-2009 at 11:17 AM.