• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Change telnet server port number on CentOS 7 / RHEL 7

December 8, 2014 by Sharad Chhetri

The tutorial explains about how to change the telnet server port number on CentOS 7 / RHEL . We will keep SELINUX in enforcing mode and change the default port number 23 to some other port number. We believe you have already install telnet server on CentOS 7 / RHEL 7.

Task : Change telnet server default port number 23 to other port number.

IMPORTANT NOTE: Always select port number more than 1024 and should not be assigned to any running application.

We will change the telnet default port 23 to 2323.

Change Telnet Server Port Number

Follow the given below steps to change the telnet server port number.

1. Take backup of telnet.socket:

First take the backup of file called telnet.socket

cp -p /usr/lib/systemd/system/telnet.socket /root/telnet.socket.`date +%F`

2. Install policycoreutils-python :

To get semanage command install policycoreutils-python package.

yum install policycoreutils-python

3. Add custom telnet port number 2323 in SELINUX

Use below command to add port number 2323 for telnet service in SELINUX.

semanage port -a -t telnetd_port_t -p tcp 2323

check the status by below given command

semanage port -l | grep telnet

4. Change custom port in telnet.socket

First stop the telnet service

systemctl stop telnet.socket

Now change the value ListenStream=23 to ListenStream=2323 in telnet.socket file . It means, the telnet service will listen on port 2323 .

Edit the file /usr/lib/systemd/system/telnet.socket and change the value ListenStream=2323 .

vi /usr/lib/systemd/system/telnet.socket

[Unit]
Description=Telnet Server Activation Socket
Documentation=man:telnetd(8)

[Socket]
ListenStream=2323
Accept=true

[Install]
WantedBy=sockets.target

5. Now relaod systemctl :

Run below given command to reload systemctl after editing telnet.socket file.

systemctl daemon-reload

Start the telnet service

systemctl start telnet.socket

6. Allow port 2323 from source address in firewalld

Allow the port no. 2323 from source address in firewalld. On RHEL 7/CentOS 7 , firewalld is alternate for iptables.

In below given command, replace the source address=”192.168.56.0/24″ with your network address or client ip address.

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.56.0/24" port port="2323" protocol="tcp" log prefix="tftp-custom" level="info" limit value="1/m" accept'

7. Access telnet-server from remote system :

Because we have changed telnet server port number to 2323 . Here we have to run below given syntax from remote system to access the telnet server

Syntax:

telnet  

Example :

Telnet server IP Address : 192.168.56.101
Telnet custom port number : 2323

From remote system, run the command on terminal

telnet 192.168.56.101 2323

By default root user is not allowed to access telnet server. Hence, use the other system user.

Hint : To allow root user to access telnet-server, you have to work on pam file. But telnet is not allowed to access from public network and it is insecure. So we decided to end this tutorial here only.

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Install Telnet Server on CentOS 7 / RHEL 7
  2. CentOS 7 / RHEL 7 : change OpenSSH port number ( SELINUX enabled )
  3. Change the default port number of ssh server
  4. How to change smtp port number 25 in postfix
  5. Change mysql default port number in linux
  6. How to change Port number for Octopress rake preview
  7. How to protect from port scanning and smurf attack in Linux Server by iptables
  8. how to change path of tmpdir in MySQL Server On Ubuntu
  9. How to install linux operating system in remote machine with telnet
  10. How to change hostname or FQDN in CentOS and Redhat

Filed Under: Linux Tagged With: telnet server

Reader Interactions

Comments

  1. Surya Peri. says

    April 1, 2020 at 4:22 pm

    Thank you for the simple and detailed configuration tutorial.

    • Sharad Chhetri says

      May 9, 2020 at 2:56 am

      You are most welcome Surya!

      Regards
      Sharad

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Keep logs of user after sudo su – : Secondary Logging

How to protect from port scanning and smurf attack in Linux Server by iptables

sed: -e expression #1, char 24: Invalid range end

How to create a file with cat command

WordPress host IP changed not able to open wp-admin and site page looks scattered

How to use grep command to get fixed pattern or exact keyword

Install libjpegtran by using yum command in CentOS 6.x

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy