Linux Netfilter discussions
 help / color / mirror / Atom feed
* Could someone tell me the rules of port translation in SNAT ?
@ 2004-01-05  6:22 ding dang
  2004-01-05 11:14 ` Antony Stone
  0 siblings, 1 reply; 6+ messages in thread
From: ding dang @ 2004-01-05  6:22 UTC (permalink / raw)
  To: netfilter

When using SNAT of Netfilter as an NAPT, how will Netfilter assign the 
public UDP port for a UDP request from the private network to Internet? 
Could someone detail it to me when the UDP request is 
NEW/ESTABLISHED/RELATED/REPLIED/UNREPLIED?

Thanks.

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: Could someone tell me the rules of port translation in SNAT ?
@ 2004-01-07  7:37 ding dang
  0 siblings, 0 replies; 6+ messages in thread
From: ding dang @ 2004-01-07  7:37 UTC (permalink / raw)
  To: netfilter

> > When using SNAT of Netfilter as an NAPT, how will Netfilter assign the
> > public UDP port for a UDP request from the private network to Internet?
>
>With both TCP and UDP, netfilter will use the source port contained in the
>original packet if it can (ie: if that source port is not being used for
>something else by the netfilter machine).   If this is not possible, then
>another port is chosen at random using the standard socket-binding 
mechanism
>used for any network connection.
>
> > Could someone detail it to me when the UDP request is
> > NEW/ESTABLISHED/RELATED/REPLIED/UNREPLIED?
>
>This makes no difference.

Thanks.

But what i observed is:(SNAT using UDP port 20000-30000)

private addr         netfilter port         Internet addr
10.0.0.8:2000 --->       20000       ---->   193.0.0.8:3000
10.0.0.8:2001 --->       20000       ---->   193.0.0.8:3001
10.0.0.8:2002 --->       20000       ---->   193.0.0.8:3002
that means DIFFERENT UDP requests from private network for DIFFERENT 
Internet destination result in a same Netfilter port no matter the Internet 
destination sends reply or not ;

private addr         netfilter port         Internet addr
10.0.0.8:2000 --->       20000       ---->   193.0.0.8:3000
10.0.0.8:2001 --->       20001       ---->   193.0.0.8:3000
10.0.0.8:2002 --->       20002       ---->   193.0.0.8:3000
DIFFERENT UDP requests from private network for a SAME Internet destination 
result in DIFFERENT Netfilter ports, why?

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: Could someone tell me the rules of port translation in SNAT ?
@ 2004-01-07  9:49 ding dang
  2004-01-07 10:08 ` Antony Stone
  0 siblings, 1 reply; 6+ messages in thread
From: ding dang @ 2004-01-07  9:49 UTC (permalink / raw)
  To: spoft; +Cc: netfilter




>From: "spoft" <spoft@sohu.com>
>To: "ding dang" <jiadeip@hotmail.com>
>Subject: Re: Could someone tell me the rules of port translation in SNAT ?
>Date: Wed, 7 Jan 2004 16:19:53 +0800
>
>dst ip, dst port, and SNATed sport of the connections must be unique. So 
the firewall can NATed correctly and enough.
>So when:
>    1) dst ip and dst port are same,then the SNATed sport must be 
different between two connetions.
>    2) dst ip or dst port is different, then the SNATed sport may be same 
between two connections.

Thanks.

For 2) above:  when will the SNATed sport be different then?


> >
> > But what i observed is:(SNAT using UDP port 20000-30000)
> >
> > private addr         netfilter port         Internet addr
> > 10.0.0.8:2000 --->       20000       ---->   193.0.0.8:3000
> > 10.0.0.8:2001 --->       20000       ---->   193.0.0.8:3001
> > 10.0.0.8:2002 --->       20000       ---->   193.0.0.8:3002
> > that means DIFFERENT UDP requests from private network for DIFFERENT
> > Internet destination result in a same Netfilter port no matter the 
Internet
> > destination sends reply or not ;
> >
> > private addr         netfilter port         Internet addr
> > 10.0.0.8:2000 --->       20000       ---->   193.0.0.8:3000
> > 10.0.0.8:2001 --->       20001       ---->   193.0.0.8:3000
> > 10.0.0.8:2002 --->       20002       ---->   193.0.0.8:3000
> > DIFFERENT UDP requests from private network for a SAME Internet 
destination
> > result in DIFFERENT Netfilter ports, why?
> >
> > _________________________________________________________________
> > 与联机的朋友进行交流,请使用 MSN Messenger:  
http://messenger.msn.com/cn
> >
> >
> >

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: Could someone tell me the rules of port translation in SNAT ?
@ 2004-01-08  1:55 ding dang
  0 siblings, 0 replies; 6+ messages in thread
From: ding dang @ 2004-01-08  1:55 UTC (permalink / raw)
  To: netfilter

>>Therefore unless you specify the port to be used, it will not be changed
>unless necessary, and if it is changed you cannot predict what it will
>become.

I'm reading some source code for more details, bu i stopped at

      return NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, 
dev,ip_finish_output2);

in    ip_output.c::ip_finish_output()

cause i don't know what part of code does POST_ROUTING work and SNAT 
implementation.

Need your help, thanks.

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-08  1:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-05  6:22 Could someone tell me the rules of port translation in SNAT ? ding dang
2004-01-05 11:14 ` Antony Stone
  -- strict thread matches above, loose matches on Subject: below --
2004-01-07  7:37 ding dang
2004-01-07  9:49 ding dang
2004-01-07 10:08 ` Antony Stone
2004-01-08  1:55 ding dang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox