在 Ubuntu 中,你可以使用 telnet 命令来测试网络连通性。以下是具体步骤:
打开终端:你可以通过按 Ctrl + Alt + T 快捷键来打开终端。
安装 Telnet 客户端(如果尚未安装):
在某些 Ubuntu 版本中,telnet 可能没有预装。你可以使用以下命令来安装它:
sudo apt update
sudo apt install telnet
使用 Telnet 测试连接: 使用以下命令格式来测试与特定主机和端口的连接:
telnet <hostname> <port>
例如,要测试与 www.example.com 的 HTTP 服务(通常在端口 80)的连接,可以输入:
telnet www.example.com 80
解读结果:
Trying xxx.xxx.xxx.xxx...
Connected to www.example.com.
Escape character is '^]'.
Trying xxx.xxx.xxx.xxx...
telnet: Unable to connect to remote host: Connection refused
退出 Telnet:
你可以输入 quit 或按 Ctrl + ] 然后输入 quit 来退出 Telnet 会话。
请注意,由于安全和功能原因,Telnet 不再被推荐用于安全的网络连接测试。对于更安全的替代方案,可以考虑使用 ssh 或 nc(netcat)。