FTP server on linux guest

This is for discussing general topics about how to use VirtualBox.
Post Reply
gerome69
Posts: 3
Joined: 6. Oct 2009, 08:26
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Linux

FTP server on linux guest

Post 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
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: FTP server on linux guest

Post by vbox4me2 »

You need to forward the data port for ftp as well.
gerome69
Posts: 3
Joined: 6. Oct 2009, 08:26
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Linux

Re: FTP server on linux guest

Post 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.
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: FTP server on linux guest

Post by vbox4me2 »

Isnt that the purpose of PASV to stick to one port?
gerome69
Posts: 3
Joined: 6. Oct 2009, 08:26
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Linux

Re: FTP server on linux guest

Post 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.
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: FTP server on linux guest

Post by vbox4me2 »

Use Bridge or Host only networking then.
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: FTP server on linux guest

Post 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.
Post Reply