OK. Thanks very much for your explanation !
Something I can't understand...
Source IP is decided when first routing decision. Why source is not
changed to the right one (while precised in ip route src) ? Is it a bug ?
I can't SNAT the output packets since the source is not correct (packets
go out, but conntrack does not consider it since the packet is not right ).
Do you know a solution ? Does a kernel upgrade could correct it ? (got a
2.6.8)
I've verified on my other server, and the route is not exactly the same.
A rule specify that to join the second proxy, it must use the second
ethernet interface, so the source is right.
Pascal Hambourg wrote:
> serge a écrit :
>>> The host is trying to acces an external web server via the
>>> GATEWAY_eth1 with his ip address set up on eth0 !
>>>
>>> I've never seen that... Any idea ?
>>
>> It happens all the time. The reason is quite simple : source address
>> selection is done before the packet enters the OUTPUT chains and can
>> be marked. One workaround is to use SNAT or MASQUERADE (if kernel >=
>> 2.6.14) on eth1.
>>
>> I'm not sure it happens all the time.
>> I've setted up a similar configuration, with exactly the same rules,
>> the same iptables' chains, and all works fine. The only difference is
>> around the hardware (we have same kernel/debian version too).
>
> This is a purely IP layer software issue, the hardware cannot make any
> difference.
>
>> Source address selection is done before, but how is it decided ?
>
> As usual, by looking up the routing table. In short :
> - if the route to the destination contains a source address, that
> address is selected ;
> - else the best suitable address of the output interface (know at that
> time) is selected ;
> - if the output interface is unnumbered, another suitable local address
> is selected.
>
>> My feeling is that, when generating packets, the interaction between
>> netfilter and iproute2 looks like this:
>> Routing decision made
>> Netfilter OUTPUT (nat + mangle) hooks are traversed (packets are
>> marked with 80)
>> OUTPUT chains are traversed
>
> Note : OUTPUT chains are a part of Netfilter OUTPUT (actually
> NF_IP_LOCAL_OUT) hooks.
>
>> POSTROUTING hooks are traversed
>> Routing decision made again, going into table web
>> Packets are transmetted
>>
>> What do you think about it ?
>
> This is correct except that the re-routing decision takes place between
> OUTPUT and POSTROUTING, not after POSTROUTING. You need that so the new
> output interface resulting from the re-routing decision can be taken
> into account in POSTROUTING rules.
|