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-seo的头像K-seoSEO优化员
Previous 2023-12-18 19:46
Next 2023-12-18 19:48

相关推荐

  • linux键盘输入无反应如何解决

    在Linux系统中,键盘输入无反应可能有多种原因,包括硬件故障、驱动问题、系统设置问题等,本文将从这些方面进行探讨,帮助您解决键盘输入无反应的问题,1、检查键盘线缆是否插好,确保键盘线缆与主机的USB端口紧密连接,没有松动或损坏,2、更换键盘线缆,如果键盘线缆有问题,可以尝试更换一根新的线缆,看是否能解决问题,3、使用其他USB接口,如果您有多个USB接口,可以尝试将键盘连接到其他接口上,看是

    2023-12-10
    0170
  • 修改服务器时间

    修改服务器时间是网络管理中的一个重要操作,它对于确保系统正常运行和数据同步具有重要意义,本文将详细介绍如何修改服务器时间,以及在操作过程中可能遇到的问题及解决方法。我们需要了解为什么需要修改服务器时间,服务器时间是指服务器上的时间设置,它对于许多应用程序和系统功能至关重要,一些应用程序会依赖于服务器时间来处理任务、生成报告或执行其他操……

    2023-12-04
    0145
  • linux查看redis

    在Linux系统中,查看Redis的方法有很多,这里主要介绍两种常用的方法:通过命令行和通过图形化界面。1. 通过命令行查看Redis在Linux系统中,我们可以通过命令行来查看Redis的运行状态、连接情况等信息,我们需要打开终端,然后输入以下命令:redis-cli这个命令会启动一个Redis客户端,我们可以在这个客户端中输入各种……

    2023-12-05
    0398
  • 虚拟主机如何给分区

    答:分区不会影响虚拟主机的访问速度,因为操作系统会根据虚拟主机的需求动态调整资源分配,使得各个虚拟主机之间的资源利用率保持在一个较低水平,但如果分区不当,导致某个虚拟主机独占过多资源,可能会影响其访问速度,在进行分区时,需要充分考虑各个虚拟主机之间的资源平衡。

    2023-12-27
    0125
  • centos7 删除服务

    删除MySQL服务前的准备工作在删除MySQL服务之前,请确保您已经备份了所有重要的数据,因为删除服务会导致数据丢失,还需要确保没有其他用户正在使用MySQL服务,如果您不确定,可以先停止MySQL服务,然后再进行删除操作。删除MySQL服务的步骤1、停止MySQL服务在删除MySQL服务之前,需要先停止正在运行的MySQL服务,可以……

    2024-01-11
    0227
  • host防封怎么改ip

    在网络通信中,IP地址是用来唯一标识网络上设备的地址,有些网络服务提供商(如某些国家的防火墙)可能会对某些IP地址进行封锁,以防止恶意活动或者违反其服务条款的行为,对于这种情况,我们可以通过更改IP地址来规避封锁,本文将详细介绍如何更改IP地址以防止被host防封。什么是host防封?Host防封是指网络服务提供商为了防止恶意用户或者……

    2024-01-30
    0135

发表回复

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

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