小编给大家分享一下Linux常用命令netstat怎么用,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

Linux常用命令netstat 命令用于显示网络状态,利用 netstat 指令可让你得知整个 Linux 系统的网络情况

语法

netstat[-acCeFghilMnNoprstuvVwx][-A][--ip]

参数说明:

-a或–all 显示所有连线中的Socket。

-A或– 列出该网络类型连线中的相关地址。

-c或–continuous 持续列出网络状态。

-C或–cache 显示路由器配置的快取信息。

-e或–extend 显示网络其他相关信息。

-F或–fib 显示路由缓存。

-g或–groups 显示多重广播功能群组组员名单。

-h或–help 在线帮助。

-i或–interfaces 显示网络界面信息表单。

-l或–listening 显示监控中的服务器的Socket。

-M或–masquerade 显示伪装的网络连线。

-n或–numeric 直接使用IP地址,而不通过域名服务器。

-N或–netlink或–symbolic 显示网络硬件外围设备的符号连接名称。

-o或–timers 显示计时器。

-p或–programs 显示正在使用Socket的程序识别码和程序名称。

-r或–route 显示Routing Table。

-s或–statistics 显示网络工作信息统计表。

-t或–tcp 显示TCP传输协议的连线状况。

-u或–udp 显示UDP传输协议的连线状况。

-v或–verbose 显示指令执行过程。

-V或–version 显示版本信息。

-w或–raw 显示RAW传输协议的连线状况。

-x或–unix 此参数的效果和指定”-A unix”参数相同。

–ip或–inet 此参数的效果和指定”-A inet”参数相同。

实例

显示详细的网络状况

#netstat-a

显示当前户籍UDP连接状况

#netstat-nu

显示UDP端口号的使用情况

#netstat-apuActiveInternetconnections(serversandestablished)ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programnameudp00*:32768*:*-udp00*:nfs*:*-udp00*:641*:*3006/rpc.statdudp00192.168.0.3:netbios-ns*:*3537/nmbdudp00*:netbios-ns*:*3537/nmbdudp00192.168.0.3:netbios-dgm*:*3537/nmbdudp00*:netbios-dgm*:*3537/nmbdudp00*:tftp*:*3346/xinetdudp00*:999*:*3366/rpc.rquotadudp00*:sunrpc*:*2986/portmapudp00*:ipp*:*6938/cupsdudp00*:1022*:*3392/rpc.mountdudp00*:638*:*3006/rpc.statd

显示网卡列表

#netstat-iKernelInterfacetableIfaceMTUMetRX-OKRX-ERRRX-DRPRX-OVRTX-OKTX-ERRTX-DRPTX-OVRFlgeth015000181864000141278000BMRUlo16436033620003362000LRU

显示组播组的关系

#netstat-gIPv6/IPv4GroupMembershipsInterfaceRefCntGroup------------------------------------------lo1ALL-SYSTEMS.MCAST.NETeth01ALL-SYSTEMS.MCAST.NETlo1ff02::1eth01ff02::1:ff0a:b0ceth01ff02::1

显示网络统计信息

