VSFTP Server on AXT1800

FTP protocol is very old and needs some trick to make it work.

In 4.2.0 firmware, here is a guide to configure vsftpd ftp server and make it accessible from WAN side.

Step 1: Install

opkg update
opkg install vsftpd

Step 2: Configure

Need to make some basic config, otherwise the vsftpd process does not start

vi /etc/vsftpd.conf

#Initialized
background=YES
listen=YES #Need to change to YES, otherwise it will not start 
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
check_shell=NO
session_support=NO

anon_mkdir_write_enable=YES
anon_other_write_enable=YES
allow_writeable_chroot=YES
anon_upload_enable=YES

#Need to configure the root path,  we use /tmp as an example
local_root=/tmp/
#support passive mode
pasv_enable=YES
#passive mode port range
pasv_min_port=10090
#passive mode port range
pasv_max_port=10100

Then you can start this process
/etc/init.d/vsftpd restart

You can check if ftp is listening now. If you see port 21 is listening, you can test it in LAN network.

:~# netstat -nl|grep 21
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      

Step 3: Make it work on WAN

Now the FTP only works on the LAN side, it does not work on WAN.
First you can open port 21, but that is not enough, because ftp use multiple ports.

In the router, use the following commands to allow the passive ftp ports

iptables -I INPUT -p tcp --destination-port 10090:10100 -j ACCEPT

You can set up this in Luci so that this setting is kept after reboot.

Now restart vsftpd and test on the WAN side.
/etc/init.d/vsftpd restart

Step 4: Make it work behind NAT (port forward)

If the router is behind NAT, you will make port foward for 21 and the passive ports.

You can set up the port forward in range in Luci


Other considerations: The above is tested inside my LAN network. I didn’t test on public Internet. If you have issues in public Internet, pls let me know.
Reference: centos - How to configure vsftpd to work with passive mode - Server Fault

4 Likes