温馨提示×

linux telnet常见错误有哪些

小樊
47
2026-10-12 09:44:26
栏目: 智能运维

在 Linux 下使用 telnet 时,常见错误主要分为连接类错误、认证/服务类错误、配置/环境类错误。下面按场景总结最常见的问题及含义。


一、连接类常见错误

1. Connection refused

原因:

  • 目标端口没有服务监听
  • 服务未启动
  • 服务只监听 127.0.0.1,而你连的是外网 IP

示例:

telnet 192.168.1.10 8080
Trying 192.168.1.10...
telnet: connect to address 192.168.1.10: Connection refused

排查:

ss -lntp | grep 8080
netstat -lntp | grep 8080

2. Connection timed out

原因:

  • 防火墙阻断
  • 网络不通
  • 中间设备(路由器/安全组)丢弃包

示例:

telnet 10.0.0.5 23
Trying 10.0.0.5...
telnet: connect to address 10.0.0.5: Connection timed out

排查:

ping 10.0.0.5
tcpdump -nn host 10.0.0.5
iptables -L -n

3. No route to host

原因:

  • 目标主机不可达
  • 路由缺失
  • 被防火墙 REJECT
telnet: connect to address 192.168.100.1: No route to host

4. Name or service not known

原因:

  • 域名解析失败
  • DNS 配置错误
telnet example.test 23
example.test: Name or service not known

排查:

cat /etc/resolv.conf
nslookup example.test

二、Telnet 服务本身问题

5. Unable to connect to remote host

通用错误,通常伴随上述原因(refused / timeout)


6. Login failed / 登录后立即断开

原因:

  • 用户名或密码错误
  • /etc/securetty 限制
  • PAM 配置问题
  • root 被禁止 telnet

7. Permission denied

原因:

  • 用户无登录权限
  • shell 被禁止(/sbin/nologin)

三、Telnet 客户端报错

8. telnet: command not found

原因:

  • 未安装 telnet 客户端

解决:

# CentOS / RHEL
yum install -y telnet

# Ubuntu / Debian
apt install -y telnet

9. Escape character is '^]'

这不是错误! 表示 telnet 已连接成功,等待输入。


四、服务器端常见配置错误

10. telnet 服务未安装 / 未启动

systemctl status telnet.socket

11. 防火墙未放行 23 端口

iptables -A INPUT -p tcp --dport 23 -j ACCEPT

12. xinetd 配置错误(老系统)

常见错误:

  • disable = yes 未改
  • only_from 限制过严

五、安全相关(重要)

⚠️ telnet 是明文协议,生产环境不推荐使用

  • 密码可被抓包
  • 建议用 ssh

六、快速排查清单

ping 目标IP
telnet IP 端口
ss -lntp | grep 端口
iptables -L -n
systemctl status telnet.socket

如果你愿意,可以告诉我:

  • 你用的是 哪类服务(SSH?HTTP?数据库?)
  • 报错 完整截图或文字

我可以帮你精准定位问题。

0 踩