netstat -a 不显示所有端口的红热

问题描述

我执行命令 netstat -a|grep 7777 并没有看到端口 7777,我尝试使用选项 -an 的命令并查看它,我尝试使用选项 -n 并再次没有看到它。请告诉我为什么会这样?谢谢。

解决方法

来自 netstat 的手册页:

-a,--all
   Show both listening and non-listening (for TCP this  means  established  connections)
   sockets.  With the --interfaces option,show interfaces that are not up

--numeric-ports
   shows  numerical  port  numbers  but  does  not affect the resolution of host or user
   names.

您需要 -n 来显示 IP 地址而不是解析的 DNS 地址和编号端口而不是命名端口。您还需要 -a 来显示监听以及已建立的连接(没有 -a 就不会显示)