Operating System - HP-UX
1827809 Members
1955 Online
109969 Solutions
New Discussion

Re: ftp syntax when using port other than 21

 
SOLVED
Go to solution
Richard Darling
Trusted Contributor

ftp syntax when using port other than 21

I had to leave port 21 open for ftp on my router for the DSL provider. I setup another port in /etc/services:
xftp 2121/tcp # File Transfer Protocol (Control)

and added the following line to my /etc/inetd.conf file:
xftp stream tcp nowait root /usr/lbin/ftpd ftpd -l

then entered:
root:L1000>:inetd -c

I had assumed that I could then use:

ftp 192.100.100.199 2121

but I don't get a connection. I did the same steps for telnet, and it works fine. Is the syntax different for ftp?

11 REPLIES 11
Kofi ARTHIABAH
Honored Contributor

Re: ftp syntax when using port other than 21

Richard:

I remember reading somewhere that the ftp daemon will look in the services file for a service called ftp therefore I would suggest that in your services file, comment out the
#ftp-data 20/tcp
#ftp 21/tcp

and create the new entries:

ftp-data 2120/tcp
ftp 2121/tcp
(rather than calling it xftp)

next do the inetd -c bit
and run
# netstat -a | grep ftp
ensure that it is listening on the ftp port.

then try:
ftp
> open host 2121

it should work.
nothing wrong with me that a few lines of code cannot fix!
Richard Darling
Trusted Contributor

Re: ftp syntax when using port other than 21

I need to use the xftp (actually anything unique, because I want to continue to use port 21 for internal ftp. I have alot of machines setup with ftp voyager, and it would take a while to change all the machines to port 2121. It also worked fine for telnet.
I also just got the message:
421 Service not available, remote server has closed connection

so there is something else going on...
Kofi ARTHIABAH
Honored Contributor

Re: ftp syntax when using port other than 21

Okay... just tested and it seems to work - can you ensure that you have a corresponding xftp-data defined in your /etc/services file. then try ftp localhost 2121 also check the /var/adm/syslog/syslog.log for messages
nothing wrong with me that a few lines of code cannot fix!
Richard Darling
Trusted Contributor

Re: ftp syntax when using port other than 21

I did all that - thanks...I get the message saying that I am connected, and then the cursor just hangs...and then the connection is "Closed by Remote Host"

In the log I get:
Nov 27 16:29:59 L1000 ftpd[7000]: FTP LOGIN FROM g40 [192.100.100.251], root
Nov 27 16:30:17 L1000 ftpd[7000]: FTP session closed

not much help...
Kofi ARTHIABAH
Honored Contributor

Re: ftp syntax when using port other than 21

hmmm.. the plot thickens:

1. Can you still ftp on port 21?

2. you might want to get verbose debugging messages so edit your /etc/inetd.conf file and modify the ftpd -l line to read ftpd -l -d (then restart inetd with inetd -c)

3. Something that jumps to mind is do you have access restrictions turned on in /var/adm/inetd.sec? or are you running DNS? it is possible that it is timing out waiting for the reverse name lookup of the connecting host.

try (while logged on to the server itself, ) ftp localhost 2121
then look at the messages in the /var/adm/syslog/syslog.log ( with the debug turned on, you should get more verbose information)
nothing wrong with me that a few lines of code cannot fix!
Kofi ARTHIABAH
Honored Contributor

Re: ftp syntax when using port other than 21

by the way could you post what you have by the way of netstat -a | grep LISTEN
(edit it to remove IP addresses before posting)
nothing wrong with me that a few lines of code cannot fix!
Richard Darling
Trusted Contributor

Re: ftp syntax when using port other than 21

Kofi,
1. No problem using ftp on port 21?

2. you might want to get verbose debugging messages so edit your /etc/inetd.conf file and modify the ftpd -l line to read ftpd -l -d (then restart inetd with inetd -c)

3. No access restrictions turned on in /var/adm/inetd.sec. and no DNS.

4. Tryed ftp localhost 2121...
no messages generated in the /var/adm/syslog/syslog.log.

root:L1000>:ftp localhost 2121
Connected to localhost.

the cursur just hangs at this point, and when I kill it with contrl c I get:

421 Service not available, remote server has closed connection
ftp>
the ouptut from netstat -a | grep LISTEN is quite long, so instead here is the output from:

root:L1000>:netstat -a | grep ftp
tcp 0 0 *.xftp *.* LISTEN
tcp 0 0 *.ftp *.* LISTEN
udp 0 0 *.tftp *.*

I am missing somthing here - and it is driving me nuts...is port 2121 reserved for anything special... I didn't think so - nothing in /etc/services. Here are the last lines from the syslog after
inetd -c
and attempting
ftp localhost 2121

Nov 28 09:23:19 L1000 inetd[550]: Rereading configuration
Nov 28 09:23:19 L1000 inetd[550]: protocol = tcp
Nov 28 09:17:16 L1000 inetd[550]: xftp/tcp: Service enabled
Nov 28 09:23:19 L1000 inetd[550]: protocol = udp
Nov 28 09:23:20 L1000 inetd[550]: Configuration complete

Nothing on the attempted ftp and it is weird that the service enable message is not in chronological order in the syslog.
Richard Darling
Trusted Contributor

Re: ftp syntax when using port other than 21

I didn't mean to leave the question mark at the end of the sentence on point 1 - ftp works without a problem to port 21.
Herve BRANGIER
Respected Contributor
Solution

Re: ftp syntax when using port other than 21

I don't know if I can help :
I made a test on a new server with a basic
HPUX 11.00 installation :

with ftp 21/tcp in my etc/services
>ftp localhost 2121
Connected to localhost
I had to kill with CtrlC
This port seems to be use by another process.
With netstat this port is in use and the file
socket is /opt/dcelocal/var/rpc/local/s-0/2121.
But I syslog there is a bind error for inetd !!

After I use ftp 30000/tcp in etc/services and
it seems to work well....
Richard Darling
Trusted Contributor

Re: ftp syntax when using port other than 21

I found the problem. There are two services at port 2121. Do you know what the udp one is?

root:L1000>:netstat -an | grep 2121
tcp 0 0 *.2121 *.* LISTEN
udp 0 0 *.2121 *.*
102244400 stream 0 0 100dd3800 0
0 0 /opt/dcelocal/var/rpc/local/s-0/2121
102248c00 dgram 0 0 100dd2800 0
0 0 /opt/dcelocal/var/rpc/local/s-3/2121
Richard Darling
Trusted Contributor

Re: ftp syntax when using port other than 21

Problem solved - two services on the same port -