I have a network with several Linux workstations/servers on it, and two Internet connections, each with a consumer-grade NAT router in front of it. So for concreteness, let's say the devices are:
192.0.2.0/26 network
192.0.2.1 router A
192.0.2.62 router B
192.0.2.10 host X
192.0.2.11 host Y
Here's a diagram, similar to one in the LARTC HOWTO:
________
+------------+ /
| | |
+-----------+-[NAT router A]------+ Provider 1 +-------
_| | | /
___/ \_ +--------------+ +------------+ |
_/ \__ | Linux host | /
/ \ | | |
| Local network -----+ if1 | | Internet
\_ __/ | | |
\__ __/ | | \
\___/ +--------------+ +------------+ |
| | | \
+---------------[NAT router B]----+ Provider 2 +-------
| | |
+------------+ \________
If a new TCP connection comes in via one or the other router, return traffic needs to go out via that router. Otherwise the return SYN packet will be improperly NATted (if even passed out at all), and the connection will effectively be blackholed. I could set up mutually exclusive port-forwarding sets on the two routers if that would help, but I'd rather keep them the same (or at least in some cases overlapping) if possible.
For new outgoing connections, I want to allocate traffic by range using the main routing table, but for certain traffic I might want to randomly balance new connections across the two routers.
I suspect what I'm asking about is doable using iptables
and ip
, or perhaps either of those tools alone. However, the HOWTOs and other answers I've found seem to all address a single router (running Linux), or host, with multiple interfaces... not policy among multiple routers attached to the same interface.
Edit: I've found one other question, also unanswered, that's asking about the same situation (note 192.168.0.0/23
as the local network), but focuses on policy for outgoing traffic; my question here is specifically about policy for incoming traffic. (Both NAT devices have a "port forward by port-range to host" function.)