編碼的世界 / 優質文選 / 生物

Linux使用NC命令檢測TCP/UDP端口是否可通


2021年7月19日
-   

Linux下 Netstat工具 簡稱NC,號稱是網絡工具中的“瑞士軍刀”,今日一見果然名不虛傳。 我們都知道檢測TCP端口是否可通的命令是telnet,在windows和Linux都可以用,但telnet不能檢測udp端口,今天給大家介紹的是Linux下 NC命令用於檢測UDP端口是否可通。
Telnet 檢測TCP端口
[root@apexsoft ~]# telnet 127.0.0.1 8906
Trying 127.0.0.1
Connected to 127.0.0.1.
Escape character is '^]'.
^CConnection closed by foreign host.

NC 檢測TCP端口
[root@apexsoft ~]# nc -vz 127.0.0.1 8906
Connection to 127.0.0.1 8906 port [tcp/*] succeeded!

NC 檢測UDP端口
檢測udp端口的時候不會立即返回測試結果,可能需要等待幾秒鐘
[root@apexsoft ~]# nc -uz 127.0.0.1 8907
Connection to 127.0.0.1 8907 port [udp/*] succeeded!

熱門文章