#netstat-sIp:184695totalpacketsreceived0forwarded0incomingpacketsdiscarded184687incomingpacketsdelivered143917requestssentout32outgoingpacketsdropped30droppedbecauseofmissingrouteIcmp:676ICMPmessagesreceived5inputICMPmessagefailed.ICMPinputhistogram:destinationunreachable:44echorequests:287echoreplies:345304ICMPmessagessent0ICMPmessagesfailedICMPoutputhistogram:destinationunreachable:17echoreplies:287Tcp:473activeconnectionsopenings28passiveconnectionopenings4failedconnectionattempts11connectionresetsreceived1connectionsestablished178253segmentsreceived137936segmentssendout29segmentsretransmited0badsegmentsreceived.336resetssentUdp:5714packetsreceived8packetstounknownportreceived.0packetreceiveerrors5419packetssentTcpExt:1resetsreceivedforembryonicSYN_RECVsocketsArpFilter:012TCPsocketsfinishedtimewaitinfasttimer572delayedackssent3delayedacksfurtherdelayedbecauseoflockedsocket13766packetsdirectlyqueuedtorecvmsgprequeue.1101482packetsdirectlyreceivedfrombacklog19599861packetsdirectlyreceivedfromprequeue46860packetsheaderpredicted14541packetsheaderpredictedanddirectlyqueuedtouserTCPPureAcks:12259TCPHPAcks:9119TCPRenoRecovery:0TCPSackRecovery:0TCPSACKReneging:0TCPFACKReorder:0TCPSACKReorder:0TCPRenoReorder:0TCPTSReorder:0TCPFullUndo:0TCPPartialUndo:0TCPDSACKUndo:0TCPLossUndo:0TCPLoss:0TCPLostRetransmit:0TCPRenoFailures:0TCPSackFailures:0TCPLossFailures:0TCPFastRetrans:0TCPForwardRetrans:0TCPSlowStartRetrans:0TCPTimeouts:29TCPRenoRecoveryFail:0TCPSackRecoveryFail:0TCPSchedulerFailed:0TCPRcvCollapsed:0TCPDSACKOldSent:0TCPDSACKOfoSent:0TCPDSACKRecv:0TCPDSACKOfoRecv:0TCPAbortOnSyn:0TCPAbortOnData:1TCPAbortOnClose:0TCPAbortOnMemory:0TCPAbortOnTimeout:3TCPAbortOnLinger:0TCPAbortFailed:3TCPMemoryPressures:0

显示监听的套接口

#netstat-lActiveInternetconnections(onlyservers)ProtoRecv-QSend-QLocalAddressForeignAddressStatetcp00*:32769*:*LISTENtcp00*:nfs*:*LISTENtcp00*:644*:*LISTENtcp00*:1002*:*LISTENtcp00*:netbios-ssn*:*LISTENtcp00*:sunrpc*:*LISTENtcp00vm-dev:ipp*:*LISTENtcp00*:telnet*:*LISTENtcp00*:601*:*LISTENtcp00*:microsoft-ds*:*LISTENtcp00*:http*:*LISTENtcp00*:ssh*:*LISTENtcp00*:https*:*LISTENudp00*:32768*:*udp00*:nfs*:*udp00*:641*:*udp00192.168.0.3:netbios-ns*:*udp00*:netbios-ns*:*udp00192.168.0.3:netbios-dgm*:*udp00*:netbios-dgm*:*udp00*:tftp*:*udp00*:999*:*udp00*:sunrpc*:*udp00*:ipp*:*udp00*:1022*:*udp00*:638*:*ActiveUNIXdomainsockets(onlyservers)ProtoRefCntFlagsTypeStateI-NodePathunix2[ACC]STREAMLISTENING10621@/tmp/fam-root-unix2[ACC]STREAMLISTENING7096/var/run/acpid.socketunix2[ACC]STREAMLISTENING9792/tmp/.gdm_socketunix2[ACC]STREAMLISTENING9927/tmp/.X11-unix/X0unix2[ACC]STREAMLISTENING10489/tmp/ssh-lbUnUf4552/agent.4552unix2[ACC]STREAMLISTENING10558/tmp/ksocket-root/kdeinit__0unix2[ACC]STREAMLISTENING10560/tmp/ksocket-root/kdeinit-:0unix2[ACC]STREAMLISTENING10570/tmp/.ICE-unix/dcop4664-1270815442unix2[ACC]STREAMLISTENING10843/tmp/.ICE-unix/4735unix2[ACC]STREAMLISTENING10591/tmp/ksocket-root/klauncherah4arc.slave-socketunix2[ACC]STREAMLISTENING7763/var/run/iiim/.iiimp-unix/9010unix2[ACC]STREAMLISTENING11047/tmp/orbit-root/linc-1291-0-1e92c8082411unix2[ACC]STREAMLISTENING11053/tmp/orbit-root/linc-128e-0-dc070659cbb3unix2[ACC]STREAMLISTENING8020/var/run/dbus/system_bus_socketunix2[ACC]STREAMLISTENING58927/tmp/mcop-root/vm-dev-2c28-4beba75funix2[ACC]STREAMLISTENING7860/tmp/.font-unix/fs7100unix2[ACC]STREAMLISTENING7658/dev/gpmctlunix2[ACC]STREAMLISTENING10498@/tmp/dbus-s2MLJGO5Ci

看完了这篇文章,相信你对“Linux常用命令netstat怎么用”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!