All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Amin Azez <azez@ufomechanic.net>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: Per-client NAT routing -- possible?
Date: Thu, 23 Mar 2006 19:26:49 +0100	[thread overview]
Message-ID: <4422E869.8020108@trash.net> (raw)
In-Reply-To: <44227366.60106@ufomechanic.net>

Amin Azez wrote:
> Jeremy Elson wrote:
> 
>> [ Sent before I subscribed - I think it was silently dropped.
>> Apologies if you get 2. ]
>>
>>
>> Hi,
>>
>> I'm trying to set up a Linux box as a NATting router.  But here's the
>> trick: my box's external interface is on a LAN that has a whole bunch
>> of routers on it, any of which can be used to access the Internet.
>> I'm trying to figure out how to configure iptables so that the NAT box
>> selects the router to use based on client IP address (i.e., the IP
>> address on the inside interface).
>>
>> I've been tinkering with a command like this:
>>
>> iptables -t nat -A POSTROUTING -i $INTERNAL_CLIENT_IP -o
>> external-iface0 -j SNAT --to $EXTERNAL_ROUTER_IP
>>
>> ...but it seems that --to controls the new source address given to the
>> packet (i.e., the router's outside-interface IP), and not the
>> destination to which the NATted packet is sent.
>>
>> Could someone please point me in the right direction?  Or is this not
>> possible?
> 
> 
> I think you can use ipt_route to select the output gateway or interface,
> NAT should then work after that.

That sounds rather hackish. The normal way to do something like that
is to use normal multipath routes and, if NAT to different IPs needs
to be used, CONNMARK to bind connections to one of the paths.

  reply	other threads:[~2006-03-23 18:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22 17:16 Per-client NAT routing -- possible? Jeremy Elson
2006-03-23  2:49 ` Jeremy Elson
2006-03-23 10:07   ` Amin Azez
2006-03-23 18:26     ` Patrick McHardy [this message]
2006-03-24 12:24       ` Amin Azez
2006-03-24 12:58         ` Patrick McHardy
2006-03-24 13:28   ` Guy Martin
2006-03-27  6:37 ` Oskar Berggren

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=4422E869.8020108@trash.net \
    --to=kaber@trash.net \
    --cc=azez@ufomechanic.net \
    --cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.