2

I need to setup 2 different instances of vsftpd. Which will listen on 2 different ports such that one instance listens on the default port 21 and the other can listen on another port 1123. Please guide me on how to setup vsftpd to listen on 2 different ports. I have the following vsftpd.conf file:

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
ftpd_banner=Welcome to the FTP Service.
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem

4 Answers 4

3

There are at least 2 ways of doing this

  1. run in standalone mode
    setup several different vsftpd conf files.
    In each set a different listen_port and call each with vsftpd /path/to/conf/file
    make sure to also enable standalone mode in each conf file (set listen to YES and disable vsftpd in inet/xinet)
  2. using systemd.unit to control the different configuration files (using systemctl start @service notation)

In your case simply create the 2 conf files, and start both instances as per option 1

1
  • 1
    Can't comment directly to your solution so commenting on my own answer - you might want to consider also using different log files for each instance, but that is a matter of personal preference.
    – Dani_l
    Jul 10, 2014 at 6:50
0

This is a nice little write up for getting this working on CentOS. But should work for Debian based OS's as well. https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-ftp-vsftpd-start-multi.html If you cannot run two instances on the same server for whatever reason you could just use iptables to redirect all traffic on port 1123 to 21.
iptables -t nat -A PREROUTING -p tcp --dport 1123 -j REDIRECT --to-port 21

1
  • I'm not sure why you need the two different ports so the iptables redirect might not work for you.
    – joeg1ff
    Jul 9, 2014 at 21:02
0

Read the manual man 5 vsftpd.conf

listen_port If vsftpd is in standalone mode, this is the port it will listen on for incoming FTP connections.
Default: 21

0

I needed to setup 2 instances of VSFTPD. So I created a 2nd conf file /etc/vsftpd-2.conf and a 2nd init script /etc/init.d/vsftpd-2

I edited the contents of /etc/vsftpd-2.conf to include the following line listen_port=1123.

I also needed to edit the /etc/init.d/vsftpd-2 file so when the start-stop-daemon is starting up the application, it uses a different pid & a different vsftpd conf file.

Below are some excerpts from the /etc/init.d/vsftpd-2 file:

CONFIG2FILE="/etc/vsftpd-2.conf"
#DAEMON="/usr/sbin/vsftpd ${CONFIG2FILE}"
DAEMON="/usr/sbin/vsftpd"
ARGS="$CONFIG2FILE"
NAME="vsftpd-2"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
LOGFILE="/var/log/vsftpd.log"
CHROOT="/var/run/vsftpd-2/empty"

CONFFILE="${CONFIG2FILE}"

case "${1}" in
    start)
        Check_standalone_mode || exit 0
        echo -n "Starting FTP server: "
        start-stop-daemon --start --background -m --oknodo --pidfile /var/run/vsftpd/vsftpd2.pid --exec ${DAEMON} -- ${ARGS}
        echo "${NAME}."
        ;;

    reload|force-reload)
        echo "Reloading FTP server configuration: "
        start-stop-daemon --stop --pidfile /var/run/vsftpd/vsftpd2.pid --signal 1 --exec $DAEMON -- ${ARGS}
        echo "${NAME}."
        ;;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .