tcpdump dump 网络流量
tcpdump dump 网络流量
描述: Tcpdump 打印一个包的内容的描述在一个网络接口 匹配布尔值表达式
它也可以运行使用-w flag, 这样会保存包的数据到一个文件用于后面分析,
使用-r flag 可以从保存的packet 文件而不是从网络接口读取
在所有的例子,只有packets 匹配表达式才会被tcpdump处理
Tcpdump 如果不带-c 运行, 会继续捕获数据包知道被信号打断(通常,例如,输入典型的 control-C)
或者 一个SIGTERM signal (kill 命令)
如果你运行-c选项,它会捕获包直到 被SIGINT or SIGTERM signal 或者指定的数量的包后
当tcpdump 完成捕获数据包后,它会报告:
1.packets "捕获的" ( 这是包的数量tcpdump 已经接受和处理的)
2.packets "过滤器接收的"(这个取决于操作系统 ,如果一个filter 是在命令行指定,
在一些OSes上 它统计包不管 他们是否被过滤器表达式,即使它们被表达式过滤器匹配,
不管 tcpdump 已经读或者处理他们,在其他系统上它只统计 表达式匹配的包
3. packets "dropped by kernel" (这个是被丢弃的包,由于缺少buffer space,如果OS 报告信息给应用 如果没有,它是报告为0)
tcpdump -i eth0 -nn -vv port 53
tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings |
-i 侦听接口,如果没有指定,tcpdump 搜索系统接口列表
-nn 不要转换协议和端口号
-s Snarf snaplen bytes of data from each packet rather than the default of 65535 bytes. Packets truncated because of a
limited snapshot are indicated in the output with ‘‘[|proto]’’, where proto is the name of the protocol level at which
the truncation has occurred. Note that taking larger snapshots both increases the amount of time it takes to process
packets and, effectively, decreases the amount of packet buffering. This may cause packets to be lost. You should
limit snaplen to the smallest number that will capture the protocol information you’re interested in. Setting snaplen
to 0 sets it to the default of 65535, for backwards compatibility with recent older versions of tcpdump.
抽取 数据的快照长度字节 从每个包而不是默认的65535字节。
包被截断因为一个受限的快照是致命在输出 使用 ‘‘[|proto]’’,
proto 是协议的名字
注意大的快照会增加处理包的总的时间,效率,降低包缓存的总量
这个也会导致包丢失,你需要限制快照长度到小的值
设置snaplen 为0 是默认值
Setting snaplen
to 0 sets it to the default of 65535
-l Make stdout line buffered. Useful if you want to see the data while capturing it. E.g.,
‘‘tcpdump -l | tee dat’’ or ‘‘tcpdump -l > dat & tail -f dat’’.
让标准输出 buffered,有用的如果你需要看数据当捕捉时
-w Write the raw packets to file rather than parsing and printing them out. They can later be printed with the -r
option. Standard output is used if file is ‘‘-’’. See pcap-savefile(5) for a description of the file format.
写raw 数据包到文件 而不是解析和打印它们。
它们可以随后被打印使用-r选项,标准输出被使用,如果file 是"-"
-r Read packets from file (which was created with the -w option). Standard input is used if file is ‘‘-’’.
从文件读取包(使用-w选项创建) 标准输入是使用file "-"
抓取所有经过 eth1,目的或源端口是 25 的网络数据
# tcpdump -i eth1 port 25
- 源端口
# tcpdump -i eth1 src port 25
- 目的端口
# tcpdump -i eth1 dst port 25网络过滤
strings 提取2进制数据
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings
- 抓取所有经过 eth1,目的或源端口是 25 的网络数据
# tcpdump -i eth1 port 25
- 源端口
# tcpdump -i eth1 src port 25
- 目的端口
# tcpdump -i eth1 dst port 25网络过滤
这个前提是必须走网卡
#!/bin/bash
#this script used montor mysql network traffic.echo sql
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i)
{
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
}'
tcpdump dump 网络流量的更多相关文章
- alluxio网络流量异常分析【转】
1. 介绍 2. 准备工作 2.1 tcpdump 2.2 winshark 2.3 安装iftop 2.4 alluxio网络通信相关的端口 3.iftop 锁定消耗流量最大的端口 4. dump数 ...
- 【读书笔记】iOS网络-测试与操纵网络流量
一,观测网络流量. 观测网络流量的行为叫做嗅探或数据包分析. 1,嗅探硬件. 从iOS模拟器捕获数据包不需要做特别的硬件或网络配置.如果需要捕获这些数据包,那么可以使用嗅探软件来监听回送设备或是用于连 ...
- 运用Ntop监控网络流量(视频Demo)
运用Ntop监控网络流量 ____网络流量反映了网络的运行状态,是判别网络运行是否正常的关键数据,在实际的网络中,如果对网络流量控制得不好或发生网络拥塞,将会导致网络吞吐量下降.网络性能降低.通过流量 ...
- Ntop监控网络流量
运用Ntop监控网络流量 ____ 网络流量反映了网络的运行状态,是判别网络运行是否正常的关键数据,在实际的网络中,如果对网络流量控制得不好或发生网络拥塞,将会导致网络吞吐量下降. 网络性能降低.通过 ...
- 【读书笔记】iOS-网络-测试与操纵网络流量
一,观测网络流量. 观测网络流量的行为叫做嗅探或数据包分析. 1,嗅探硬件. 从iOS模拟器捕获数据包不需要做特别的硬件或网络配置.如果需要捕获这些数据包,那么可以使用嗅探软件来监听回送设备或是用于连 ...
- TCPflow:在Linux中分析和调试网络流量的利器(转)
TCPflow是一款功能强大的.基于命令行的免费开源工具,用于在Unix之类的系统(如Linux)上分析网络流量.它可捕获通过TCP连接接收或传输的数据,并存储在文件中供以后分析,采用的格式便于协议分 ...
- NetFlow是一种数据交换方式,提供网络流量的会话级视图,记录下每个TCP/IP事务的信息
NetFlow是一种数据交换方式,提供网络流量的会话级视图,记录下每个TCP/IP事务的信息.也许它不能象tcpdump那样提供网络流量的完整记录,但是当汇集起来时,它更加易于管理和易读.Netflo ...
- Linux服务器上监控网络带宽的18个常用命令nload, iftop,iptraf-ng, nethogs, vnstat. nagios,运用Ntop监控网络流量
Linux服务器上监控网络带宽的18个常用命令 本文介绍了一些可以用来监控网络使用情况的Linux命令行工具.这些工具可以监控通过网络接口传输的数据,并测量目前哪些数据所传输的速度.入站流量和出站流量 ...
- windows下使用C#获取特定进程网络流量
最近老板接了一个中船重工的项目,需要做一个有关海军软件系统的组件评估项目,项目中有一个子项目需要获取特定进程的各种系统参数,项目使用.NET平台.在获取特定进程各种系统参数时,其它诸如进程ID,进程名 ...
随机推荐
- yield关键字的用法
在上一篇文章中,说了下foreach的用法,但是还是比较复杂的,要实现接口才能进行遍历,有没有简单些的方法呢?答案是肯定的.且看下面. yield关键字的用法: 1.为当前类型添加一个任意方法,但是要 ...
- C# 高精度求幂 poj1001
高精度求幂 public static char[] exponentiation(string a,int r) { ]; string b = ""; string c = a ...
- 18_高级映射:一对一查询(使用resultMap)
[简述] 数据库模型和数据等信息与上一篇博文相同. 需求也同上一篇博文. [工程截图] [User.java]POJO package cn.higgin.mybatis.po; import jav ...
- 快速开启Windows 的各种任务及 bat(ch)脚本
MSC It is the Microsoft Management Console Snap-in Control File, like services.msc, devmgmt.msc (Dev ...
- IP address/地址 检查
1.Determine if a string is a valid IP address in C Beej's Guide to Network Programming 2.9.14. inet_ ...
- [翻译][MVC 5 + EF 6] 8:更新相关数据
原文:Updating Related Data with the Entity Framework in an ASP.NET MVC Application 1.定制Course的Create和E ...
- PHP - 5.4 Array dereferencing 数组值
在5.4之前我们直接获取数组的值得方法如下 <?php $str = 'a;b;c;d'; list($value) = explode(';',$str); echo $value; 结果为: ...
- sharepoint 2013 suitbar
参考链接:http://academy.bindtuning.com/customize-sharepoint-2013-and-office-365-suite-bar/
- php 加密解密方法2
<?php /* * @param $string 要加密或解决的字符串 * @param $operation 加密/解密 ENCODE加密, DECODE 解密 * @param $key ...
- 关闭一个winform窗体刷新另外一个
例如Form1是你的主窗体,然后Form2是你的要关闭那个窗体,在Form1中SHOW FORM2的窗体那里加上一句f2.FormClosed += new FormClosedEventHandle ...