在 Ubuntu 上“测试 telnet”通常有两层含义:① 测试系统是否安装了 telnet 客户端;② 用 telnet 测试某个 IP/端口是否连通。下面分别说明。
Ubuntu 默认通常不安装 telnet 客户端。
sudo apt update
sudo apt install telnet -y
安装完成后检查:
which telnet
例如测试 192.168.1.100 的 23 端口:
telnet 192.168.1.100 23
Trying 192.168.1.100...
telnet: Unable to connect to remote host: Connection refused
或Connection timed out
telnet google.com 80
telnet mail.example.com 25
sudo apt install telnetd
sudo systemctl start inetd
然后本地测试:
telnet localhost
⚠️ telnet 是明文协议,生产环境不建议使用
nc -zv 192.168.1.100 23
curl -v telnet://192.168.1.100:23
ssh user@host
| 问题 | 原因 |
|---|---|
| Connection refused | 目标端口未监听 |
| Connection timed out | 防火墙 / 网络不通 |
| command not found | 未安装 telnet |
如果你愿意,可以告诉我:
我可以给你更精确的命令。