在 Debian 里用 telnet 测试网络,通常不是“测网速”,而是测某个 IP/端口是否通,用来排查服务是否正常、防火墙是否放行等。
下面按常见场景说明。
Debian 默认可能没装:
which telnet
没装就安装:
sudo apt update
sudo apt install telnet -y
telnet <IP或域名> <端口>
telnet 192.168.1.10 22
如果看到类似:
Connected to 192.168.1.10.
Escape character is '^]'.
SSH-2.0-OpenSSH_8.4
✅ 说明网络和服务都正常
如果卡住或提示:
Connection refused
❌ 服务没开或端口不对
如果一直 Trying... 后超时:
❌ 网络不通或防火墙拦截
telnet www.example.com 80
连接后手动发请求(可选):
GET / HTTP/1.1
Host: www.example.com
回车两次,能看到 HTTP 响应说明正常。
telnet 127.0.0.1 3306 # MySQL
telnet 127.0.0.1 6379 # Redis
telnet 127.0.0.1 25 # SMTP
Ctrl + ]
然后输入:
quit
⚠️ 注意:
UDP 测试推荐:
nc -u <IP> <端口>
nc -vz 192.168.1.10 22
curl -I http://192.168.1.10
ping 192.168.1.1
| 现象 | 可能原因 |
|---|---|
| Connection refused | 服务未启动 |
| 超时 | 防火墙 / 路由问题 |
| 本地能连,远程不能 | 安全组 / iptables |
| DNS 解析失败 | /etc/resolv.conf 配置问题 |
如果你愿意,可以告诉我:
我可以帮你精确分析。