Skip to contentSkip to conversation

NAT changing src-port

DISCUSSION Nikolai Dahlem 2 participants 2 messages Mar 1, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I'm working on a pair of connection tracking / nat helper modules; when NAT sees the first outgoing packet of the connection it changes the src port to some free port (1024 in the example), but the remote side is responding to the port listed in the packet payload (5022), thus the answer to the request is not recognized. How can I get the port the new (changed) port from netfilter, to change the payload accordingly in my NAT-helper ?

udp 17 25 src=172.30.8.100 dst=10.20.10.198 sport=5022 dport=5014
[UNREPLIED] src=10.20.10.198 dst=10.20.10.213 sport=5014 dport=1024 use=3
udp 17 25 src=10.20.10.198 dst=10.20.10.213 sport=5014 dport=5022
[UNREPLIED] src=10.20.10.213 dst=10.20.10.198 sport=5022 dport=5014 use=1

And is there a way to tie the timeouts of related connections together ? My related connections are UDP and one rarely sees data while there is a constant flow of data on the other related connection, it's undesired that one related connection gets a timeout, while the other one is still active.

regards

Nikolai Dahlem

#1 lore raw

Hi,

Quoted 3 lines · Nikolai Dahlem

request is not recognized. How can I get the port the new (changed) port from netfilter, to change the payload accordingly in my NAT-helper ?

After setting up the NAT mappings with ip_nat_setup_info(), the new
source port is ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all (ct is a pointer to your conntrack structure).

Signature · 2 lines
 Regards,
   Krisztian KOVACS