Page 1 of 1

FTP server on linux guest

Posted: 6. Oct 2009, 08:33
by gerome69
Hi together,
I just installed Virtual Box with a Debian linux guest OS system. Everything went fine, I can access my webserver from the host with these additional lines in the machine configuration:

Code: Select all

<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" value="TCP"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" value="80"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" value="80"/>
Now I tried the same for the vsftpd running on the guest OS:

Code: Select all

<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestftp/Protocol" value="TCP"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestftp/HostPort" value="21"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestftp/GuestPort" value="21"/>
I can connect and authenticate, but I don't get the file list. The problem is that passive and active FTP uses a dynamic port for sending this data:

Code: Select all

Status:	Verbinde mit 192.168.56.1:21...
Status:	Verbindung hergestellt, warte auf Willkommensnachricht...
Antwort:	220 Welcome to Debian FTP service.
Befehl:	USER www
Antwort:	331 Please specify the password.
Befehl:	PASS *******
Antwort:	230 Login successful.
Befehl:	OPTS UTF8 ON
Antwort:	200 Always in UTF8 mode.
Status:	Verbunden
Status:	Empfange Verzeichnisinhalt...
Befehl:	PWD
Antwort:	257 "/"
Befehl:	TYPE I
Antwort:	200 Switching to Binary mode.
Befehl:	PASV
Antwort:	227 Entering Passive Mode (10,0,2,15,196,59)
Befehl:	LIST
Fehler:	Zeitüberschreitung der Verbindung
Fehler:	Verzeichnisinhalt konnte nicht empfangen werden
How can I achieve an FTP connection?

Thanks for tips, Gérôme

Re: FTP server on linux guest

Posted: 6. Oct 2009, 10:32
by vbox4me2
You need to forward the data port for ftp as well.

Re: FTP server on linux guest

Posted: 6. Oct 2009, 15:18
by gerome69
Yes I know I have to forward the dataport, too. But how? It is not constant. Every file gets an new port!

B.

Re: FTP server on linux guest

Posted: 6. Oct 2009, 15:21
by vbox4me2
Isnt that the purpose of PASV to stick to one port?

Re: FTP server on linux guest

Posted: 6. Oct 2009, 23:02
by gerome69
vbox4me2 wrote:Isnt that the purpose of PASV to stick to one port?
No, see the log above:

Code: Select all

Befehl:   PASV
Antwort:   227 Entering Passive Mode (10,0,2,15,196,59)
The port is 196*256+59= whatever. And for the next file it will be another.

G.

Re: FTP server on linux guest

Posted: 7. Oct 2009, 13:32
by vbox4me2
Use Bridge or Host only networking then.

Re: FTP server on linux guest

Posted: 20. Nov 2009, 03:18
by MarkCranness
Configure the vsftpd pasv_min_port and pasv_max_port settings to a range of ports, and then VirtualBox port forward those ports.

You will also need to set the vsftpd pasv_address setting (set it to the VM's external IP address - 192.168.56.1 in your example).
There is a problem here if you want to access the VM's ftp from outside your lan: the VM's external IP address inside your lan (when using VB NaAT networking) is the same as your host's IP, but the VM's external address outside your lan (assuming you port forward your router to the VM) will be an actual external IP address.