linux下的netstat命令
linux下的netstat命令
原创 程序员虎王 [程序员虎王](javascript:void(0)😉 2023-02-18 18:52 发表于北京
使用命令man netstat可以看到介绍:
Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
意思是:
打印网络连接、路由表、接口统计信息、伪装连接和多播成员身份
●
netstat -tunlp | grep 端口号
-t (tcp) 仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化为数字
-l 仅列出在Listen(监听)的服务状态
-p 显示建立相关链接的程序名
例如查看 8000 端口的情况,使用以下命令:
netstat -tunlp | grep 8000
●
netstat -a
意义:
Show both listening and non-listening (for TCP this means established connections) sockets. With the --interfaces option, show interfaces that are not up
显示监听和非监听(对于TCP,这意味着已建立连接)套接字。使用--interfaces选项,显示未启动的接口
⬛
结果1
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
示例:
⬛
结果2
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
示例
●
netstat -apu
显示UDP端口号的使用情况
a--代表all
u--代表udp
p意义:
--program
Show the PID and name of the program to which each socket belongs.
●
netstat -i
{--interfaces|-I|-i}
显示网卡列表
●
netstat -g
--groups , -g
Display multicast group membership information for IPv4 and IPv6.
显示IPv4和IPv6的多播组成员身份信息。
●
netstat -s
--statistics , -s
Display summary statistics for each protocol.
显示每个协议的摘要统计信息。
协议列表:
Ip
Icmp
IcmpMsg
Tcp
Udp
UdpLite
TcpExt
IpExt
结果示例:
IP统计结果
TCP统计结果
UDP统计结果
●
netstat -l
-l, --listening
Show only listening sockets. (These are omitted by default.)
仅显示监听套接字。(默认情况下省略这些。)