为什么80%的码农都做不了架构师?>>>   

tcpdump

1.What is tcpdump?

Tcpdump prints out a description ofthe contents of packets on a network interface that match the boolean expression.It can also be run with the -w(write) flag,which causes it to save the packet data to a file for later analysis,and/or with the -r(read) flag,which causes it to read from a saved packet file rather than to read packets from a network interface.In all cases,only packets that match the book expression will be processed by tcpdump.

Tcpdump will,if not run with the -c(count) flag,continue capturing packets until it is interrupted by a SIGINIT signal(generated,for example,by typing your interrupt character,typically control-C) or a SIGTERM signal(typically generated with the kill command);if run with the -c flag,it will capture packets until it is interrupted by a SIGINT or SIGTERM signal or the specified number of packets have been processed.

When tcpdump finishes  capturing packets,it will report counts of:

  • packets 'captured'(this is the number of packets that tcpdump has received and processed);
  • packets 'receieved by filter'(the meaning of this depends on the OS on which you're running tcpdump,and possibly on the way the OS was configured - if a filter was specified on the command line,on some OSes it counts packets regardless of whether they matched by the filter expression,regradless of whether tcpdump has read and processed them yet,on toher 0Ses it counts only packets that were matched by the filter expression regardless of whether tcpdump has read and processed them yet,and on other OSes it counts only packets that were matched by the filter expression and were processed by tcpdump);
  • packets 'dropped by kernel'(this is the number of packets that were dropped,due to a lack of buffer space,by the packet capture mechanism in the OS on which tcpdump is running,if the OS reports that information to applications;if not,it will be reported as 0).

Reading packets from a network interface may require that you have special privileges.Reading a saved packet file doesn't require special privileges.

2.Capture packets from a particular network interface using -i option

When you execute tcpdump command without any option,it will capture all the packets flowing throught all the interfaces.-i option with tcpdump command,allows you to filter on a particular network interface.

In this example,tcpdump captured all the packets flows in the interface lo and displays in the standard output.

3.Capture only N number of packets using -c option

When you execute tcpdump command it gives packets until you cancel the tcpdump command.Using -c option you can specify the number of packets to capture.

The above tcpdump command captured only 2 packets from interface lo.

4.Display captured packets in ASCII using -A option

The following tcpdump syntax prints the packet in ASCII.

5.Display captured packets in HEX and ASCII using -XX option

Some users might want to analyse the packets in hex values.Tcpdump provides a way to print packets in both ASCII and HEX format.

6.Capture the packets and write into a file using -w option

Tcpdump allows you to save the packets to a file,and later you can use the packet file for further analysis.

-w option writes the packets into a given file.The file extension should be .pcap,which can be read by any network protocol analyzer.

7.Reading the packets from a saved file using -r option

You can read the captured pcap file and view the packets for anaysis,as shown below.

8.Capture packets with IP address using -n option

In all the above examples,it prints packets with the DNS address,but not the ip address.The following example captures the packets and it will display the IP address of the machines involved.

9.Capture packets with proper readable timestamp using -tttt option

10.Read packets longer than N bytes

You can receive only the packets greater than n number of bytes using a filter 'greater' throught tcpdump command

tcpdump -i lo greater 1024

转载于:https://my.oschina.net/huihu/blog/186935

How to use tcpdump with examples相关推荐

  1. 事到如今已经不敢问的tcpdump的使用方法

    1 构成 master: SZE-L0149625 node1: SZE-L0149628 在 node1 上启动 httpd. 在 master 上通过 curl 执行请求. master ---- ...

  2. TCPDUMP中文手册

    名称(NAME) tcpdump-转储网络上的数据流 总览(SYNOPSIS) tcpdump[-adeflnNOpqStvx][-ccount][-Ffile] [-iinterface][-rfi ...

  3. tcpdump 用法

    原文链接 本文原文来自: A tcpdump Tutorial with Examples - 50 Ways to Isolate Traffic TCPDUMP 简介 TCPDUMP 在一个界面中 ...

  4. tcpdump 命令祥解

    NAME        tcpdump - 转储网络上的数据流 总览 (SYNOPSIS)        tcpdump [ -adeflnNOpqStvx ] [ -c count ] [ -F f ...

  5. perf Examples

    为什么80%的码农都做不了架构师?>>>    These are some examples of using the perf Linux profiler, which has ...

  6. tcpdump man 手册页的详细中文翻译

    出处:http://sanyk.is-programmer.com/posts/14645.html 原文地址 ========= 以下是本文档完整版本地址:http://sanyk.is-progr ...

  7. tcpdump常用命令

    按照2G一个报文存储网卡流量命令如下: tcpdump -i eth0 -s 0 tcp port 80 -w test.pcap -C 2000 合并数据包命令如下: mergecap.exe -a ...

  8. tcpdump教程_Tcpdump教程示例

    tcpdump教程 Tcpdump is a packet sniffer for everyday use. There is a lot of packet sniffers but tcpdum ...

  9. tcpdump 详细使用指南(请尽情食用)

    参考 Tcpdump 示例教程 超级棒! Tcpdump Examples [译]tcpdump 示例教程 Linux 网络命令必知必会之 tcpdump,一份完整的抓包指南请查收! Linux tc ...

最新文章

  1. php种loop用法,PHP EvLoop 用法 手册 | 示例代码
  2. Android --- allowBackup 属性的含义和危险性实例讲解
  3. 5、Power Map—实例:填充地图
  4. cornerstone的简单使用
  5. Razor传值到js
  6. 大学计算机专业全英文论文,计算机专业大学生英文简历模板
  7. 做项目,如何选单片机?
  8. ocupload完成文件上传(一键上传)
  9. 【Elasticsearch】es 7.8.0 java 实现 BulkRequest 批量写入数据
  10. Oracle提升查询性能之-简单范围分区表的创建
  11. python画曲线图-如何使用python画曲线图
  12. ViT (Vision Transformer) ---- RNN
  13. Ogre实现简单地形
  14. 拓端tecdat|R语言数量生态学冗余分析RDA分析植物多样性物种数据结果可视化
  15. VS2008(Visual Studio 2008)下载安装步骤
  16. 借鸡生蛋术–砍价小程序的推广变现教学
  17. php 上传图片返回预览,图片上传前的预览(PHP)
  18. CCNet: Criss-Cross Attention for Semantic Segmentation论文阅读
  19. matlab中进行拟合自定义形式的函数
  20. mysql存密码_存储用户ID和密码到mysql数据库的方法

热门文章

  1. 传奇世界RollBall设计
  2. 四大中三家已面向客户推出机器人业务解决方案?别逗了,先用机器人自我革命吧! post by 上海嘉冰信息技术...
  3. 思杰“个人云”翻开企业人本管理新篇章
  4. 转载:DIV+CSS有可能遇到的问题
  5. 编程题:两个数比较大小,之后用变量t互换。
  6. ubuntu中文wiki
  7. 咨询公司建议完美批准私有化
  8. log file sycn 概述
  9. JqueryQrcode生成二维码不支持中文的解决办法
  10. linux根分区扩容(LVM动态卷)