工具介绍
ethtool 是一个用于查询和更改以太网适配器的配置工具。它通常用于诊断网络连接问题,查看网络适配器的当前设置,并在需要时更改这些设置
一、配置交叉工具环境
1、NDK包
官网自行下载linux版ndk解压到Linux服务器上
下面是我使用的r23c链接
平台 | 下载路径 |
---|---|
Windows 64-bit | android-ndk-r23c-windows.zip |
Mac OS X 64-bit | android-ndk-r23c-darwin.dmg |
Linux 64-bit | android-ndk-r23c-linux.zip |
2、配置环境变量
修改配置文件,在配置文件的最后一行加入路径配置:
vim /etc/bash.bashrc
PATH=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin:"${PATH}"
3、环境变量生效与测试
source /etc/bash.bashrc
aarch64-linux-android28-clang -v
二、交叉编译ethtool源码
1、获取源码
git clone git://git.kernel.org/pub/scm/network/ethtool/ethtool.git
2、执行脚本生成配置文件:
./autogen.sh
报错:
解决:
automake工具未安装
sudo apt-get install automake
3、configure配置
./configure --host=arm-linux CC=aarch64-linux-android28-clang LDFLAGS=-static
问题:
解决:
sudo apt-get install pkg-config libmnl-dev
4、make编译
问题:
解决:
libmnl库的交叉编译
1.源码 下载
2.配置
./configure --host=arm-linux CC=aarch64-linux-android28-clang LDFLAGS=-static --prefix=/root/ethtool/libmnl
3.make
make
make install
增加libmnl的头文件和lib库的路径参数继续编译
make CFLAGS="-I/root/ethtool/libmnl/include" LDFLAGS="-L/root/ethtool/libmnl/lib
三、ethtool命令详解
以下是一些常见的 ethtool 命令及其用法:
1.显示网络适配器的基本信息:
ethtool eth0
2.显示支持的功能和设置:
ethtool -i eth0
3.启用或禁用自动协商:
ethtool -s eth0 autoneg on
ethtool -s eth0 autoneg off
4.更改速度和双工模式:
ethtool -s eth0 speed 1000 duplex full
5.显示已启用的功能:
ethtool -k eth0
6.显示接口统计信息:
ethtool -S eth0
7.显示ethtool的命令帮助(help):
ethtool –h
8.关闭 eth0 的 Energy Efficient Ethernet (EEE) 功能:
ethtool --set-eee eth0 eee off
9.显示 eth0 当前的 EEE 配置,如果该接口支持 EEE:
ethtool --show-eee eth0