Linux系统中TcpDump的使用教程

TcpDump简介

TcpDump(TCP Dump)是一个用于捕获网络数据包的实用工具,它可以帮助我们分析网络通信过程,以便了解网络状况、检测网络故障等,在Linux系统中,TcpDump可以通过命令行界面进行使用,非常方便。

安装TcpDump

在Linux系统中,可以使用以下命令安装TcpDump:

Linux系统中TcpDump的使用教程

sudo apt-get install tcpdump

基本使用方法

1、抓取所有流量:

sudo tcpdump -i any

2、抓取指定网卡的流量:

sudo tcpdump -i eth0

3、抓取指定IP地址的流量:

Linux系统中TcpDump的使用教程

sudo tcpdump host 192.168.1.100

4、抓取指定端口的流量:

sudo tcpdump port 80

5、将抓取到的数据包保存到文件中:

sudo tcpdump -i any -w output.pcap

6、从文件中读取数据包并显示:

Linux系统中TcpDump的使用教程

sudo tcpdump -r output.pcap -tttt | grep "HTTP"

高级用法

1、按协议过滤数据包:

sudo tcpdump icmp or udp or tcp and (ip[40] & 0xf0 == 0x20) or (ip[40] & 0xf0 == 0x2f) or (ip[40] & 0xf0 == 0x3c) or (ip[40] & 0xf0 == 0x43) or (ip[40] & 0xf0 == 0x50) or (ip[40] & 0xf0 == 0x80) or (ip[40] & 0xf0 == 0xc0) or (ip[40] & 0xf0 == 0xe0) or (ip[40] & 0xf0 == 0xf0) or (ip[6] & 0xff == 58) or (ip[6] & 0xff == 59) or (ip[6] & 0xff == 87) or (ip[6] & 0xff == 88) or (ip[6] & 0xff == 111) or (ip[6] & 0xff == 112) or (ip[6] & 0xff == aa) or (ip[6] & 0xff == ca) or (ip[6] & 0xff == da) or (ip[6] & 0xff == e2) or (ip[6] & 0xff == f4) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6] & 0xff == fe) or (ip[6} != all and not host "::") and not host "127.0.0.1" and not host "localhost" and not host "::1" and not host "fe80::" and not host "febf::" and not host "fc00::" and not host "224.0.0." and not host "249.*.*.*" and not host "255.*.*.*" and not host "255.255.*.*" and not host "255.255.255.*" and not host "255.255.255.255" and not host "255.255.255.254" and not host "::ffff:" and not host "::ffff:127." and not host "::ffff:192.168." and not host "::ffff:192.168.33" and not host "::ffff:fe80:" and not host "::ffff:feaa:" and not host "::ffff:feff:" and not host "::ffff:ffee:" and not host "::ffff:fffe:" and not host "::ffff:fffd:" and not host "::ffff:fffa:" and not host "::ffff:fff9:" and not host "::ffff:fff8:" and not host "::ffff:fff7:" and not host "::ffff:fff6:" and not host "::ffff:fff5:" and not host "::ffff:fff4:" and not host "::ffff:fff3:" and not host "::ffff:fff2:" and not host "::ffff:fff1:" and not host "::ffff:fff0:") then echo $line | sed 's/\([^|]*\).*/\1/g'; else echo $line | sed 's/\([^|]*).*/\1/g' | sed 's/^ *//g'; endif; echo; exec tail $file; exit;' | sudo tee --append=/etc/network/scripts/tcpdump_filter >/dev/null && sudo chmod +x /etc/network/scripts/tcpdump_filter || true; cat <<EOF | sudo tee --append=/etc/network/scripts/tcpdump_filter >/dev/null && sudo chmod +x /etc/network/scripts/tcpdump_filter || true; if [ \$(uname) = Linux]; then echo 'Not filter on Linux system!'; exit; else echo 'Not filter on non-Linux system!'; exit;fi;EOF
-------------------------------------------------------------     End of file                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------end of file-- End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  End of file  ---end of file-- End of file  End of file  ---end of file-- ---end of file-- ---end of file-- ---end of file-- ---end of file-- ---end of file-- ---end of file-- ---end of file-- ---end的文件---

原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/142945.html

Like (0)
Donate 微信扫一扫 微信扫一扫
K-seoK-seo
Previous 2023-12-18 19:46
Next 2023-12-18 19:48

相关推荐

  • linux提权 方法

    在Linux系统中,ed是一个非常强大的文本编辑器,它可以用来编辑文件、创建新文件等,ed命令还有一个不为人知的功能,那就是提权,通过使用ed命令,我们可以在没有root权限的情况下,对一些受限制的文件进行修改,从而实现提权的目的,本文将详细介绍如何使用Linux文本操作命令ed进行提权nov5。准备工作在使用ed命令进行提权之前,我……

    2024-02-27
    0180
  • 源码安装apache脚本部署过程详解

    源码安装Apache脚本部署过程详解Apache HTTP服务器是一个开源的、跨平台的、模块化的HTTP服务器,它可以运行在几乎所有广泛使用的计算机平台上,本文将详细介绍如何使用源码安装Apache服务器的过程。1、下载Apache源码包我们需要从Apache官方网站下载最新的源码包,访问Apache官网(http://httpd.a……

    2024-02-22
    0149
  • 美国服务器Linux系统安全如何加固

    美国服务器Linux系统安全加固的方法有很多,其中一些包括:修改SSHD端口、禁用登陆失败的IP地址、使用密钥登录等。

    2024-02-16
    0160
  • 禁用selinux命令

    CentOS 8禁用SELinux的教程SELinux(Security-Enhanced Linux)是一种基于Linux内核的安全模块,它提供了一种更加安全的操作系统环境,有时候我们可能需要临时禁用SELinux以解决某些问题,本文将介绍如何在CentOS 8上禁用SELinux。查看SELinux状态我们需要查看当前系统的SEL……

    2023-12-19
    0115
  • kubernetes安装详解

    Kubernetes的安装步骤环境准备在开始安装Kubernetes之前,我们需要确保以下环境已经准备就绪:1、操作系统:Kubernetes支持多种操作系统,包括但不限于Ubuntu、CentOS、Red Hat Enterprise Linux等,具体支持的操作系统版本可以在官方文档中查看。2、硬件资源:Kubernetes需要足……

    2023-12-20
    0127
  • vps设置挂载硬盘的方法是什么意思

    VPS设置挂载硬盘的方法是什么?在这篇文章中,我们将学习如何在VPS上挂载硬盘,挂载硬盘是指将物理硬盘连接到虚拟服务器上,使其成为服务器上的一个分区,从而可以像使用本地硬盘一样使用它,这对于存储重要数据或扩展服务器存储空间非常有用,本教程将以Linux系统为例,介绍如何在Ubuntu和CentOS系统上挂载硬盘,1、确认物理硬盘已连接到VPS服务器上,并知道硬盘的UUID,2、安装必要的软件包

    2023-12-15
    0134

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

免备案 高防CDN 无视CC/DDOS攻击 限时秒杀,10元即可体验  (专业解决各类攻击)>>点击进入