萬盛學電腦網

 萬盛學電腦網 >> 服務器教程 >> Linux下常用網絡命令總結

Linux下常用網絡命令總結

   你可以使用以下任何一個命令:

  nstat 命令 : 網絡統計工具

  鍵入以下命令:

  代碼如下:

  # nstat

  輸出樣例:

  #kernel

  IpInReceives 133243 0.0

  IpInDelivers 133243 0.0

  IpOutRequests 92904 0.0

  IcmpOutErrors 97 0.0

  IcmpOutTimeExcds 97 0.0

  IcmpMsgOutType3 97 0.0

  TcpActiveOpens 538 0.0

  TcpEstabResets 56 0.0

  TcpInSegs 129837 0.0

  TcpOutSegs 89720 0.0

  TcpRetransSegs 42 0.0

  TcpOutRsts 704 0.0

  UdpInDatagrams 3255 0.0

  UdpNoPorts 97 0.0

  UdpOutDatagrams 3270 0.0

  Ip6OutNoRoutes 206 0.0

  TcpExtTW 141 0.0

  TcpExtDelayedACKs 508 0.0

  TcpExtDelayedACKLocked 1 0.0

  TcpExtDelayedACKLost 42 0.0

  TcpExtTCPHPHits 117659 0.0

  TcpExtTCPPureAcks 2158 0.0

  TcpExtTCPHPAcks 605 0.0

  TcpExtTCPSackRecovery 1 0.0

  TcpExtTCPLossUndo 16 0.0

  TcpExtTCPSackFailures 4 0.0

  TcpExtTCPFastRetrans 1 0.0

  TcpExtTCPSlowStartRetrans 3 0.0

  TcpExtTCPTimeouts 33 0.0

  TcpExtTCPDSACKOldSent 40 0.0

  TcpExtTCPDSACKRecv 5 0.0

  TcpExtTCPAbortOnData 120 0.0

  TcpExtTCPAbortOnClose 55 0.0

  TcpExtTCPSackShiftFallback 9 0.0

  IpExtInOctets 180131682 0.0

  IpExtOutOctets 7289106 0.0

  ss 命令 : 查詢套接字工具

  要查看統計匯總, 輸入:

  代碼如下:

  # ss -s

  輸出樣例:

  Total: 786 (kernel 804)

  TCP: 65 (estab 40, closed 7, orphaned 0, synrecv 0, timewait 6/0), ports 56

  Transport Total IP IPv6

  * 804 - -

  RAW 1 1 0

  UDP 12 9 3

  TCP 58 52 6

  INET 71 62 9

  FRAG 0 0 0

  netstat 命令 : 不錯的顯示套接字信息的舊工具

  查看所有網絡端口以及匯總信息表,輸入:

  代碼如下:

  # netstat -i

  輸出樣例:

  Kernel Interface table

  Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg

  eth0 1500 0 941022 0 0 0 688165 0 0 0 BMRU

  lo 16436 0 9304 0 0 0 9304 0 0 0 LRU

  ppp0 1496 0 3784 0 0 0 4177 0 0 0 MOPRU

  查看每個協議的匯總統計信息,輸入:

  代碼如下:

  # netstat -s

  輸出樣例:

  Ip:

  1092065 total packets received

  0 forwarded

  0 incoming packets discarded

  1091681 incoming packets delivered

  798913 requests sent out

  895 dropped because of missing route

  759 reassemblies required

  375 packets reassembled ok

  Icmp:

  17 ICMP messages received

  0 input ICMP message failed.

  ICMP input histogram:

  timeout in transit: 8

  echo replies: 9

  1747 ICMP messages sent

  0 ICMP messages failed

  ICMP output histogram:

  destination unreachable: 1730

  echo request: 17

  IcmpMsg:

  InType0: 9

  InType11: 8

  OutType3: 1730

  OutType8: 17

  Tcp:

  4822 active connections openings

  1129 passive connection openings

  457 failed connection attempts

  165 connection resets received

  7 connections established

  1062519 segments received

  771394 segments send out

  7158 segments retransmited

  6 bad segments received.

  2578 resets sent

  Udp:

  20846 packets received

  1730 packets to unknown port received.

  0 packet receive errors

  19242 packets sent

  UdpLite:

  TcpExt:

  71 invalid SYN cookies received

  8 resets received for embryonic SYN_RECV sockets

  142 packets pruned from receive queue because of socket buffer overrun

  2109 TCP sockets finished time wait in fast timer

  84 packets rejects in established connections because of timestamp

  19454 delayed acks sent

  6 delayed acks further delayed because of locked socket

  Quick ack mode was activated 7306 times

  1 packets directly queued to recvmsg prequeue.

  1 bytes directly received in process context from prequeue

  823921 packet headers predicted

  24412 acknowledgments not containing data payload received

  10150 predicted acknowledgments

  242 times recovered from packet loss by selective acknowledgements

  33 congestion windows recovered without slow start by DSACK

  335 congestion windows recovered without slow start after partial ack

  336 TCP data loss events

  TCPLostRetransmit: 35

  1 timeouts after reno fast retransmit

  156 timeouts after SACK recovery

  116 timeouts in loss state

  461 fast retransmits

  5 forward retransmits

  608 retransmits in slow start

  2073 other TCP timeouts

  62 SACK retransmits failed

  43074 packets collapsed in receive queue due to low socket buffer

  8499 DSACKs sent for old packets

  101 DSACKs sent for out of order packets

  308 DSACKs received

  9 DSACKs for out of order packets received

  427 connections reset due to unexpected data

  122 connections reset due to early user close

  28 connections aborted due to timeout

  TCPDSACKIgnoredOld: 3

  TCPDSACKIgnoredNoUndo: 60

  TCPSpuriousRTOs: 4

  TCPSackShifted: 282

  TCPSackMerged: 740

  TCPSackShiftFallback: 1017

  IpExt:

  InMcastPkts: 47

  OutMcastPkts: 51

  InBcastPkts: 1

  InOctets: 1341508973

  OutOctets: 72525352

  InMcastOctets: 8649

  OutMcastOctets: 7519

  InBcastOctets: 328

  ip / ifconfig 命令 : 配置或者顯示網絡端口信息

  鍵入以下命令:

  代碼如下:

  # ifconfig

  或者

  復制代碼

  代碼如下:

  # /sbin/ifconfig

  或者

  代碼如下:

  # ifconfig eth0

  eth0 Link encap:Ethernet HWaddr b8:ac:6f:65:31:e5

  inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0

  inet6 addr: fe80::baac:6fff:fe65:31e5/64 Scope:Link

  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

  RX packets:966334 errors:0 dropped:0 overruns:0 frame:0

  TX packets:703297 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:1000

  RX bytes:1186255648 (1.1 GiB) TX bytes:73968238 (70.5 MiB)

  Interrupt:17

  lo Link encap:Local Loopback

  inet addr:127.0.0.1 Mask:255.0.0.0

  inet6 addr: ::1/128 Scope:Host

  UP LOOPBACK RUNNING MTU:16436 Metric:1

  RX packets:9666 errors:0 dropped:0 overruns:0 frame:0

  TX packets:9666 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:0

  RX bytes:1399578 (1.3 MiB) TX bytes:1399578 (1.3 MiB)

  ppp0 Link encap:Point-to-Point Protocol

  inet addr:10.1.11.70 P-t-P:10.0.31.18 Mask:255.255.255.255

  UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1

  RX packets:3784 errors:0 dropped:0 overruns:0 frame:0

  TX packets:4177 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:3

  RX bytes:2400265 (2.2 MiB) TX bytes:275983 (269.5 KiB)

  顯示網絡端口統計信息,輸入:

  代碼如下:

copyright © 萬盛學電腦網 all rights reserved