Using Linux on two Default Gateways

This was from about a year ago, when we were transitioning internet connections. We had two default gateways and obviously traffic can only go out one/come in one. This was for one of our web servers.

The solution is to tag packets:

echo "10 special" >> /etc/iproute2/rt_tables
ip route add default via <second gateway ip> table special
ip rule add from <second gateway ip> table special

This way, traffic to for example will go in and come out as normal. However if your new IP is, the traffic is tagged with "special" and goes out the other gateway.

Hope this helps!