在 Linux 下测试 telnet 连通性,通常是指:
确认某台主机的某个 TCP 端口是否能通过 telnet 方式连通。
下面按常见场景说明。
telnet <IP或域名> <端口>
示例:
telnet 192.168.1.10 23
telnet www.example.com 80
连接成功
Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is '^]'.
✅ 表示端口通
连接失败 / 超时
Trying 192.168.1.10...
telnet: connect to address 192.168.1.10: Connection timed out
❌ 网络不通或被防火墙拦截
端口拒绝
Connection refused
❌ 目标端口未监听
yum install -y telnet
apt install -y telnet
很多服务器已禁用 telnet,可用以下方式:
nc -vz 192.168.1.10 23
Connection to 192.168.1.10 23 port [tcp/*] succeeded!timeout 3 bash -c 'echo > /dev/tcp/192.168.1.10/23' && echo "通" || echo "不通"
curl -v telnet://192.168.1.10:23
防火墙
iptables / firewalld目标服务未启动
ss -lntp | grep 23
中间网络问题
ping 192.168.1.10
traceroute 192.168.1.10
如果你愿意,可以告诉我:
我可以给你更精确的命令。