I'm trying to connect to an FTP server that is behind a NAT. The local IP of the server is and the public IP is, 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.

  • 1
    This should be solved at the NAT level (via the FTP module of ip_conntrack) – Eugen Rieck Feb 8 '17 at 12:26
  • You might consider using active mode in your FTP client (and your question really should say which one you're using; there are several FTP clients that are part of Linux distributions). – Toby Speight Feb 8 '17 at 14:25

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).

  • Thank you. I think some of the users of the server have go through natting and some don't, so we cannot get the server fixed since it reports the correct address for some users. We could set up additional natting for our outgoing calls as you suggest, but it isn't pretty. We'll just use another client. Thank you. – Martin Ørding-Thomsen Feb 10 '17 at 12:30

Martin Prikryl:

"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."

I am an FTP administrator at a major institution, where we use 4 node HA clustered FTP environments. 2 active, and 2 standby, all load balanced and NAT'd. The issue is not necessarily a "server fix". Our servers all respond with the local IP's for PASV connections. However, if the LB's and NAT's are correctly configured, the CLIENT needs to ignore the PASV IP and use it's control connection IP when connecting through the LB. The ACTUAL problem is a linux FTP/S client failure. Our configuration is a normal, standard, configuration, which works beautifully with ALL OTHER CLIENTS who connect to our FTP systems. We ONLY see this problem when using FTP/S on linux boxes or our mainframe. On linux and IBM z/OS, the FTP/S client won't allow the PASV connection if the PASV is different from the control channel IP.

Just wanted to explain that.

To the original poster: That being said, you might try: ftp:ignore-pasv-address and see if that will allow you to make the data channel connection.

  • 1
    "CLIENT needs to ignore the PASV IP" - Why? Where in FTP RFC did you see such claim? – Martin Prikryl Mar 23 '18 at 20:13
  • Because it's a common configuring when FTP servers are sitting behind both public facing and internal facing firewalls, and have to service both internal and external clients. This is, after all, the reason that virtually (VIRTUALLY) every FTP client has the ability to ignore the PASV IP response. As for NAT translating the IP address in the PASV response, on encrypted connections NAT has no knowledge of the packet contents that contain the PASV response. – Curtis Reynolds Mar 25 '18 at 4:28
  • Further, since the RFC for FTP ambiguously defines the PASV response... ie it does not define specifically what host and port are to be returned, only what host and listening port the server will use... this is not a matter of the FTP RFC. This is a matter of network configuration and client accessibility. – Curtis Reynolds Mar 25 '18 at 4:47
  • I'm a little surprised an author of FTP client software needs that simple fact explained. – Curtis Reynolds Mar 25 '18 at 22:33
  • It's not that I need it to be explained. I understand you. I just do not agree. Imo, it's administrator task to make his/hers server working with every FTP client that complies with RFC. And if not possible, simply use a different technology, like SFTP. - I understand that you may need to do a pragmatic decision is some cases. But do not claim that it's something that should be followed in every case, without questioning. – Martin Prikryl Mar 26 '18 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.