FTP passive connection between client and server running in different local networks

Giganews Newsgroups
Subject: FTP passive connection between client and server running in different local networks
Posted by:  Tomasz B (t.berg.REMO…@slican.pl)
Date: Wed, 16 Sep 2009

Is it possible to force idFtp to alter ip address sending by server as a
respond on PASV command when returning address is a private ip and
idFtp.Host contains public ip?

My situation looks like:
client (local ip) -- gateway* -- internet -- gateway2* --  server (local ip)

* both gateways have nat, gatway2 also forward chosen ports to a PC with
ftp server.

FTP communication between IdFTp and IdFtpServer works if command port is
in use (so it's possible to list directories). Attempt to download file
failed because of wrong ip address returning by server:

PASV
227 Entering Passive Mode (192,168,0,171,78,42).

Then idFtp reports:
150 File status okay; about to open data connection.
504 Data port can only be used by the same IP address used by the
control connection.

From the other side Total Commander can cope with this situation altering:
PASV
227 Entering Passive Mode (192,168,0,171,78,42).
Server reports local IP -> Redirect to: public_ip_of_a_ftp_server_gateway

I'll appreciate any help.

Replies