安装libpcap和libnet是安装libnids的前提。
libnids的安装的安装
因为libnids必须支持库libpcap和libnet,所以在安装libnids之前需要先安装libpcap和libnet。 在linux下安装libnids的步骤:
(1) 安装libpcap开发包:我们安装的版本是libpcap-0.8.3.tar.gz.
tar –xzvf libpcap-0.8.3.tar.gz 注:此处可直接把文件拖到xzvf之后以防路径问题
./configure 注:要进入解压后的libpcap路径
make 注:前面的configure出错,这里的make也不能正常运行
make install 注:可能需要在前面加sudo
(2) 安装libnet开发包:我们安装的版本是libnet-1.1.2.1.tar.gz.
tar –xzvf libnet-1.1.2.1.tar.gz
./configure
make
make install
(3) 安装libnids开发包:我们安装的版本是libnids-1.20.tar.gz.
tar –xzvf libnids.1.20.tar.gz
make install
上述安装可能出现的问题:
安装libpcap出现:
1:error: your operating system's lex is insufficient to compile libpcap. ex is a lex replacement that has many advantages, including being able to compile libpcap.
需要更新lex ,执行命令:sudo apt-get install flex
2:出现错误
yacc -d grammar.y
make: yacc:命令未找到
make: *** [grammar.c] 错误 127
需要安装yacc
inux下是用flex和bison来分别代替lex和yacc的,安装直接使用命令:
sudo apt-get install bison
*************************************
安装libnet:
1:error: c++ preprocessor "/lib/cpp" fails sanity check
安装 g++ 编译器 (一款linux、unix等操作系统下的c++编译器
使用命令:sudo apt-get install g++
可能出现libnet的版本不符合要求
***************************************
安装libnids:
1:checking for glib... configure: error: package requirements (glib-2.0 >= 2.2.0) were not met.
直接安装命令:sudo apt-get install "libglib2.0-dev"
注:若有其他一些小问题,估计也可以再命令前加sudo解决了。
libnids安装成功后可以用libnids中的函数来编写用于各种服务的程序。