Linux – Make Linux command line ftp client ignore local IP address in passive mode

ftplinuxnat;

I'm trying to connect to an FTP server that is behind a NAT. The local IP of the server is 172.23.11.41 and the public IP is 194.239.61.58, and I'm connecting to the public IP.

When entering passive mode the server returns its local IP address which is useless. Example:

227 Entering passive mode (172,23,11,41,234,113).

The Linux command-line ftp client cannot establish a data channel when this happens.

I need to get the ftp client to ignore the IP address returned by passive mode (PASV) or to use extended passive mode instead (EPSV), which only returns the port number. Example:

229 Entering extended passive mode (|||64607|).

Is there any way to do this?

Edit:
I'm being told that we use ftp.x86_64, installed by calling sudo yum install ftp.

Best Answer

Get the server fixed. It should be configured to report its external IP address. Or the NAT should be configured to translate the IP in the PASV response.

The common *nix ftp command-line client cannot be configured to use the EPSV or to use the control connection IP instead of the IP returned in the PASV response.

Or use another FTP client, like tnftp (use the epsv4 command) or curl (defaults to the EPSV).

Related Question