1829924 Members
2555 Online
109997 Solutions
New Discussion

how to change ftp port

 
Binu_5
Regular Advisor

how to change ftp port

Hi All

I need to change the ftp port in Hpux from 21 to 65530 ... I have chaged in /etc/services and restarted the server ..
but it is now working ..

Please help

Binu
16 REPLIES 16
Orhan Biyiklioglu
Respected Contributor

Re: how to change ftp port

Edit /etc/inetd.conf

ftp stream tcp6 nowait root /usr/lbin/ftpd ftpd -l -c 65530

and

inetd -c

hth
Ivan Ferreira
Honored Contributor

Re: how to change ftp port

Just changin in the /etc/services file won't help.

The ftp daemon "could" have a configuration file where you specify the port that will be used, and depends of the ftp server that is used.

The /etc/services file is used only to "resolve" port-to-name, when you issue commands like netstat.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Binu_5
Regular Advisor

Re: how to change ftp port

Hi All

The problem still persist ...
I have changed the /etc/inetd.conf and run inetd -c but the problem presist

Thanks
Binu
Binu_5
Regular Advisor

Re: how to change ftp port

Hi All

The error looks like this

ftp 192.151.103.81
ftp: connect: Connection refused

Thanks
Binu



Jeff Schussele
Honored Contributor

Re: how to change ftp port

I don't believe this will work.
Even if you can get the ftpd daemon to listen on another port, how will you get the client to connect on that port?
Face it, ftp is going to be ports 20 & 21 like it always has.
Why would you want to change it? If security is the problem there are better ways to address that then trying to "hide" the ports. Any portscan will find the "new" port(s) anyway.

My 2 cents,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Piergiacomo Perini
Trusted Contributor

Re: how to change ftp port

Hi Binu,
(maybe) some significant info stay in
/var/adm/syslog/syslog.log.

regards
Orhan Biyiklioglu
Respected Contributor

Re: how to change ftp port

Hi

Excerpt from man ftpd

-c ctrlport
-C dataport Overrides the control and the data port numbers
respectively that is used by the daemon.
Normally, the daemon determines the port numbers
by looking in /etc/services (see services(4)) for
"ftp" and "ftp-data". If there is no
/etc/services entry for "ftp-data" and the -C
option is not specified, the daemon uses the port
just prior to the control connection port. The -c
and -C options are both available if running as a
standalone daemon. Otherwise, only the -C option
can be used.

I have missed the standalone portion in the previous post.

Since inetd will not mention that you have changed the port this is not possible while running under inetd.

However if you disable the ftpd service from inetd and run it as a stand alone process from the command line like

/usr/lbin/ftpd -S -l -c 65530

it will work

hth
Binu_5
Regular Advisor

Re: how to change ftp port

Hi All

Still the problem persisit ...

Thanks
Binu
Jeff Schussele
Honored Contributor

Re: how to change ftp port

Hi Orhan,

What OS is that man page snippet from?
I see no such options in either 11.0 nor 11.11 ftpd man pages.
I do see a -c in the ftp man page, but that is for disabling SYST & TYPE commands upon connection. Has nothing to do with the port(s).
Without a rewrite of the ftpd & ftp binaries, I don't see this working - period.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Raj D.
Honored Contributor

Re: how to change ftp port

Hi Binu ,

Have you tried from the client side to logon to the particular port you are assigning for FTP i.e 65530 ,

When you try $ ftp 192.151.103.81 it will try to establish a socket conection in port 21, hence try changing the port no, to 65530.

$ telnet 192.151.103.81 65530

Does it work?

You will get a screen like this:

Connected to 192.151.103.81.
Escape character is '^]'.
220 hostname.domain.com FTP server (Version 1.1.214.4(PHNE_29461) Thu Nov 20 06:40:06 GMT 2003) ready.

Cheers,
Raj.


" If u think u can , If u think u cannot , - You are always Right . "
Ivan Ferreira
Honored Contributor

Re: how to change ftp port

I think that you need to specify the port, like:

ftp

ftp> open 192.168.0.1 65530
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Raj D.
Honored Contributor

Re: how to change ftp port

Hi Binu ,

Hope the above will work.

check out this:

$ ftp

ftp>
ftp> open 192.151.103.81 65530

Connected to host
220 FTP server ready.
Name (host:username):


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
rick jones
Honored Contributor

Re: how to change ftp port

Indeed - all the advice about how _both_ the client and the server have to agree on the change for the control port is spot-on.

And _all_ clients connecting to that FTP server will have to specify the other control port number, which can be a bit of bother if there are lots of clients - hence the use of a well-known port number in the first place :)

I have to wonder just why you want to change the port - particularly from being within the reserved range to being beyond the reserved range.
there is no rest for the wicked yet the virtuous have no pillows
Orhan Biyiklioglu
Respected Contributor

Re: how to change ftp port

Jeff,

This was from an HP-UX 11.23 system running wuftpd-2.6.1. Please check here http://docs.hp.com/en/B2355-60105/ftpd.1M.html.

I have tested it on this system and it is running without any problems.

To the client end: sure you have to specify the port you want to connect to. This is trivial since you want to change the port.

hth

Fred.Wu
Frequent Advisor

Re: how to change ftp port

Just change in /etc/services do work, I just tried on my HP-UX, and change the 21 to 65530 or some others. then "inetd -c"

run "netstat -an |grep 65530" you can see it's listening.

Please give out the port number 65530 when you run ftp command, instead of using the default.

#ftp
ftp> open x.x.x.x 65530
fred
Raj D.
Honored Contributor

Re: how to change ftp port

Binu ,

Just wondering is there any specific reason for changing the ftp port from 21 to 65530. As all clinet need to use the new port number, to use this box as ftp , rather using the default, and can make some confusion.

hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "