netstat-打印網絡鏈接,路由表,接口統計信息的工具,在日常工做也會常常遇到;nginx
經常使用選項:
docker
-i:查看網卡數據包收發狀況(經常使用於查看是否有丟包、錯誤)bash
-s:對各類協議的統計信息網絡
-r:查看路由表信息(也經常使用route -n)查看
socket
用法示例一:查看網絡包收發狀況,以肯定是否存在丟包的狀況(當網絡存在延遲的時候用)
tcp
[root@admin test]# netstat -i Kernel Interface table Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg docker0 1500 34954 0 0 0 39693 0 0 0 BMRU eth0 1500 14214045 0 0 0 12320299 0 0 0 BMRU lo 65536 438426 0 0 0 438426 0 0 0 LRU vethd0731cd 1500 271 0 0 0 345 0 0 0 BMRU
RX-OK:接收的總包數ide
RX-ERR:總錯誤數工具
RX-DRP:進入 Ring Buffer 後因其餘緣由(如內存不足)致使的丟包數spa
RX-OVR:Ring Buffer 溢出致使的丟包數 接口
TX-OK等也是相似的
用法示例二:對各類協議的統計信息(經常使用於確認傳輸層和網絡層是否出現問題)
會對ip、icmp、tcp、udp協議的網絡包數據進行統計
[root@nginx ~]# netstat -s Tcp: 0 active connection openings 3 passive connection openings 22 failed connection attempts 0 connection resets received 0 connections established 64 segments received 51 segments sent out 8 segments retransmitted 0 bad segments received 0 resets sent ... TcpExt: 22 resets received for embryonic SYN_RECV sockets 2 TCP sockets finished time wait in fast timer 0 packet headers predicted 8 acknowledgments not containing data payload received TCPTimeouts: 13 TCPOFOQueue: 2 TCPSynRetrans: 8 TCPOrigDataSent: 5 TCPDelivered: 5 IpExt: ...
22次鏈接失敗重試(22 failed connection attempts)
8 次重傳(8 segments retransmitted)
11 次半鏈接重置(11 resets received for embryonic SYN_RECV sockets)
8 次 SYN 重傳(TCPSynRetrans)
13 次超時(TCPTimeouts)