Change default port number for Telnet in Cenots 7
First – install telnet on Centos 7
yum -y install telnet-server
Edit the file /usr/lib/systemd/system/telnet.socket The section [Socket] has by default
[Socket] ListenStream=23
Change 23 to the desired port number. Then
systemctl enable telnet.socket systemctl start telnet.socket
Firewalld for Telnet
Make sure you permit that port number through the firewall (replace 1234 in the example below with the port number you want to use)
firewall-cmd --zone=public --add-port=1234/tcp --permanent firewall-cmd --reload
SELINUX for SSH
By default SELINUX only allows port 23 for telnet. Now add new port context 1234.
Note: Replace 1234 with the port number you want to use
Note: Replace 1234 with the port number you want to use
semanage port -a -t telnetd_port_t -p tcp 1234
Note: if you get the following after running semanage:
bash: semanage: command not found
you need to run
yum -y install policycoreutils-python
then re-execute the complete semanage command above
Now check the port context for telnet
semanage port -l | grep telnet
Below given is output from our server
[root@localhost ~]# semanage port -l | grep ssh telnetd_port_t tcp 1234, 23 [root@localhost ~]#