From: Alex Bligh <alex@alex.org.uk>
To: netfilter@vger.kernel.org
Cc: Alex Bligh <alex@alex.org.uk>
Subject: Using DNAT with multiple upstreams
Date: Tue, 18 Dec 2012 20:46:30 +0000 [thread overview]
Message-ID: <4B5F9CC88C3B87ECDEAD7A5D@Ximines.local> (raw)
I have a multihomed configuration as follows:
Provider A Provider B
^ ^
eth1 | | eth2
192.200.0.2/24 | | 192.200.1.2/24
ROUTERRUNNINGLINUX
| eth3
| 10.10.10.1/24
|
---+----
|
10.10.10.99/24
Internet connections A and B both inject default routes when
they are up. I use SNAT on eth1 and eth2 to NAT the range
on eth3 to the appropriate IP address (well, SNAT on one
and MASQUERADE on the other for boring reasons). Connection
B is faster so injects its default route with a lower distance.
This gives me resilience and uses the fastest connection.
So far so good.
Now, I also want to use DNAT on eth1 so that incoming connections
to 10.200.0.2:1234 get mapped to (say) 10.10.10.99:5678. When
the connection to provider B is down, all this works just fine.
However, when the connection to provider B is up, the connection
fails. As far as I can tell, this is because return traffic
to the external host initiating the connection follows the
default route with the lowest distance, and goes out provider B
instead (who knows how it gets NATted).
What I'd really like to do is say "if the connection is in
your DNAT table, send it out the way it came", but I think
the DNAT is undone after the routing decision. I can think
of a pile of ways to solve this, many of which involve
ugly source routing. I could use the connmark stuff I think.
I could also (conceivably) SNAT the incoming connection
to be originated by 192.200.0.1 so that the route out would
always be via provider A (as that's an interface route).
I know I have a million options. My question is what is the
fastest way to do this (with minimal impact on other traffic).
I'm loathe to go down the ip rule route unless I really need to.
--
Alex Bligh
next reply other threads:[~2012-12-18 20:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 20:46 Alex Bligh [this message]
2012-12-18 23:51 ` Using DNAT with multiple upstreams 叶雨飞
2012-12-19 0:34 ` Alex Bligh
2012-12-19 0:47 ` 叶雨飞
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B5F9CC88C3B87ECDEAD7A5D@Ximines.local \
--to=alex@alex.org.uk \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox