当前位置: 首页 > news >正文

Ubuntu18.04安装RTL8125/RTL8168等网卡驱动程序

Ubuntu下的驱动程序在这里下载,

Realtek PCIe FE / GBE / 2.5G / Gaming Ethernet Family Controller Software - REALTEK
其中第一个是用得最多的,很多通用笔记本用的R8125(Realtek8125),其中包括R8162等硬件也是用的这个驱动。

R8168貌似没那么常见。下面的过程适合Realtek相应的任何一款驱动,亲测在Ubuntu18.04上都可以成功安装。

当然,前提条件是你的电脑能上网。在网卡不通的情况下,我通常会通过手机共享网络或使用USB_WIFI的方式连网。安装完驱动之后,就可以直接使用网线连接了。

言归正传,首先下载安装 Openssl,

sudo apt-get update
sudo apt-get install gcc make

git clone --recursive https://github.com/openssl/openssl.git
cd openssl
./Configure
make
make test
sudo make install
sudo ldconfig /usr/local/lib64/

===================================

然后安装r8168的驱动,

user@UBUNTU:~/mc/r8168-8.049.02$ sudo ./autorun.sh
Check old driver and unload it.
Build the module and install
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
Warning: modules_install: missing 'System.map' file. Skipping depmod.
Backup r8169.ko
rename r8169.ko to r8169.bak
DEPMOD 5.4.0-96-generic
load module r8168
modprobe: ERROR: could not insert 'r8168': Operation not permitted
Updating initramfs. Please wait.
update-initramfs: Generating /boot/initrd.img-5.4.0-96-generic
I: The initramfs will attempt to resume from /dev/sda6
I: (UUID=3c85298d-8075-4360-8a78-bf16feba10f7)
I: Set the RESUME variable to override this.
Completed.

这里我们可以看到有一大堆的报错,我们一个一个来解决。

问题1:SSL证书上的问题

- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory

解决办法参考:https://github.com/andikleen/simple-pt/issues/8

cd /lib/modules/$(uname -r)/build/certs

sudo tee x509.genkey > /dev/null << 'EOF'
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = myexts
[ req_distinguished_name ]
CN = Modules
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
EOF

sudo openssl req -new -nodes -utf8 -sha512 -days 36500 -batch -x509 -config x509.genkey -outform DER -out signing_key.x509 -keyout signing_key.pem

不过这个过程中根据系统的具体情况,可能会碰到下面的报错:

user@UBUNTU:/lib/modules/5.4.0-96-generic/build/certs$ sudo openssl req -new -nodes -utf8 -sha512 -days 36500 -batch -x509 -config x509.genkey -outform DER -out signing_key.x509 -keyout signing_key.pem

openssl: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory

这个问题的主要原因是前面编译Openssl时没有ldconfig,参考这里:
https://stackoverflow.com/questions/54124906/openssl-error-while-loading-shared-libraries-libssl-so-3

所以添加下面这条命令即可,

user@UBUNTU:/lib/modules/5.4.0-96-generic/build/certs$ sudo ldconfig /usr/local/lib64/
user@UBUNTU:/lib/modules/5.4.0-96-generic/build/certs$ sudo openssl req -new -nodes -utf8 -sha512 -days 36500 -batch -x509 -config x509.genkey -outform DER -out signing_key.x509 -keyout signing_key.pem
....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+...+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+......+.....................+..+.+..+.......+.................+......+..........+.........+........+.+..+...+.+......+..+...+....+......+.................+..........+...+..+..........+..+...............+......+....+...+..+......+....+..................+..+....+......+.....+.+....................+....+...+..+....+..+...................+.....+...+.+..+..........+..+.+.........+.....+......+......+.............+..+.+.....+...+.+.....+....+.........+...+..+...+............+......+............+...+.+..............+.......+........+.+........+............................+..................+..+............+...+....+........+.+......+.........+..+...+.........+......+.+...+...+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...+............+...+.........+........+......+....+...+.....+...+.....................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+........+...+..........+.........+...........+.........+...+...+.......+.....+.+.................+....+...+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.....+....+.....+.......+......+........+....+..+...+............+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

