怎么在Linux服务器上测试TCP/UDP端口的连通性?
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
翻译自:
How to Test Port[TCP/UDP] Connectivity from a Linux Server (文档 ID 2212626.1)
适用于:
Linux OS - Version Oracle Linux 5.0 to Oracle Linux 6.8 [Release OL5 to OL6U8]
Information in this document applies to any platform.
目标:
在Linux服务器上检查TCP/UDP端口的连通性。
解决方案:
telnet和nc 是用来测试端口连通性的一般工具。
telnet可以测试tcp端口的连通性。
nc可以测试tcp和udp端口的连通性。
请确保telnet和nc工具已经安装
# yum install nc
# yum install telnet
测试tcp端口的连通性:
语法如下:
telnet <hostname/IP address> <port number>
如下是连通成功的例子:
# telnet 192.118.20.95 22
Trying 192.118.20.95...
Connected to 192.118.20.95.
Escape character is '^]'.
SSH-2.0-OpenSSH_6.6.1
Protocol mismatch.
Connection closed by foreign host.
如下是连通不成功的例子:
# telnet 192.118.20.95 22
Trying 192.118.20.95...
telnet: connect to address 192.118.20.95: No route to host
使用nc命令来测试tcp端口的连通性:
语法:
nc -z -v <hostname/IP address> <port number>
如下是连通成功的例子:
# nc -z -v 192.118.20.95 22
Connection to 192.118.20.95 22 port [tcp/ssh] succeeded!
如下是连通不成功的例子:
# nc -z -v 192.118.20.95 22
nc: connect to 192.118.20.95 port 22 (tcp) failed: No route to host
使用nc命令来测试udp端口的连通性:
语法:
nc -z -v -u <hostname/IP address> <port number>
# nc -z -v -u 192.118.20.95 123
Connection to 192.118.20.95 123 port [udp/ntp] succeeded!
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献9条内容
所有评论(0)