tcpdump 命令详解

 

TCPdump: dump  traffic on a network ,根据使用者的定义对网络上的数据包进行截获的一种包分析工具。 TCPdump 可以讲网络中传送的数据包的 头信息完全截获下来提供分析, 它支持针对网络层,协议,主机,网络或端口的过滤, 并提供and,or ,not 等逻辑语句来帮助去掉无用的信息。
Tcpdump  prints  out  the headers of packets on a network interface that match the boolean expression.  It can also be run with the  -w flag,  which  causes it to save the packet data to a file for later analysis, and/or with the -r flag, which causes it to read  from  a saved packet file rather than to read packets from a network inter-face.  In all cases, only packets that  match  expression  will  be processed by tcpdump.

 

选项:

 

-i : 指定监听的网络接口, 不加-i 选项表示抓取所有的接口包括lo 
-v: 输出详细信息
-nn: 显示格式为IP+Port ,默认为主机名+服务名
-c: 抓取包的数量, 到达该数量后则停止抓取
-T:将监听到的包直接解释为指定类型的报文, rpc(远程过程调用)  snmp (简单网络管理协议) 

实例:

//打印所有进入或离开sundown 的数据包
tcpdump host sundown
//指定ip ,拦截所有指定ip的主机收到和发出的所有的数据包
tcpdump host 210.27.48.1
//打印helios 与hot 或者ace 之间通信的数据包
tcpdump host helios and \(hot or ace\)
 //截获主机hostname 发送的所有数据
tcpdump -i eth0 src host hostname
//件事所有送到主机hostname 的数据包
tcpdump -i eth0 dst host hostname
//对本机的udp 123 端口进行监视
tcpdump udp port 123
//打印所有通过网关snup 的ftp 数据包, ‘’防止shell 对括号进行错误解析
tcpdump 'gateway snup and (port ftp or ftp-data)'
//打印所有原地址或目标地址是本地主机的ip 数据包
tcpdump ip and not net localnet   如果本地网络通过网关连到另一网络, 则另一网络并不能算做本地网络

 

posted on   linuxSu  阅读(430)  评论(0编辑  收藏  举报

编辑推荐:
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
阅读排行:
· Windows桌面应用自动更新解决方案SharpUpdater5发布
· 我的家庭实验室服务器集群硬件清单
· C# 13 中的新增功能实操
· Supergateway:MCP服务器的远程调试与集成工具
· Vue3封装支持Base64导出的电子签名组件
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示