Linux Netfilter discussions
 help / color / mirror / Atom feed
* How to mangle source packet source ports to a fixed range
@ 2007-02-09 15:15 Steve
  2007-02-09 15:34 ` Pascal Hambourg
  0 siblings, 1 reply; 2+ messages in thread
From: Steve @ 2007-02-09 15:15 UTC (permalink / raw)
  To: netfilter

I have a need to set the source packet's high (unprivileged) source ports to a 
fixed range of high  ports on a firewall providing NAT.

The goal is to be able to identify the inside machines at the destination 
after NAT has changed the addresses.  This is for identification only.  I do 
not need to connect back to the machines inside the firewall.  I realize this 
may break certain protocols which may use dedicated unprivileged ports.

i.e.:

PREROUTING -i eth0 -p tcp -m tcp -s 192.168.0.x  --sport 1024:65535 -j 
REDIRECT --to-ports 2000-2200

The above modifies the destination port based on the source port.  I wish to 
modify the source port (  --from-ports ? ).

By already knowing the range of high ports used per internal IP address, I can 
tell which machine inside is sending the data.

If someone knows another way of doing this, I would appreciate any 
suggestions.

Thanks,

Steve.


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

* Re: How to mangle source packet source ports to a fixed range
  2007-02-09 15:15 How to mangle source packet source ports to a fixed range Steve
@ 2007-02-09 15:34 ` Pascal Hambourg
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Hambourg @ 2007-02-09 15:34 UTC (permalink / raw)
  To: netfilter

Hello,

Steve a écrit :
> I have a need to set the source packet's high (unprivileged) source ports to a 
> fixed range of high  ports on a firewall providing NAT.

NAT = source NAT (or masquerading) ?

> The goal is to be able to identify the inside machines at the destination 
> after NAT has changed the addresses.  This is for identification only.  I do 
> not need to connect back to the machines inside the firewall.  I realize this 
> may break certain protocols which may use dedicated unprivileged ports.
> 
> i.e.:
> 
> PREROUTING -i eth0 -p tcp -m tcp -s 192.168.0.x  --sport 1024:65535 -j 
> REDIRECT --to-ports 2000-2200
> 
> The above modifies the destination port based on the source port.

Not only it modifies the destination port but also the destination address.

>  I wish to modify the source port (  --from-ports ? ).

POSTROUTING [...] -j SNAT --to-source [ipaddr[-ipaddr]]:port-port
or
POSTROUTING [...] -j MASQUERADE --to-ports port-port


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

end of thread, other threads:[~2007-02-09 15:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-09 15:15 How to mangle source packet source ports to a fixed range Steve
2007-02-09 15:34 ` Pascal Hambourg

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