随笔 - 16,  文章 - 0,  评论 - 3,  阅读 - 30759

1.TCP端口的连通性

TCP端口的连通性,一般通过telnet检测,命令格式如下:

telnet <targetHost> <targetPort>

如果出现以下内容,则表示TCP端口连通性是OK的:

[root@localhost ~]# telnet localhost 33401
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

否则就表示网络不通,需要开通网络连通。

TCP端口连通性也可以通过nc命令来检查,命令格式如下:

nc <targetIp> <targetPort>

如果执行nc命令直接退出,则表示网络不通,需要开通网络连通,如下:

[root@localhost ~]# nc localhost 33401
[root@localhost ~]# 

2.UDP端口的连通性

对于UDP端口,因为UDP协议是无连接的,不需要握手建立连接,数据发送后,server端也不会返回确认信息。

一般可以使用netcat检测,命令格式如下:

nc -vuz <targetIp> <targetPort>

看能否发送成功,发送成功,则表示可连通,如下:

[root@localhost ~]# nc -vuz localhost 33401
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Connected to 127.0.0.1:33401.
Ncat: UDP packet sent successfully
Ncat: 1 bytes sent, 0 bytes received in 2.01 seconds.

 

posted on   圣上有喜  阅读(4645)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示