Tcpdump源碼官網
http://www.tcpdump.org
安裝步驟
- 下載tcpdump、libpcap
libpcap-1.8.1.tar.gz
tcpdump-4.9.0.tar.gz
安裝libpcap
- 解壓縮
tar -vxzf libpcap-1.8.1.tar.gz
注:小技巧:Linux下一般壓縮文件後綴爲.tar.bz2和.tar.gz,
它們解壓命令有兩三個選項是一致的:
xf(v),前者再加上j選項,後者再加上z選項。
- 進入目錄
cd libpcap-1.8.1/
- 配置
3536: CC=arm-hisiv400-linux-gcc ./configure --host=arm-hisiv400-linux --target=arm-hisiv400-linux --program-prefix=arm-hisiv400-linux- --with-pcap=linux --prefix=$(pwd)/../output/3536
3519: CC=arm-hisiv600-linux-gcc ./configure --host=arm-hisiv600-linux --target=arm-hisiv600-linux --program-prefix=arm-hisiv600-linux- --with-pcap=linux --prefix=$(pwd)/../output/3519a
3519av100: CC=arm-himix200-linux-gcc ./configure --host=arm-himix200-linux --target=arm-himix200-linux --program-prefix=arm-himix200-linux- --with-pcap=linux --prefix=$(pwd)/../output/3519av100
開發機: ./configure --with-pcap=linux --prefix=$(pwd)/../output/pc
編譯參數說明:
1) CC:編譯gdb使用的交叉編譯工具鏈,3536和3519的工具不一樣
2) --host:編譯出來的gdb運行在什麼機器上
3) --target:要調試的目標板
4) --program-prefix:編譯生成可執行文件的前綴
5) --prefix:make install的的位置
注:–target=arm-linux意思是說目標平臺是運行於ARM體系結構的linux內核;
–program-prefix=arm-linux-是指生成的可執行文件的前綴, 比如arm-linux-gdb,
–prefix是指生成的可執行文件安裝在哪個目錄,這個目錄需要根據實際情況作選擇。
如果該目錄不存在,會自動創建,當然,權限足夠的話。
- 編譯、安裝
make
make install
- 完成,繼續安裝tcpdump
安裝tcpdump
- 解壓縮
tar -vxf tcpdump-4.9.0.tar.gz
注:小技巧:Linux下一般壓縮文件後綴爲.tar.bz2和.tar.gz,
它們解壓命令有兩三個選項是一致的:
xf(v),前者再加上j選項,後者再加上z選項。
- 進入目錄
cd tcpdump-4.9.0/
- 配置
3536: CC=arm-hisiv400-linux-gcc ./configure --host=arm-hisiv400-linux --target=arm-hisiv400-linux --program-prefix=arm-hisiv400-linux- --prefix=$(pwd)/../output/3536
3519: CC=arm-hisiv600-linux-gcc ./configure --host=arm-hisiv600-linux --target=arm-hisiv600-linux --program-prefix=arm-hisiv600-linux- --prefix=$(pwd)/../output/3519a
3519av100: CC=arm-himix200-linux-gcc ./configure --host=arm-himix200-linux --target=arm-himix200-linux --program-prefix=arm-himix200-linux- --prefix=$(pwd)/../output/3519av100
開發機: ./configure --prefix=$(pwd)/../output/pc
編譯參數說明:
1) CC:編譯gdb使用的交叉編譯工具鏈,3536和3519的工具不一樣
2) --host:編譯出來的gdb運行在什麼機器上
3) --target:要調試的目標板
4) --program-prefix:編譯生成可執行文件的前綴
5) --prefix:make install的的位置
注:–target=arm-linux意思是說目標平臺是運行於ARM體系結構的linux內核;
–program-prefix=arm-linux-是指生成的可執行文件的前綴, 比如arm-linux-gdb,
–prefix是指生成的可執行文件安裝在哪個目錄,這個目錄需要根據實際情況作選擇。
如果該目錄不存在,會自動創建,當然,權限足夠的話。
- 編譯,安裝
make
make install
- 過程中間報錯:
configure: error: Report this to [email protected],
and include the config.log file in your report.
If you have downloaded libpcap from tcpdump.org, and built it yourself,
please also include the config.log file from the libpcap source directory,
the Makefile from the libpcap source directory,
and the output of the make process for libpcap,
as this could be a problem with the libpcap that was built,
and we will not be able to determine why this is happening,
and thus will not be able to fix it, without that information,
as we have not been able to reproduce this problem ourselves.
原因:/usr/bin/pcap-config 文件不對,需要替換(root權限才能操作)
解決:
su cp xxx/pcap-config /usr/bin
- 輸出:
ls ../output/xxx/sbin/tcpdump