问题2:System.map的问题

原来的问题是:

Warning: modules_install: missing 'System.map' file. Skipping depmod.

解决办法参考这里:
ref. https://www.linuxquestions.org/questions/ubuntu-63/system-map-no-such-file-or-directory-840336/

上面提到,

The Wikipedia article at http://en.wikipedia.org/wiki/System.map says that System.map is generated at build time of the kernel.

This says in part:
After building the Linux kernel, System.map is located in the root of the source directory. However, some further software installation steps expect to locate the file elsewhere:

* as /boot/System.map-$(uname -r)
* Building SVGALib expects to find /lib/modules/$(uname -r)/build/System.map
Do an "ls -l /boot/System.map*" and see if you have any files appended with the System.map. If so do a symbolic link of that to the location your make is looking for it in. e.g.
"ln -s /boot/System.map-2.6.32-25-generic /lib/modules/2.6.32-25-generic/build/System.map"

Also based on above it may be you need to install the kernel source package to be able to do your make. You don't mention what it is you're trying to make.

根据上面的提示,创建下面的链接即可让程序找到正确的map位置,

user@UBUNTU:~/mc/r8168-8.049.02$ ls -l /boot/System.map*
-rw------- 1 root root 4289273 7月  29  2019 /boot/System.map-5.0.0-23-generic
-rw------- 1 root root 4591534 1月  13 21:10 /boot/System.map-5.4.0-96-generic
user@UBUNTU:~/mc/r8168-8.049.02$ sudo ln -s /boot/System.map-5.4.0-96-generic /lib/modules/5.4.0-96-generic/build/System.map
user@UBUNTU:~/mc/r8168-8.049.02$ sudo ln -s /boot/System.map-5.0.0-23-generic /lib/modules/5.0.0-23-generic/build/System.map

问题3:modeprobe 没有权限的问题

modprobe: ERROR: could not insert 'r8168': Operation not permitted

这个问题的解决方案参考:
https://askubuntu.com/questions/1114867/operation-not-permitted-when-trying-to-modprobe-xpad

其中有一段是这么说的,

if you are facing this error modprobe: ERROR: could not insert 'rtl8723de': Operation not permitted

The solution is to disabled the Secure Boot. Firstly check if SecureBoot is enabled on Ubuntu.

Install mokutil "sudo apt-get install mokutil"

and check the status of SecureBoot "mokutil --sb-state"

In case it is enabled run command "sudo mokutil --disable-validation"

Now enter a temporary password between 8 to 16 digits. We will use this password later. Enter the same password again to confirm. Once it’s done reboot the system and press any key when you see the blue screen (MOK management). Select Change Secure Boot state. Enter the password you had selected before and press Enter. Select Yes to disable Secure Boot in shim-signed. Press Enter key to finish the whole procedure.

Predictably, it was some dumb Secure Boot thing. Once I signed the module with

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n xpad)

I could modprobe it without issues, and the controller works well.

The files MOK.priv and MOK.der are Secure Boot keys, which I'd previously created using this answer to get VirtualBox working.

user@UBUNTU:~/mc/r8168-8.049.02$ sudo apt-get install mokutil
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
mokutil 已经是最新版 (0.3.0+1538710437.fb6250f-0ubuntu2~18.04.1)。
下列软件包是自动安装的并且现在不需要了:
  gir1.2-geocodeglib-1.0 libegl1-mesa libfwup1 libllvm8 libwayland-egl1-mesa shim ubuntu-web-launchers
使用'sudo apt autoremove'来卸载它(它们)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
user@UBUNTU:~/mc/r8168-8.049.02$ mokutil --sb-state
SecureBoot enabled

user@UBUNTU:~/mc/r8168-8.049.02$ sudo mokutil --disable-validation
password length: 8~16
input password: (这里输入你的临时密码,例如:123456708)
input password again: (这里输入你的临时密码,例如:12345678)

===================================================

到这里,就可以正确安装驱动程序了,如果如下,

