Centos下安装libpcap
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
libpcap是一个网络数据包捕获函数库,功能非常强大,Linux下著名的tcpdump就是以它为基础的。我们可以利用它来完成自己的sniffer。
1.安装
下载最新版本的libpcap,下载地址:点击打开链接
解压缩libpcap-1.5.3.tar.gz
./configure
make
sudo make install
2.测试
写一个简单的例子测试一下安装是否成功,代码如下:
#include <pcap.h>
#include <stdio.h>
int main()
{
char errBuf[PCAP_ERRBUF_SIZE], * device;
device = pcap_lookupdev(errBuf);
if(device)
{
printf("success: device: %s\n", device);
}
else
{
printf("error: %s\n", errBuf);
}
return 0;
}
~
这里需要注意的是,编译时候需要添加-lpcap项,不然编译会出现如下错误:
(.text+0x14): undefined reference to `pcap_lookupdev'
collect2: ld 返回 1
正确的编译命令如下:
gcc test.c -o test -lpcap
编译通过后,执行此程序,会显示出当前网卡,




A beautiful web dashboard for Linux
最近提交(Master分支:5 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
所有评论(0)