linux离线安装tcpdump

安装步骤:
(1) tcpdump需要依赖包libcap,所以需要先安装lipcap,然后安装tcpdump
(2) lipcap需要依赖包flex和bison,所以需要先安装flex和bison
(3) flex、bison、libcap、tcpdump百度网盘安装包可以访问链接: https://pan.baidu.com/s/17Kx56e_B87OnOSQz598D5w
提取码:jsw8
如果想下载最新版本tar.gz格式的libcap、tcpdump,可以访问链接: https://www.tcpdump.org/release/
如果想下载不同操作系统的rpm格式的 flex、bison、libcap、tcpdump,可以访问链接: https://pkgs.org/download/libpcap
在这里插入图片描述

1.安装依赖包flex和bison

安装包:

tar -zxvf flex.tar.gz
cd flex/
./configure --prefix=/usr
make && sudo make install
tar -zxvf bison.tar.gz
cd bison/
./configure --prefix=/usr
make && sudo make install

安装bison:make编辑报错./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)

解决办法:

 vi lib/stdio.in.h

 查找字段:gets is a security hole,将_GL_WARN_ON_USE (gets, “gets is a security hole - use fgets instead”); 字段和他之前的注释 /* 一块注释掉,如下
 /* It is very rare that the developer ever has full control of stdin,
   so any use of gets warrants an unconditional warning.  Assume it is
   always declared, since it is required by C89.
 #undef gets
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); */ 
 
 再添加如下内容:
 #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 #endif

安装bison:make编辑报错lib/fseterr.c:77:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib

解决办法:

cd /opt/p2/openwrt/build_dir/host/bison-3.0.4/
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h

2.安装lipcap

tar -zxvf  libpcap-1.5.3.tar.gz  
cd  libpcap-1.5.3  
./configure  
sudo make install  

3.安装tcpdump

tar -zxvf tcpdump-4.5.1.tar.gz  
cd tcpdump-4.5.1  
./configure  
sudo make install

4.校验安装成功

抓取所有经过eno33559296网卡的网络数据,并写入指定文件
tcpdump -i eno33559296 -w /tmp/wangjing.pcap文章来源地址https://uudwc.com/A/3aEb

原文地址:https://blog.csdn.net/qq_43522910/article/details/126783524

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

h
上一篇 2023年06月15日 00:59
【Linux】缓冲区/磁盘inode/动静态库制作
下一篇 2023年06月15日 00:59