<[EMAIL PROTECTED]> writes:

> On Sat, 18 May 2002, Gatis Gailis wrote:
> > Http traffic can be handled easily by
> > setting up Squid (proxy) on the first router, which has that other router
> > set up as a parent cache (and squid can alter requests by destination IP);
> > IPFilter on first router deals with transparent proxying.
> 
> So there is no way to do a rdr and nat on the same box?  I can set
> up squid on the first router, but it just seems like a lot of extra
> latency and work to do.
> 
> What I wish I could do is chain two ipnat rules.
> 
> rdr eth0 0.0.0.0/32 port 80 -> x.x.x.x port n
> map eth0 10.1.1.0/24 -> 0.0.0.0/32 portmap tcp/udp 10000:40000

This doesn't do what you think it does. Ipfilter's NAT can only NAT
the "local" address of packets (ie, the source addr of outgoing
packets and dest addr of incoming packets). Additionally, you can't
"chain" multiple NAT rules so that more than one operation is
performed on a single packet during processing on one interface.

The problem *can* be solved, though - see below.

> So outgoing traffic to port 80 would get redirected
> to the external proxy machine.. then run through NAT.
> 
> Any way to achieve this?

If you want to redirect outgoing web traffic to a particular proxy
server, you need to add NAT rules for your *INTERNAL* interface.
For example, if eth1 was your internal interface, and eth0 was
external, and you wanted to NAT all internal hosts to 10.1.1.0/24 and
redirect all outgoing traffic on port 80 to the machine at 4.3.2.1
port 1080, you would put the following in your ipnat.conf:


  rdr eth1 0.0.0.0/0 port 80 -> 4.3.2.1 port 1080 tcp
  map eth0 10.1.1.0/24 -> 0.0.0.0/32 portmap tcp/udp 10000:40000

In this case order is not significant, since the first rule only
matches packets on eth1 and the 2nd only matches packets on eth0. Note
that this would *not* redirect tcp/80 requests originating from the
ipfilter machine itself.

So you aren't really "chaining" the rules; you have a separate rule
for the internal interface and another for the external interface.
Since the packet has to come in one and out the other, both rules end
up being applied, but in totally separate operations.

BTW, squid isn't necessary (and is really just overkill) if all you
want to do is redirect all your client's HTTP traffic to a proxy
server somewhere else. (It *is* useful if the clients will be visiting
the same websites often, and your bandwidth is limited).

Reply via email to