How to make FTP Passive Mode on Oracle Virtualbox work

I was configuring my Ubuntu server and came across this problem. I forgot that this was the thing that prevented me to install an FTP server on a virtual machine. But since installing BuddyPress requires an FTP account. I have no option but setup an FTP server. Enought with the talk, lezgeriron!

Of course, you need to install a FTP server of your choice. Just apt-get it!

sudo apt-get install uber-mega-ftp-server

Next, do your thing. Add a user, configure the user’s directories and stuff. Now for the tricky part.

Of course, for every opened port in your Guest OS (virtual machine) we need to open a port to our Main OS (and I guess that is your crappy windows).

Virtualbox Network settings..


If you haven’t attached the network adapter to NAT, do it. Next, click on advanced and you’ll see the port forwarding settings. voila!

Now just like your HTTP, MYSQL and SSH ports. let us forward the famed FTP port; port 21!

FTP is a tricky service. In an FTP connection, based on the mode and the port range specified in the server’s configuration file, random unprivileged ports are opened (i think ports that are 1023 and up).

The problem in Virtualbox is, it does not support port ranges. So if you are going to forward hundred of ports, that will be one big problem. So I came up with this batch script..

@echo off
set MACHINE=<virtual_machine_name>
set MACHINE_IP=<virtual_machine_ip>
set RULENAME=<rule_name>

for /L %%p IN (<from-port-xxx>,1,<to-port-xxx>) DO “%programfiles%\Oracle\Virtualbox\VBoxManage” modifyvm %MACHINE% –natpf1 “%RULENAME%[%%p],tcp,,%%p,%MACHINE_IP%,%%p

I guess the above script is pretty self-explanatory. Just change the values of the words in between < … >

Since this is just a development box, we won’t be needing a very high range of passive ports. The number of simultaneous connections can be minimized. Let’s say 2 connections. So we will configure our server to just use two passive ports. Let’s say 65533 and 65534.

Upon configuring and restarting the FTP daemon on the Guest OS, we need to forward those to the main OS. We will just do what we did to port 21 a while ago.

Two passive ports 😀

Back to our FTP server’s configuration file, we need to bind (or mask if that’s what you call it) the FTP server’s IP address to the localhost in order for passive mode to work. Let’s assume you are using ProFTPd here. check out my config file.

Note: this is a proftpd config file

Save the config file and restart the server. FTP in passive mode should work as expected.

Read More:

Active FTP vs. Passive FTP, a Definitive Explanation

What is the difference between active and passive FTP? [closed]

Make FTP Server on virtualbox work in passive mode

HOWTO : Create a FTP server with user access (proftpd)

Tags : , , , , , , ,

One thought on “How to make FTP Passive Mode on Oracle Virtualbox work”

Leave a Reply

%d bloggers like this: