tcpdump和ngrep抓不到本机数据包

简介:
1
2
3
4
5
6
本机上运行server(nginx)和client(curl),用tcpdump tcp port  80 命令抓不到数据包,原因是:
本地环回不经过以太网卡,在用tcpdump加参数 -i lo 来抓本地环回数据。
 
ngrep环回接口数据抓取方法:使用-d lo参数,注意参数的顺序:ngrep -W byline -d lo port  80
 
注意ngrep使用port  80  而不是tcp port  80 ,如果用tcp port  80  则无法抓取到数据。


使用tcpdump查看数据包的内容(-X表示十六进制):tcpdump -X tcp port 6379

[@bx_10_70 /usr/local/nginx/sbin]# tcpdump -X tcp port 6379

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes

 

 

18:28:14.506298 IP 10.16.10.70.58092 > 10.10.68.205.6379: Flags [P.], seq 1906837172:1906837233, ack 3018595310, win 115, options [nop,nop,TS val 3800684809 ecr 123124458], length 61

        0x0000:  4500 0071 0768 4000 4006 cff2 0a10 0a46  E..q.h@.@......F

        0x0010:  0a0a 44cd e2ec 18eb 71a8 06b4 b3ec 1bee  ..D.....q.......

        0x0020:  8018 0073 6390 0000 0101 080a e289 d909  ...sc...........

        0x0030:  0756 baea 2a33 0d0a 2435 0d0a 5345 544e  .V..*3..$5..SETN

        0x0040:  580d 0a24 3332 0d0a 6261 6339 3832 6336  X..$32..bac982c6

        0x0050:  6531 6563 3436 3930 3832 3266 6439 6534  e1ec4690822fd9e4

        0x0060:  3834 3739 3563 6131 0d0a 2431 0d0a 310d  84795ca1..$1..1.

        0x0070:  0a                                       .

18:28:14.508888 IP 10.10.68.205.6379 > 10.16.10.70.58092: Flags [P.], seq 1:5, ack 61, win 46, options [nop,nop,TS val 123137393 ecr 3800684809], length 4

        0x0000:  4500 0038 ac40 4000 3b06 3053 0a0a 44cd  E..8.@@.;.0S..D.

        0x0010:  0a10 0a46 18eb e2ec b3ec 1bee 71a8 06f1  ...F........q...

        0x0020:  8018 002e d773 0000 0101 080a 0756 ed71  .....s.......V.q

        0x0030:  e289 d909 3a31 0d0a                      ....:1..




本文转自 zhegaozhouji 51CTO博客,原文链接:http://blog.51cto.com/1038741/1750246
相关文章
|
30天前
|
存储 运维 安全
在Linux中,如何使用tcpdump和tshark进行实时数据包捕获?
在Linux中,如何使用tcpdump和tshark进行实时数据包捕获?
|
Shell 容器
使用tcpdump抓取容器中的数据包
学习记录下,容器的网络数据包抓取
691 0
|
网络协议 Linux Windows
使用tcpdump+wireshark抓包分析网络数据包
最近和学弟在调试一个GPRS通信模块,需求是通过GPRS模块通过http协议发送数据到服务器,但是http协议一直失败,服务器返回400,通过查询http状态码得知,http400错误是请求无效,因为GPRS模块没有实现http协议的封装,需要在TCP协议的基础上,手动拼装http格式的报文.
3896 0
|
网络协议 数据安全/隐私保护 Windows
|
网络协议 数据安全/隐私保护 Windows
|
4月前
|
运维 网络协议 安全
【Shell 命令集合 网络通讯 】Linux 网络抓包工具 tcpdump命令 使用指南
【Shell 命令集合 网络通讯 】Linux 网络抓包工具 tcpdump命令 使用指南
148 0
|
4月前
|
网络协议 Linux
Linux命令(120)之tcpdump
Linux命令(120)之tcpdump
66 0
|
10月前
|
Linux
linux下用tcpdump抓包
linux下用tcpdump抓包
|
2月前
|
网络协议 Linux
linux tcpdump 使用小结(二)
linux tcpdump 使用小结(二)
25 1
|
2月前
|
运维 监控 网络协议
Linux抓包命令tcpdump使用技巧大全
【7月更文挑战第10天】
77 5
Linux抓包命令tcpdump使用技巧大全