Aglystas
Aglystas

Reputation: 379

Is it possible to get FTP to work in VirtualBox using NAT networking or get php's ftp functions to work

I'm trying to get php's ftp methods to work from within a VM. I can connect using ftp_connect but not actually do anything afterwards.

HOST: Ubuntu 14.10 GUEST: Debian 7 Stack: Vagrant - VirtualBox - Debian - LAMP

I'm using vagrant to run a virtual box VM that runs a lamp stack. In php I'm running some method calls (ftp_pasv, ftp_nlist) that are not working. I discovered that because of the FTP protocol using random ports for connections, the issue is caused by the use of NAT networking in virtualbox. I have the perfect vagrant-virtualbox setup except for this one issue. Does anyone know of a method to get ftp to work on the guest OS in this scenario. I know I could try using a bridged setup, but that means a bunch more work setting it up and the machine will be available to the public. So I would prefer to try to get it working behind that NAT.

I also have tried to use ftp_pasv to get passive mode turned on, which would fix the issue. But the method returns false when I call it to turn on passive mode.

Upvotes: 4

Views: 2299

Answers (3)

troelskn
troelskn

Reputation: 117615

I had this issue and it turned out that upgrading Virtual Box solved the issue. Possibly some bug in the NAT interface.

Upvotes: 0

hasc
hasc

Reputation: 1

The problem is most likely related to the network configuration. The fact that e.g. creating a directory works in contrary to getting the directory listing indicates, that theres an issue with the back channel.

A potential root cause is the configuration of the network router. It seems that some routers handle packages different if they are sent from different mac adresses (host vs guest system).

Upvotes: 0

Aglystas
Aglystas

Reputation: 379

As far as I know this isn't possible. Maybe if you want to hack some source code and compile custom solutions it will work. But that's harder than just using a different setup. I've resorted to using curl to make the ftp connections. Which works for listing files and downloading them.

Anyone that comes across this question and actually finds a solution please post it here.

Upvotes: 1

Related Questions