linux 分析工具--网络

“本文偏于实用,不偏于理论;而且本文力求简单有用;若是想了解的多一些,能够看看其余大神的文章”服务器

一、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复制代码
相关文章
相关标签/搜索