「本文偏於實用,不偏於理論;而且本文力求簡單有用;若是想了解的多一些,能夠看看其餘大神的文章」服務器
一、ping網絡
功能說明:肯定網絡和各外部主機狀態,以及網絡延時。tcp
命令格式:工具
ping IP -c 10
複製代碼
參數說明spa
IP : 表示目標IP地址
-c 10:表示發送10個包後中止
複製代碼
樣例展現code
正常樣例:ip
$ping 192.168.10.111 -c 10
PING 192.168.10.111 (192.168.10.111) 56(84) bytes of data.
64 bytes from 192.168.10.111: icmp_seq=2 ttl=64 time=0.032 ms
64 bytes from 192.168.10.111: icmp_seq=3 ttl=64 time=0.037 ms
64 bytes from 192.168.10.111: icmp_seq=1 ttl=64 time=0.042 ms
64 bytes from 192.168.10.111: icmp_seq=4 ttl=64 time=0.035 ms
64 bytes from 192.168.10.111: icmp_seq=5 ttl=64 time=0.036 ms
64 bytes from 192.168.10.111: icmp_seq=6 ttl=64 time=0.034 ms
64 bytes from 192.168.10.111: icmp_seq=7 ttl=64 time=0.041 ms
64 bytes from 192.168.10.111: icmp_seq=8 ttl=64 time=0.039 ms
64 bytes from 192.168.10.111: icmp_seq=9 ttl=64 time=0.038 ms
64 bytes from 192.168.10.111: icmp_seq=10 ttl=64 time=0.033 ms
--- 192.168.10.111 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 8999ms
rtt min/avg/max/mdev = 0.032/0.036/0.042/0.007 ms
複製代碼
異常樣例:it
$ping 192.168.10.187 -c 10
PING 192.168.10.187 (192.168.10.187) 56(84) bytes of data.
From 192.168.10.18 icmp_seq=1 Destination Host Unreachable
From 192.168.10.18 icmp_seq=2 Destination Host Unreachable
From 192.168.10.18 icmp_seq=3 Destination Host Unreachable
From 192.168.10.18 icmp_seq=4 Destination Host Unreachable
From 192.168.10.18 icmp_seq=5 Destination Host Unreachable
From 192.168.10.18 icmp_seq=6 Destination Host Unreachable
From 192.168.10.18 icmp_seq=7 Destination Host Unreachable
From 192.168.10.18 icmp_seq=8 Destination Host Unreachable
From 192.168.10.18 icmp_seq=9 Destination Host Unreachable
From 192.168.10.18 icmp_seq=10 Destination Host Unreachable
--- 192.168.10.187 ping statistics ---
10 packets transmitted, 0 received, +10 errors, 100% packet loss, time 9001ms
pipe 4s
複製代碼
說明:pip
packet loss :表示丟包率。
min/avg/max/ :表示 最小/平均/最大 耗時。
複製代碼
二、netstatio
功能說明:經過netstat命令顯示端口鏈接狀態及鏈接數量
命令格式
#顯示端口的狀態
netstat -pan |grep PORT
#顯示端口的鏈接數量
netstat -pan|grep PORT|wc -l
#按應用IP概括端口的鏈接數量
netstat -pan|grep PORT|awk '{print $5}'|awk -F":" '{print $1}'|sort -nr|awk '{a[$1]+=1}END{for (i in a){print i,a[i]}}'
#存在TIME_WAIT狀態鏈路的數量
netstat -pan|grep PORT |grep TIME_WAIT|wc -l
複製代碼
三、tcpdump
功能說明:經過tcpdump工具抓取通訊的數據包。
命令格式
tcpdump -i device -c number host IP -w test.cap
複製代碼
參數說明
-i:後面device爲服務器使用網卡名稱
-c:抓包個數
host:後跟服務器本機IP
-w:將抓到的內容寫入test.cap文件中。
複製代碼
說明:tcpdump抓取的包,須要使用wireshark工具進行分析。wireshark使用在後續的文章中會說。若是暫時沒有wireshark工具,能夠使用tcpdump的命令來簡單查看一下
tcpdump -tttt -r test.cap >test.log複製代碼