go to bug id or search bugs for
In response to the PASV command, FTP servers sometimes return their IP address
(10.X for example) and PHP honors this IP address, stores it in ftp->pasvaddr
and uses that for future connections.
This is problematic because PHP won't be able to communicate with a server
behind a NAT device using passive FTP.
The attached patch adds the USEPASVADDRESS option (a boolean) which can be set
and read via the ftp_set_option() and ftp_get_option() functions. USEPASVADDRESS
is set to TRUE by default to preserve existing functionality. When
USEPASVADDRESS is set to FALSE, the ftp extension will ignore the IP address
returned by the PASV command and instead use the IP address passed to
ftp_connect() (or ftp_ssl_connect())
In the future we may expand the values to include AUTO which would ignore any
RFC 1918 IP addresses returned by the PASV command.
The only thing to note is that the call to ftp_set_option() must be made before
ftp_pasv() is called.
Add a Patch
Add a Pull Request
PS - this patch works against PHP 5.2.17 as well as 5.3.8
Any chance of this patch getting reviewed and accepted? (A more detailed
explanation is at http://www.elitehosts.com/blog/php-ftp-passive-ftp-server-
There were 78 votes, 72 people reproduced the problem and other people are
seeing the same problem:
It has been almost exactly four years since this bug report was created, but the bug persists in version 5.6.10. It has 165 votes with a 100% rate of reproduction. Why isn't this being reviewed?
Is the patch for 5.3.8 working on > 5.6 ?
The patch can be applied up until 5.6.10, after that is it requires a small typo change in ext/ftp/ftp.h to work ("configureable" -> "configurable"). It needs adaptation for the 7.0 branch.
The following patch has been added/updated:
Patch Name: ftp_usepasvaddress_php70.patch
Fixed in 5.6 branch with http://git.php.net/?p=php-src.git;a=commit;h=90a26a4844d1acfecb3bd0842da333f8bddd45c6
Fixed in 7.0 branch with http://git.php.net/?p=php-src.git;a=commit;h=71e468e14149169b28439a552f5924330580acab