当前位置:网站首页>史上最简明的 Tcpdump 入门指南,看这一篇就够了
史上最简明的 Tcpdump 入门指南,看这一篇就够了
2022-07-27 20:51:00 【果子哥丶】
简介
网络数据包截获分析工具。支持针对网络层、协议、主机、网络或端口的过滤。并提供and、or、not等逻辑语句帮助去除无用的信息。
例子
1、监听特定网卡
tcpdump -i en0
2、监听特定主机
例子:监听本机跟主机182.254.38.55之间往来的通信包。
备注:出、入的包都会被监听。
tcpdump host 182.254.38.55
3、特定来源、目标地址的通信
特定来源
tcpdump src host hostname
特定目标地址
tcpdump dst host hostname
如果不指定 src 跟 dst,那么来源 或者目标 是hostname的通信都会被监听
tcpdump host hostname
4、特定端口
tcpdump port 3000
5、来源主机+端口+TCP
监听来自主机 123.207.116.169 在端口 22 上的TCP数据包
tcpdump tcp port 22 and src host 123.207.116.169
监听特定主机之间的通信
tcpdump ip host 210.27.48.1 and 210.27.48.2
监听210.27.48.1 除了和 210.27.48.2 之外的主机之间的通信
tcpdump ip host 210.27.48.1 and ! 210.27.48.2
6、
tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap
(1)tcp: ip icmp arp rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置,用来过滤数据报的类型
(2)-i eth1 : 只抓经过接口eth1的包
(3)-t : 不显示时间戳
(4)-s 0 : 抓取数据包时默认抓取长度为68字节。加上-S 0 后可以抓到完整的数据包
(5)-c 100 : 只抓取100个数据包
(6)dst port ! 22 : 不抓取目标端口是22的数据包
(7)src net 192.168.1.0/24 : 数据包的源网络地址为192.168.1.0/24
(8)-w ./target.cap : 保存成cap文件,方便用ethereal(即wireshark)分析
7、保存到本地
备注:tcpdump默认会将输出写到缓冲区,只有缓冲区内容达到一定的大小,或者tcpdump退出时,才会将输出写到本地磁盘
tcpdump -n -vvv -c 1000 -w /tmp/tcpdump_save.cap
实战例子
先看下面一个比较常见的部署方式,在服务器上部署了nodejs server,监听3000端口。nginx反向代理监听80端口,并将请求转发给nodejs server(127.0.0.1:3000)。
浏览器 -> nginx反向代理 -> nodejs server
问题:假设用户(183.14.132.117)访问浏览器,发现请求没有返回,该怎么排查呢?
步骤一:查看请求是否到达nodejs server -> 可通过日志查看。
步骤二:查看nginx是否将请求转发给nodejs server。
tcpdump port 3000
复制代码这时你会发现没有任何输出,即使nodejs server已经收到了请求。
因为nginx转发到的地址是127.0.0.1,用的不是默认的interface,此时需要显示指定interface
tcpdump port 8383 -i lo
复制代码备注:配置nginx,让nginx带上请求侧的host,不然nodejs server无法获取 src host,也就是说,
上面的监听是无效的,因为此时对于nodejs server来说,src host 都是 127.0.0.1
tcpdump port 8383 -i lo and src host 183.14.132.117
步骤三:查看请求是否达到服务器
tcpdump -n tcp port 8383 -i lo and src host 183.14.132.117
边栏推荐
- The print version of imeta | international standard ISSN is officially confirmed, and the application for dual ISSN is completed
- Software test function test full set of common interview questions [function test] interview summary 4-2
- Zabbix4.0 uses SNMP agent to monitor vcenter6.5
- 日产1500万只!比亚迪口罩拿下美国加州10亿美元订单
- [signal denoising] signal denoising based on Kalman filter with matlab code
- 强化学习——PyTorch 实现 Advantage Actor-Critic (A2C)
- Common Taylor expansion
- 360 was selected into the panorama of China's security industry, and isc2022 talked about the direction of security services in 63 fields
- Preliminary understanding of Panda3D audio and advanced interactive components
- ZCMU--1720: 死亡如风,我要装逼
猜你喜欢

常用泰勒展开

The principle and demonstration of service path lifting without quotation marks
Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (5) - detailed explanation of fiddler monitoring panel

一篇文章读懂人工神经网络

With double-digit growth in revenue and profit, China Resources Yibao has quietly created these new products worth more than 100 million
![[number recognition] handwritten number recognition based on knowledge base with matlab code](/img/06/6adab955a339f453249543baab1dc6.png)
[number recognition] handwritten number recognition based on knowledge base with matlab code

Common Taylor expansion

【ELM分类】基于核极限学习机和极限学习机实现UCI数据集分类附matlab代码

Exercise --- BFS

Ideas, methods and steps of making folding fans with 3DMAX
随机推荐
Can Siemens PLC collect analog data of multiple slave stations in real time and wirelessly?
Simple and practical data visualization cases
Accelerate IGBT localization! BYD semiconductor will be listed independently, with a market value of 30billion yuan!
After returning to mixlab for three days, "creative team" cured my spiritual internal friction
[soft test software evaluator] 2014 comprehensive knowledge over the years
Interviewer: I can't carry a backpack at all. Are you going by yourself or I'll give you a lift?
reduce错误示范
Pro multi store version system, versatile is it!
用户画像在科技期刊微信公众号精准推送中的应用
一加将在2020年释放ODM订单,发力中低端市场
真的很难理解?RecyclerView 缓存机制到底是几级缓存?
简单实用的数据可视化案例
新技术引领大中型企业营销新变革,用友BIP CRM重磅发布!
Bi Shi - University Logistics Management System Based on SSM
XML external entity (xxE) vulnerability and its repair method
【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
Excel VBA finds out the maximum and minimum values of a column of time, and repeatedly pastes multiple values according to the actual situation
使用灰度滤镜
常用泰勒展开
[GNN report] Tang Jian, Montreal, Canada: Geometric deep learning for drug discovery