Change vsftpd port in DNS-320L

251 views
Skip to first unread message

Wagner Anghinoni Nardin

unread,
Apr 3, 2022, 3:14:34 PM4/3/22
to Alt-F
Good afternoon.
Is it possible to change the vsftpd port on my DNS-320L?

I tried changing the /etc/vsftpd.conf file by adding the line listen_port=2121 , but it didn't work.

I also changed port 21 in the /etc/services file, but it didn't work.

Jeremy Laidman

unread,
Apr 3, 2022, 7:48:02 PM4/3/22
to al...@googlegroups.com
Wagner

The reason the listen_port configuration parameter is not working, is that vsftpd is run from inetd rather than running as a persistent daemon. The listening port is chosen by inetd, before vsftpd is run, so vsftpd doesn't get a chance to set its listening port. Running vsftpd from inetd frees up valuable RAM, so it's recommended to run it this way. However, if you were to change from inetd to server mode, then the listening port setting in the configuration file should work.

An alternative is to modify inetd to use an alternate port. The way to do this is:

a) edit /etc/inetd.conf, make a copy of the ftp line but change the name to ftpalt and the port number to 2121, like so:

...
ftp             21/tcp
ftpalt          2121/tcp
fsp             21/udp          fspd
...

b) edit /etc/inetd.conf, make a copy of the ftp line but change the name to ftpalt (must be the same name as in /etc/services), like so:

...
ftp    stream  tcp     nowait  root    /usr/sbin/vsftpd        vsftpd  # FTP server
ftpalt  stream  tcp     nowait  root    /usr/sbin/vsftpd        vsftpd  # FTP server
ftps   stream  tcp     nowait  root    /usr/sbin/vsftpd        vsftpd -oimplicit_ssl=yes       # FTPS server

...

c) go to [Service > Network Services > inetd/Configure] and you should see the new "ftpalt" service marked as enabled, although it's not yet actually enabled until you click on the "Submit" button at the bottom. You might first want to disable ftpd and ftps if you're not going to be using them.

d) You might notice that there is no "Configure" button for the new ftpalt service. If you wanted to, you could, create a symlink for the FTP service configurator. This will enable a "Configure" button, which you can use to modify the vsftpd configuration files (vsftpd.conf and vsftpd.user_list):

# ln -s ftp.cgi /usr/www/cgi-bin/ftpalt.cgi

Don't forget to save your settings in the GUI [System > Settings > SaveSettings] or the CLI [loadsave_settings -sf].

Note that the ftp configurator doesn't support all vsftpd options. In particular, you cannot set the listen_port option. Any option that isn't supported in the configurator needs to be set in the vsftpd.conf file directly. So it might be preferable to skip the last step, and do all configuration from CLI.

Cheers
Jeremy

Joao Cardoso

unread,
Apr 4, 2022, 9:55:09 PM4/4/22
to Alt-F
On Monday, April 4, 2022 at 12:48:02 AM UTC+1 Jezzaaaa wrote:
Wagner

The reason the listen_port configuration parameter is not working, is that vsftpd is run from inetd rather than running as a persistent daemon. The listening port is chosen by inetd, before vsftpd is run, so vsftpd doesn't get a chance to set its listening port. Running vsftpd from inetd frees up valuable RAM, so it's recommended to run it this way. However, if you were to change from inetd to server mode, then the listening port setting in the configuration file should work.

An alternative is to modify inetd to use an alternate port. The way to do this is:

a) edit /etc/inetd.conf, make a copy of the ftp line but change the name to ftpalt and the port number to 2121, like so:
Jezzaaaa meant /etc/services 

...
ftp             21/tcp
ftpalt          2121/tcp
fsp             21/udp          fspd
...

b) edit /etc/inetd.conf, make a copy of the ftp line but change the name to ftpalt (must be the same name as in /etc/services), like so:

...
ftp    stream  tcp     nowait  root    /usr/sbin/vsftpd        vsftpd  # FTP server
ftpalt  stream  tcp     nowait  root    /usr/sbin/vsftpd        vsftpd  # FTP server
ftps   stream  tcp     nowait  root    /usr/sbin/vsftpd        vsftpd -oimplicit_ssl=yes       # FTPS server

...

c) go to [Service > Network Services > inetd/Configure] and you should see the new "ftpalt" service marked as enabled, although it's not yet actually enabled until you click on the "Submit" button at the bottom. You might first want to disable ftpd and ftps if you're not going to be using them.

d) You might notice that there is no "Configure" button for the new ftpalt service. If you wanted to, you could, create a symlink for the FTP service configurator. This will enable a "Configure" button, which you can use to modify the vsftpd configuration files (vsftpd.conf and vsftpd.user_list):

# ln -s ftp.cgi /usr/www/cgi-bin/ftpalt.cgi

Don't forget to save your settings in the GUI [System > Settings > SaveSettings] or the CLI [loadsave_settings -sf].

Notice that your changes to /etc/services will not be saved on flash memory when you do "save settings". Instead they will be saved on disk on /Alt-F/etc/services (but *don't* edit/change anything directly under /Alt-F). 
 

Note that the ftp configurator doesn't support all vsftpd options. In particular, you cannot set the listen_port option. Any option that isn't supported in the configurator needs to be set in the vsftpd.conf file directly. So it might be preferable to skip the last step, and do all configuration from CLI.

When working on the CLI you have to signal inetd that its configuration file has changed, use 'rcinetd reload' to do that.
 

Cheers
Jeremy

If you decide to to run vsftpd in "server mode" instead of "inetd mode", you have to, instead of the above, to edit the vsftpd init scrip, /etc/init.d/S63vsftpd. You will see near the top

FTP_OPTS="-olisten_port=21"
FTPS_OPTS="-olisten_port=990 -oimplicit_ssl=yes"

Those are passed as arguments to vsftpd, so it might be simpler to do than running in inetd mode. You can then use 'rcvsftpd start|stop|status|reload|...'
Notice that init scripts are also not saved in flash memory when you "save settings" (only the script permissions will). Again, it will be saved as /Alt-F/etc/init.d/S63vsftpd

Not all edited files will be saved under /Alt-F. As a rule of thumb, if the parent directory of the file that you are editing exists under /Alt-F, the edits will go to under /Alt-F. If you wish to undo your changes, don't directly remove /Alt-F/etc/init.d/S63vsftpd, instead you have to do

aufs.sh -n
rm /Alt-F/etc/init.d/S63vsftpd
aufs.sh -r


Reply all
Reply to author
Forward
0 new messages