Telnet 协议是 TCP/IP 协议族中的一员,是 Internet 远程登陆服务的标准协议和主要方式。它为用户提供了在本地计算机上完成远程主机工作的能力。
在终端使用者的电脑上使用 telnet 程序,用它连接到服务器。终端使用者可以在 telnet 程序中输入命令,这些命令会在服务器上运行,就像直接在服务器的控制台上输入一样,可以在本地就能控制服务器。
☛ 安装 Telnet 伺服器
⑴ 检查是否已经安装 Telnet Server
[root@localhost]# rpm -qa|grep telnet-server [root@localhost]# rpm -qa|grep xinetd
⑵ 安装 Telnet Server 及 xinetd
[root@localhost]# yum -y install telnet* [root@localhost]# yum -y install xinetd
⑶ 配置并启动 Telnet,xinetd 和 telnet 必须设置开机启动,否则无法启动 Telnet 服务
[root@localhost]# systemctl enable xinetd.service [root@localhost]# systemctl enable telnet.socket [root@localhost]# systemctl start telnet.socket [root@localhost]# systemctl start xinetd
⑷ 进行 telnet 端口测试
[root@localhost]# telnet 192.168.7.50 Trying 192.168.7.50 Conneted to 192.168.7.50 Escape character is ']'.
当你使用其他机器远程 telnet 的时候,如果不成功,那么很有可能是防火墙的问题,下面我们来修改防火墙的设置。首先,使用 netstat –tunlp 查看是否 23 端口被防火墙封掉了:
再使用 iptables 修改设置,使用 service iptables save 保存设置,然后 service iptables restart 重启防火墙。
如果上述命令执行失败报出 The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
解决方法如下:
[root@localhost]# systemctl stop firewalld [root@localhost]# yum install iptables-services [root@localhost]# systemctl enable iptables [root@localhost]# systemctl start iptables [root@localhost]# iptables -I INPUT -p tcp --dport 23 -jACCEPT [root@localhost]# iptables -I INPUT -p udp --dport 23 -jACCEPT [root@localhost]# service iptables save [root@localhost]# service iptables restart