user@UBUNTU:~/mc/r8168-8.049.02$ sudo ./autorun.sh
Check old driver and unload it.
Build the module and install
DEPMOD 5.4.0-96-generic
load module r8168
Updating initramfs. Please wait.
update-initramfs: Generating /boot/initrd.img-5.4.0-96-generic
I: The initramfs will attempt to resume from /dev/sda6
I: (UUID=3c85298d-8075-4360-8a78-bf16feba10f7)
I: Set the RESUME variable to override this.
Completed.

本文结束

其他参考安装方法(Realtek系列网卡的驱动):

Ubuntu安装 Realtek R8125/R8168 驱动 - 知乎

Ubuntu18.04安装Realtek网卡驱动_MWbayern的博客-CSDN博客_ubuntu18.04安装网卡驱动

Ubuntu下安装RealtekRTL8125网卡驱动_hello-CSDN博客_rtl8125驱动

5.14 kernal with support for MediaTek MT7921 and RealTek 8162

networking - Wifi Driver with Dual Boot MediaTek - Ask Ubuntu

相关文章:

  • Ubuntu如何卸载cuda driver
  • Ubuntu20.04安装Cuda driver + toolkit + cudnn
  • ROS安装时:找不到有效的OpenPGP数据
  • ROS报错:-- Could NOT find PY_em (missing: PY_EM)
  • SLAM算法r3live试运行
  • VINS-MONO:integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
  • Ubuntu如何查看eigen版本
  • Ubuntu命令查看CPU信息
  • ROS报错: Unable to communicate with master
  • ROS报错:Roslaunch got a ‘No such file or directory‘ error while attempting to run xterm -e gdb --args
  • Ubuntu下的录屏工具Kazam和SimpleScreenRecorder, Peek
  • Ubuntu20.04+gdb/vscode调试ROS(VINS-Mono)程序
  • Windows 10上安装ROS noetic平台
  • Ubuntu查看环境变量
  • 四元素(四元数quaternion)的理解
  • JavaScript-如何实现克隆(clone)函数
  • [rust! #004] [译] Rust 的内置 Traits, 使用场景, 方式, 和原因
  • js ES6 求数组的交集,并集,还有差集
  • Js基础——数据类型之Null和Undefined
  • leetcode378. Kth Smallest Element in a Sorted Matrix
  • python 装饰器(一)
  • Spring Security中异常上抛机制及对于转型处理的一些感悟
  • Unix命令
  • Webpack4 学习笔记 - 01:webpack的安装和简单配置
  • Web标准制定过程
  • 阿里云前端周刊 - 第 26 期
  • 可能是历史上最全的CC0版权可以免费商用的图片网站
  • 前端每日实战:61# 视频演示如何用纯 CSS 创作一只咖啡壶
  • 小程序、APP Store 需要的 SSL 证书是个什么东西?
  • 智能网联汽车信息安全
  • 追踪解析 FutureTask 源码
  • 阿里云API、SDK和CLI应用实践方案
  • ​2021半年盘点,不想你错过的重磅新书
  • #控制台大学课堂点名问题_课堂随机点名
  • ( 10 )MySQL中的外键
  • (1)bark-ml
  • (二十四)Flask之flask-session组件
  • (十八)用JAVA编写MP3解码器——迷你播放器
  • (十五)devops持续集成开发——jenkins流水线构建策略配置及触发器的使用
  • (十一)手动添加用户和文件的特殊权限
  • (四) Graphivz 颜色选择
  • (四)docker:为mysql和java jar运行环境创建同一网络,容器互联
  • (五)大数据实战——使用模板虚拟机实现hadoop集群虚拟机克隆及网络相关配置
  • (原創) X61用戶,小心你的上蓋!! (NB) (ThinkPad) (X61)
  • (最简单,详细,直接上手)uniapp/vue中英文多语言切换
  • .[backups@airmail.cc].faust勒索病毒的最新威胁:如何恢复您的数据?
  • .chm格式文件如何阅读
  • .Net core 6.0 升8.0
  • .NET I/O 学习笔记:对文件和目录进行解压缩操作
  • .NET MVC 验证码
  • .NET Remoting学习笔记(三)信道
  • .NET导入Excel数据
  • .NET开发人员必知的八个网站
  • .Net面试题4
  • .NET企业级应用架构设计系列之开场白