SacAutos
Regular Pleskian
Plesk 10.2 on CentOS 5.6 . We've purchased a Virtual Machine with a local hosting company for hosting a web client. The provider's network assigns the VM a block of internal website addresses for use internally on their network and an external public IP address. NAT is used to do the translation from the public to private and vice versa. Overall it works well.
However, all FTP transfers in must use active mode. Though that was an unexpected adjustment inbound works fine this way. FTP out seems to be another matter. When I use the ftp command line utility from the VM, I can connect and transfer files to other servers with ease. But trying to use the ftp functions from within PHP isn't working. We have some regular cron jobs that are currently broken because they cannot transfer files outward. And this also effects the Plesk Backup processing: I wish to transfer files out regularly to a remote server for saving backup files.
To test and evaluate this problem I created this short FTP test program to see why it wasn't working (I have hidden the actual server and credentials for obvious reasons). I also created a brief text file called test.txt for the test:
--------- begin ---------
<?php
print ("\nConnecting\n");
$ftp_connection = ftp_connect ('myremoteserver.com');
print ("\nLogging in\n\n");
ftp_login ($ftp_connection,'username','password');
// print ("\nGoing active\n");
ftp_pasv ($ftp_connection,FALSE);
$filename = 'test.txt';
print ("\nWriting file\n\n");
ftp_put ($ftp_connection,$filename,$filename,FTP_ASCII);
print ("\nClosing\n");
ftp_close ($ftp_connection);
print ("\nDone!\n");
?>
--------- end ---------
When I ran the program interactively, here was the results:
--------- begin ---------
[root@cloud httpdocs]# php ftp2.php
Connecting
Logging in
Writing file
PHP Warning: ftp_put(): IP address does not match command connection address. in /var/www/vhosts/vmserver.com/httpdocs/ftp2.php on line 11
Closing
Done!
--------- end ---------
No file was transfered.
In looking at the FTP server log on the other end, the FTP server is attempting to connect to the internal IP address (10.16.25.80), which of course won't work. The external IP is the one needed, naturally. I have also tried running this test program with the passive command commented out. Same result.
I need to find a solution to this problem. Ideas??
However, all FTP transfers in must use active mode. Though that was an unexpected adjustment inbound works fine this way. FTP out seems to be another matter. When I use the ftp command line utility from the VM, I can connect and transfer files to other servers with ease. But trying to use the ftp functions from within PHP isn't working. We have some regular cron jobs that are currently broken because they cannot transfer files outward. And this also effects the Plesk Backup processing: I wish to transfer files out regularly to a remote server for saving backup files.
To test and evaluate this problem I created this short FTP test program to see why it wasn't working (I have hidden the actual server and credentials for obvious reasons). I also created a brief text file called test.txt for the test:
--------- begin ---------
<?php
print ("\nConnecting\n");
$ftp_connection = ftp_connect ('myremoteserver.com');
print ("\nLogging in\n\n");
ftp_login ($ftp_connection,'username','password');
// print ("\nGoing active\n");
ftp_pasv ($ftp_connection,FALSE);
$filename = 'test.txt';
print ("\nWriting file\n\n");
ftp_put ($ftp_connection,$filename,$filename,FTP_ASCII);
print ("\nClosing\n");
ftp_close ($ftp_connection);
print ("\nDone!\n");
?>
--------- end ---------
When I ran the program interactively, here was the results:
--------- begin ---------
[root@cloud httpdocs]# php ftp2.php
Connecting
Logging in
Writing file
PHP Warning: ftp_put(): IP address does not match command connection address. in /var/www/vhosts/vmserver.com/httpdocs/ftp2.php on line 11
Closing
Done!
--------- end ---------
No file was transfered.
In looking at the FTP server log on the other end, the FTP server is attempting to connect to the internal IP address (10.16.25.80), which of course won't work. The external IP is the one needed, naturally. I have also tried running this test program with the passive command commented out. Same result.
I need to find a solution to this problem. Ideas??