Hello joy.
I calculated tcp checksum. Now port redirection works fine.
I have still problems with address redirection. Example:
IP1: the one with firewall.
IP2 requests connection
IP3 target of redirection
rule on IP1: when receiving a connection on port 25 redirect to IP3 port 22.
On IP2 i do a ssh IP1 -p 25
On IP1 port 25 is translated into 22 and i see packet FORWARDED to IP3.
ON sniffer TCPDUMP on pc IP3 i see SYN from IP2 to IP3 (correct because of
redirection)
then Syn ack from IP3 to IP2 (addresses and ports get translated by IP1 so
IP3 should respond directly to IP2)
finally, and here the problem, i see a reset from IP2 to IP3!
What am i wrong with?
There must be something wrong: should i make every packet pass through the
firewall?
My home scenario is quite unusual: usually redirection happens from an
extern network towards a private one.
In that case, if the first packet of a connection gets Destination natted,
response goes out directly to the source address in the first packet, that
is,
the external network, through the gateway.
thanks a lot fr any suggestion.
Giacomo.
"joy" <joy79a_nospam_@libero.it> ha scritto nel messaggio
news:%K7ye.82$(E-Mail Removed)...
> Giacomo wrote:
>> Good morning i'm Giacomo From Italy
>>
>> i am writing a simple firewall in linux kernel space (2.6.11)
>>
>> i'm trying to implement DNAT, and i take struct sk_buff* skb from
>> functions in prerouting context.
>>
>> i change the destinstion port on skb.
>>
>> i printk the fields in pre routing and in input: all things as expected:
>> original port in pre and changed port in input.
>>
>> the problem is that packet seems to disappear: it does not enter the
>> output hook.
>>
>> For example
>>
>> i map port 100 to 22 and do SSH from IP2 to IP1. On IP1 I do dnat from
>> port 100 to 22
>>
>> IP2: ssh IP1 -p 100
>>
>> on IP1 i get printed:
>>
>> PRE: dest port 100 OK
>> INPUT dest port 22 OK!
>>
>> but ssh seems not responding, it probably does not really receive packet!
>>
>> WHY??
>>
>> perhaps i miss something... perhaps it is not enough to simply rewrite a
>> field of sk_buff.
>>
>> I thought it was automatic that since a packet enters input functions
>> with a certain destination port, although different from the port that
>> was in pre routing,
>> it got directed in the right way, in this case delivered to port 22 where
>> ssh is listening.
>>
>> Do i have to recalculate checksum?? how??
>>
>> PS: of course, i have prepared de-dnat on outgoing packets... but for now
>> they do not OUT-GO!
>>
>> PPS: of course ssh is up and responds correctly if i don't mangle
>> destination port in pre routing.
>>
>> Thanks in advance for any idea.
>>
>> Giacomo, Italy
> hello jacopo....
>
> have you try to sniff?what you see?
>
> peppe
|