本文针对PCIE relatek 2.5G Ethernet LINUX driver r8125 for kernel up to 5.6
一、用安卓手机共享网络(以OPPO智能机系统为例)
1.用数据线连接手机
2.打开 设置
-> 连接与共享
-> USB共享网络
二、在ubuntu主机上查找新网络接口
通过命令查看当前网卡设备
sudo lshw -C network
此时可以看到两个设备
*-network DISABLED
description: Ethernet interface
product: RTL8125 2.5GbE Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:01:00.0
logical name: enp1s0
version: 04
serial: d8:bb:c1:17:ba:67
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8125 driverversion=9.008.00-NAPI duplex=full ip=179.160.6.111 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:19 ioport:3000(size=256) memory:a2200000-a220ffff memory:a2210000-a2213fff
*-network DISABLED
description: Ethernet interface
physical id: 2
bus info: usb@1:5
logical name: usb0
serial: 76:7e:24:83:87:cd
capabilities: ethernet physical
configuration: broadcast=yes driver=rndis_host driverversion=22-Aug-2005 firmware=RNDIS device link=no multicast=yes
为网络接口分配IP
dhclient usb0
ip address
可以看到已经有ip地址,并且ping www.baidu.com已经可以联网
三、下载驱动安装包
1.去 realtek官方驱动下载
下载得到驱动包 r8125-9.008.00.tar.bz2
搭建跟手机同一个网络的下载服务,以下为nginx搭建的本地网络下载服务配置
client_max_body_size 8192m;
proxy_max_temp_file_size 8192m;
location /software {
alias /allroot/download;
autoindex on; # 显示目录
autoindex_exact_size on;# 显示文件大小
autoindex_localtime on;# 显示文件时间
charset gbk,utf-8;
}
2.在ubuntu主机通过命令下载驱动包
sudo curl -o drive8125.tar.bz2 http://192.168.0.1/software/r8125-9.008.00.tar.bz2
3.解压重命名后的驱动包
tar -jxvf drive8125.tar.bz2
进入解压目录可以看到可执行文件
autorun.sh,Makefile README src
执行脚本
sudo sh autorun.sh
最后执行网络ip分配命令
dhclient enp1s0
再通过ifconfig或ip address命令,可以看到已经分配ip
四、配置自启动脚本
vi /etc/rc.local
写入
#!/bin/bash
dhclient
exit 0
执行命令
sudo chmod 755 /etc/rc.local && systemctl enable rc-local && systemctl restart rc-local
sudo systemctl status rc-local
查看网络状态
sudo systemctl status systemd-networkd
评论 (0)