Linux Netfilter discussions
 help / color / mirror / Atom feed
* passive mode ftp high ports driving me nuts
@ 2010-01-07 19:13 MargoAndTodd
  2010-01-08 10:24 ` Mart Frauenlob
  0 siblings, 1 reply; 8+ messages in thread
From: MargoAndTodd @ 2010-01-07 19:13 UTC (permalink / raw)
  To: netfilter

Hi All,

In my firewall, I deny all and then allow what
services though that I want.  Problem: on
passive mode ftp, where the second connection is
estabilshed using random high ports, other
services are using my (last three) ftp rules.

My passive mode rules:

/etc/sysconfig/iptables-config:
IPTABLES_MODULES="ip_conntrack_netbios_ns ip_nat_ftp ip_conntrack_ftp 
ip_conntrack_tftp"

unassgn=1024:65535
$tbls -A dsl-out  -o eth1  -p tcp  -s $eth1_addr --sport $unassgn 
--dport ftp         -m state --state NEW,ESTABLISHED           -j ACCEPT

$tbls -A dsl-in   -i eth1  -p tcp  ! --syn --sport ftp -d $eth1_addr 
--dport $unassgn -m state --state RELATED,ESTABLISHED       -j ACCEPT

$tbls -A dsl-for  -i eth1  -p tcp  ! --syn --sport ftp -d $internal_net 
  --dport $unassgn  -m state --state RELATED,ESTABLISHED  -j ACCEPT

# The "ftpdata" session is a "new" one when it sends the SYN.  However, 
the ftp_conntrack module marks it as related to its controlling
# ftp session, so that state=related matches.  This should deny any 
"ftpdata" session that doesn't have a controlling ftp session.

$tbls -A dsl-out  -o eth1  -p tcp  -s $eth1_addr --sport $unassgn -d 
$ANY_IP --dport $unassgn -m state --state RELATED,ESTABLISHED 
      -j ACCEPT

$tbls -A dsl-in   -i eth1  -p tcp  ! --syn  -s $ANY_IP --sport $unassgn 
-d $eth1_addr --dport $unassgn  -m state --state RELATED,ESTABLISHED 
   -j ACCEPT

$tbls -A dsl-for  -i eth1  -p tcp  ! --syn  -s $ANY_IP --sport $unassgn 
-d $internal_net --dport $unassgn   -m state --state RELATED,ESTABLISHED 
  -j ACCEPT


It is the "--sport $unassgn --dport $unassgn" that is killing me.
How do I restrict the last three to just passive mode ftp?

Also, what is the lowest port that the random passive mode ftp
port will choose?  20,000?  That may be all I need to do.

Many thanks,
-T

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

end of thread, other threads:[~2010-01-09 16:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-07 19:13 passive mode ftp high ports driving me nuts MargoAndTodd
2010-01-08 10:24 ` Mart Frauenlob
2010-01-08 16:09   ` MargoAndTodd
2010-01-08 16:40     ` Mart Frauenlob
2010-01-09  2:59   ` MargoAndTodd
2010-01-09 13:55     ` Mart Frauenlob
2010-01-09 14:04       ` Mart Frauenlob
2010-01-09 16:33         ` MargoAndTodd

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