All of lore.kernel.org
 help / color / mirror / Atom feed
* FTP Connection problems.
@ 2004-08-24 13:07 Vincent Blondel
  2004-08-24 13:17 ` a.ledvinka
  2004-08-24 16:10 ` Aleksandar Milivojevic
  0 siblings, 2 replies; 17+ messages in thread
From: Vincent Blondel @ 2004-08-24 13:07 UTC (permalink / raw)
  To: netfilter

Hi all,

I a trying to initiate ftp connections to some of my servers but it
doesn't work. You can find below a schema representing my three
machines, client, firewall and ftp server. There is no NAT at the moment
and the script I use on my firewall.

---

 ftp server                   eth1 fw eth0                 client 
192.168.125.1      192.168.125.240    192.168.124.240    192.168.124.1

---

#!/bin/sh
#

fw="/sbin/iptables"
nat="$fw -t nat"
mangle="$fw -t mangle"

CONN_TRACK="1" 				# Connection Tracking
UNPRIVPORTS="1024:65535" 		# unprivileged port range

# Remove any existing rules from all chains
$fw --flush
$nat --flush
$mangle --flush

# Unlimited traffic on the loopback interface
$fw -A INPUT  -i lo -j ACCEPT
$fw -A OUTPUT -o lo -j ACCEPT

# Set the default policy to drop
$fw --policy INPUT   DROP
$fw --policy OUTPUT  DROP
$fw --policy FORWARD DROP

$nat --policy PREROUTING  DROP
$nat --policy OUTPUT      DROP
$nat --policy POSTROUTING DROP

$mangle --policy PREROUTING  DROP
$mangle --policy OUTPUT      DROP

# Remove any pre-existing user-defined chains
$fw --delete-chain
$nat --delete-chain
$mangle --delete-chain

if [ "$CONN_TRACK" = "1" ]; then
	$fw -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
	$fw -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
	$fw -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
fi

# Incoming FTP requests
iptables -A FORWARD -i eth0 -o eth1 -p tcp -s 192.168.124.1 --sport
$UNPRIVPORTS -d 192.168.125.1 --dport 21 -m state --state NEW -j ACCEPT

# Port Mode Data Channel Responses
iptables -A FORWARD -i eth1 -o eth0 -p tcp -d 192.168.124.1 --sport 20
--dport $UNPRIVPORTS -m state --state NEW -j ACCEPT

Thanks to help me ...
Vincent




^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: FTP Connection problems.
@ 2004-08-24 13:19 Jason Opperisano
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Opperisano @ 2004-08-24 13:19 UTC (permalink / raw)
  To: netfilter

> Hi all,
>
> I a trying to initiate ftp connections to some of my servers but it
> doesn't work. You can find below a schema representing my three
> machines, client, firewall and ftp server. There is no NAT at the moment
> and the script I use on my firewall.
>
> ---
>
>  ftp server                   eth1 fw eth0                 client
> 192.168.125.1      192.168.125.240    192.168.124.240    192.168.124.1
>
> ---
>
> #!/bin/sh
> #
>
> fw="/sbin/iptables"
> nat="$fw -t nat"
> mangle="$fw -t mangle"
>
> CONN_TRACK="1"                                # Connection Tracking
> UNPRIVPORTS="1024:65535"              # unprivileged port range
>
> # Remove any existing rules from all chains
> $fw --flush
> $nat --flush
> $mangle --flush
>
> # Unlimited traffic on the loopback interface
> $fw -A INPUT  -i lo -j ACCEPT
> $fw -A OUTPUT -o lo -j ACCEPT
>
> # Set the default policy to drop
> $fw --policy INPUT   DROP
> $fw --policy OUTPUT  DROP
> $fw --policy FORWARD DROP
>
> $nat --policy PREROUTING  DROP
> $nat --policy OUTPUT      DROP
> $nat --policy POSTROUTING DROP
>
> $mangle --policy PREROUTING  DROP
> $mangle --policy OUTPUT      DROP
>
> # Remove any pre-existing user-defined chains
> $fw --delete-chain
> $nat --delete-chain
> $mangle --delete-chain
>
> if [ "$CONN_TRACK" = "1" ]; then
>       $fw -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
>       $fw -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
>       $fw -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
> fi
>
> # Incoming FTP requests
> iptables -A FORWARD -i eth0 -o eth1 -p tcp -s 192.168.124.1 --sport
> $UNPRIVPORTS -d 192.168.125.1 --dport 21 -m state --state NEW -j ACCEPT
>
> # Port Mode Data Channel Responses
> iptables -A FORWARD -i eth1 -o eth0 -p tcp -d 192.168.124.1 --sport 20
> --dport $UNPRIVPORTS -m state --state NEW -j ACCEPT
>
> Thanks to help me ...
> Vincent

if the client is running a passive FTP client--you need to have the FTP connection tracking module loaded for those connections to be considered RELATED:

  # modprobe ip_conntrack_ftp

-j


^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: FTP Connection problems.
@ 2004-08-24 14:04 Jason Opperisano
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Opperisano @ 2004-08-24 14:04 UTC (permalink / raw)
  To: netfilter; +Cc: Vincent Blondel

> I compiled a kernel without any modules ( all these are in vmlinuz ) an
> I use the very basic ftp client from coreutils ( so normally this does
> not initiate passive connections ).
>
> So what do I have to do ???

go look in your config file that you used to compile your kernel.  did you set CONFIG_IP_NF_CONNTRACK (i assume you did) and CONFIG_IP_NF_FTP (this is connection tracking for FTP)?  if not...i see a make config && make dep clean bzImage install in your future...

use an FTP client that allows you to switch between active and passive mode on the fly so you can determine what is and is not working.  i use ncftp, which supports 'set passive on|off'...  the basic "ftp" command that ships with FC1 supports switching back and forth with the 'passive' command.  the way your rules are set up, *active* FTP should be working.

also--please rethink this:

> $nat --policy PREROUTING  DROP
> $nat --policy OUTPUT      DROP
> $nat --policy POSTROUTING DROP
>
> $mangle --policy PREROUTING  DROP
> $mangle --policy OUTPUT      DROP

you'll never get anything working with those set to DROP (relatively speaking)...

-j


^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: FTP Connection problems.
@ 2004-08-25 11:48 Jason Opperisano
  2004-08-25 12:34 ` Vincent Blondel
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Opperisano @ 2004-08-25 11:48 UTC (permalink / raw)
  To: netfilter

> ... but the connection takes a long time to terminate. If I disable all
> the rules, ftp connection goes directly but with iptables enabled it
> takes such 8 seconds to accomplish the annonymomus connection ( with
> data port and passive models ).
>
> What is this all about ???
>
> Regards
> Vincent

your server is trying to do a reverse DNS lookup on the IP address of the connecting client.  either disable reverse lookups on your FTP server, or allow it to resolve DNS through your firewall.

-j


^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: FTP Connection problems.
@ 2004-08-25 12:49 Jason Opperisano
  2004-08-25 13:58 ` Vincent Blondel
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Opperisano @ 2004-08-25 12:49 UTC (permalink / raw)
  To: netfilter

> Here the logfile generated by tcpdump on my firewall when I ...
>
> ftp 192.168.125.1 (from 192.168.124.1)
>
> 14:31:19.818595 IP 192.168.124.1.32790 > 192.168.125.1.ftp: S
> 2452334504:2452334504(0) win 5840 <mss 1460,sackOK,timestamp
> 10914109[|tcp]>

SYN

> 14:31:19.819085 IP 192.168.125.1.ftp > 192.168.124.1.32790: S
> 2932060858:2932060858(0) ack 2452334505 win 5792 <mss
> 1460,sackOK,timestamp 1164327[|tcp]>

SYN-ACK

> 14:31:19.819448 IP 192.168.124.1.32790 > 192.168.125.1.ftp: . ack 1 win
> 5840 <nop,nop,timestamp 10914109 1164327>

ACK

> 14:31:29.830558 IP 192.168.125.1.ftp > 192.168.124.1.32790: P 1:66(65)
> ack 1 win 5792 <nop,nop,timestamp 1165329 10914109>

10 second delay...  either that FTP is sending packets elsewhere that aren't getting captured, or has some problem/configuration that keeps it from responding any faster than that.

can you perform the tcpdump on the FTP server itself?

> 14:31:29.830970 IP 192.168.124.1.32790 > 192.168.125.1.ftp: . ack 66 win
> 5840 <nop,nop,timestamp 10924124 1165329>
>
> Furthermore, as you suggested it I added in my proftpd server
> configuration
>
> UseReverseDNS                   off
>
> ... But this does not change anything.

you *did* restart the daemon after that, right?  ;-)

-j


^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: FTP Connection problems.
@ 2004-08-25 14:14 Jason Opperisano
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Opperisano @ 2004-08-25 14:14 UTC (permalink / raw)
  To: netfilter

> Here you are ...
>
> tcpdump.firewall.log
>
> 15:59:24.071217 IP 192.168.124.1.32796 > 192.168.125.1.ftp: S
> 3496999441:3496999441(0) win 5840 <mss 1460,sackOK,timestamp
> 16200055[|tcp]>
> 15:59:24.072144 arp who-has 192.168.124.1 tell pix1
> 15:59:24.072464 arp reply 192.168.124.1 is-at 00:50:ba:e2:a9:ed
> 15:59:24.072499 IP 192.168.125.1.ftp > 192.168.124.1.32796: S
> 4161421847:4161421847(0) ack 3496999442 win 5792 <mss
> 1460,sackOK,timestamp 1692753[|tcp]>
> 15:59:24.072847 IP 192.168.124.1.32796 > 192.168.125.1.ftp: . ack 1 win
> 5840 <nop,nop,timestamp 16200057 1692753>
> 15:59:34.085569 IP 192.168.125.1.ftp > 192.168.124.1.32796: P 1:66(65)
> ack 1 win 5792 <nop,nop,timestamp 1693755 16200057>
> 15:59:34.085984 IP 192.168.124.1.32796 > 192.168.125.1.ftp: . ack 66 win
> 5840 <nop,nop,timestamp 16210073 1693755>
>
> tcpdump.ftp.log
>
> 15:52:48.574738 192.168.124.1.32796 > iptables.ftp: S
> 3496999441:3496999441(0) win 5840 <mss 1460,sackOK,timestamp 16200055
> 0,nop,wscale 0>
> 15:52:48.574908 arp who-has 192.168.125.240 tell iptables
> 15:52:48.575204 arp reply 192.168.125.240 is-at 0:30:4f:5:74:39
> 15:52:48.575226 iptables.ftp > 192.168.124.1.32796: S
> 4161421847:4161421847(0) ack 3496999442 win 5792 <mss
> 1460,sackOK,timestamp 1692753 16200055,nop,wscale 0> (DF)
> 15:52:48.576318 192.168.124.1.32796 > iptables.ftp: . ack 1 win 5840
> <nop,nop,timestamp 16200057 1692753>
> 15:52:48.597025 iptables.33254 > 192.168.124.1.auth: S
> 4154447273:4154447273(0) win 5840 <mss 1460,sackOK,timestamp 1692755
> 0,nop,wscale 0> (DF)
> 15:52:51.587881 iptables.33254 > 192.168.124.1.auth: S
> 4154447273:4154447273(0) win 5840 <mss 1460,sackOK,timestamp 1693055
> 0,nop,wscale 0> (DF)

IDENT request...bingo...

iptables -I FORWARD -p tcp --syn --dport 113 -j REJECT --reject-with tcp-reset

-j


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

end of thread, other threads:[~2004-08-25 15:51 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-24 13:07 FTP Connection problems Vincent Blondel
2004-08-24 13:17 ` a.ledvinka
2004-08-24 16:10 ` Aleksandar Milivojevic
2004-08-25 10:10   ` Vincent Blondel
2004-08-25 11:11     ` a.ledvinka
2004-08-25 11:29       ` Vincent Blondel
2004-08-25 14:13     ` Aleksandar Milivojevic
2004-08-25 14:58       ` Vincent Blondel
2004-08-25 15:51       ` Vincent Blondel
  -- strict thread matches above, loose matches on Subject: below --
2004-08-24 13:19 Jason Opperisano
2004-08-24 14:04 Jason Opperisano
2004-08-25 11:48 Jason Opperisano
2004-08-25 12:34 ` Vincent Blondel
2004-08-25 12:49 Jason Opperisano
2004-08-25 13:58 ` Vincent Blondel
2004-08-25 14:16   ` Aleksandar Milivojevic
2004-08-25 14:14 Jason Opperisano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.