For security purpose, you may want telnet bind to a different port instead of the well-known port 23. It should be noted that changing port numbers of well-known services is also usually a bad idea. In general, services should either be left with their default ports or completely disabled. Changing the default port should only be opted as last option when you want to keep the service as enabled.
Follow the steps below to change the telnet port from 23 to 24.
1. Check if nay other service is listening onto port 24 before proceeding.
$ netstat -an | grep "*.24" | grep LISTEN
2. edit the /etc/services file and edit the line for telnet
3. restart or hangup inetd…
$ kill -HUP <pid_of_inetd
4. There should now be a listener on port 24.
$ netstat -an | grep "*.23" | grep LISTEN *.23 *.* 0 0 49152 0 LISTEN
5. Telnet to the client by specifying port number to connect to this machine.
$ telnet hostname 24
This works because the inetd “super-server” uses getservbyname(3SOCKET) to obtain the port number from the services database. Please be aware that if you have configured the name service switch to use backends other than “files” then you may also need to alter the name/port mapping in those backends.