
正文
【tshark tcpdump】linux网络排查
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
抓包:
1、tcpdump
2、tshark是wireshark的命令行版。
tshark使用示例:
,实时打印当前http请求的url
# tshark -s -i eth0 -n -f 'tcp dst port 80' -R 'http.host and http.request.uri' -T fields -e http.host -e http.request.uri -l | tr -d '\t'
参数含义:
-s :只抓取前512个字节数据
-i eth0 :捕获eth0网卡
-n :禁止网络对象名称解析
-f 'tcp dst port 80' :只捕捉协议为tcp,目的端口为80的数据包
-R 'http.host and http.request.uri' :过滤出http.host和http.request.uri
-T fields -e http.host -e http.request.uri :打印http.host和http.request.uri
-l :输出到标准输出
、实时打印当前mysql查询语句
# tshark -s -i eth0 -n -f 'tcp dst port 3306' -R 'mysql.query' -T fields -e mysql.query
参数含义:
-s :只抓取前512个字节数据
-i eth0 :捕获eth0网卡
-n :禁止网络对象名称解析
-f 'tcp dst port 3306' :只捕捉协议为tcp,目的端口为3306的数据包
-R 'mysql.query' :过滤出mysql.query
-T fields -e mysql.query :打印mysql查询语句
tshark -f 'tcp dst port 6443'
3、查看网络流量 iftop
iftop,查看哪个进程占用带宽







