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 makegit 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/certssudo 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
EOFsudo 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 enableduser@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

Ubuntu18.04安装RTL8125/RTL8168等网卡驱动程序相关推荐

  1. VMware linux 虚拟机(ubuntu18.04) 安装TL-WDN5200H 2.0网卡驱动 完美使用(适用于vmware无法桥接网络使用此方法)

    VMware linux 虚拟机(ubuntu18.04) 安装TL-WDN5200H 2.0网卡驱动 完美使用(适用于vmware无法桥接网络使用此方法) # 以下操作均已root用户操作 # 安装 ...

  2. 如何在Ubuntu18.04安装Tesla T4板的驱动程序

    1 手先需要卸载当前的网卡驱动 (当然,如果是新装的系统就忽略该步.) 1)用ctrl+Alt+Fn进入命令行:          Fn=F1 ~ F10 2)sudo apt-get purge n ...

  3. Ubuntu18.04安装basler相机的ROS驱动程序pylon_ros_camera

    系统:Ubuntu 18.04 64位,ROS:melodic 安装basler单目相机驱动之前需要安装ROS,安装过程见我之前发的博客,一定要确保rosdep update成功,否则可能会导致安装失 ...

  4. Ubuntu18.04安装ax200网卡驱动以及更新内核

    Ubuntu18.04安装ax200网卡驱动以及更新内核 参考资料:https://zhangyiming748.github.io/2019/12/05/useAX200OnUbuntu/ 原来的网 ...

  5. ubuntu18.04安装 usb无限网卡上网

    ubuntu18.04安装 usb无限网卡上网 总结,千万不要在未联网的情况下安装ubuntu,否则会给你带来无尽灾难 下面我介绍一下我在未联网情况下安装Ubuntu后遇到的灾难: 1.ubuntu我 ...

  6. Linux/Ubuntu18.04安装RTL8811cu驱动

    Linux/Ubuntu18.04安装TL-WDN5200H驱动 适用于TP-LINK 无线USB网卡 <TL-WDN5200H 免驱版 > 问题描述: 1.笔记本安装双系统ubuntu1 ...

  7. ubuntu18.04安装Nvidia显卡驱动后黑屏及网络、蓝牙驱动消失的解决方案

    ubuntu18.04安装Nvidia显卡驱动后黑屏及网络.蓝牙驱动消失的解决方案 文章目录 ubuntu18.04安装Nvidia显卡驱动后黑屏及网络.蓝牙驱动消失的解决方案 1.问题描述 2.解决 ...

  8. 无人机开发系列 Ubuntu18.04安装 含虚拟机与双系统

    主线 无人机开发系列 一 Ubuntu操作系统搭建 本系列文章主要基于linux环境做有关开发,使用Ubuntu操作系统.开发方式主要分为虚拟机和双系统.直接步入正题. 一.虚拟机VMware和Ubu ...

  9. ubuntu20.04到ubuntu18.04安装英伟达(nvidia)显卡驱动的血泪史

    文章目录 ubuntu20.04到ubuntu18.04安装显卡驱动的血泪史 一.Ubuntu系统准备 二.显卡驱动的三种方法 1. 使用标准Ubuntu仓库进行自动安装 2. 使用PPA仓库进行自动 ...

最新文章

  1. C语言实现生产者-消费者问题
  2. UA MATH571B 试验设计 QE练习题 平衡非完全区组设计BIBD
  3. 弹出显示多条的message对话框
  4. 三角网导线平差实例_导线测量平差实例
  5. java8 按条件过滤集合
  6. 推荐系统知识梳理——WideDeep
  7. ASP.NET设置发帖时间间隔不超过30秒
  8. 标点符号/特殊符号的英文名称
  9. CLION CMAKE 缺-g 导致断点不执行(无效)
  10. [POJ3233] Matrix Power Series(矩阵快速幂)
  11. createdroptargets_拖拽神器React DnD你真的了解了吗?
  12. anaconda 安装Mosek
  13. Shell 脚本大全(收藏好)
  14. 苏宁 OLAP 引擎发展之路
  15. 快乐技术沙龙技术分享之账户助手
  16. 语音搜索引擎--Midomi
  17. python解一元二次方程ax^2+bx_python 练习题:定义一个函数quadratic(a, b, c),接收3个参数,返回一元二次方程ax^2+bx+c=0的两个解...
  18. 北京数码视讯s905l固件_数码视讯Q6联通版S905L芯片第三方刷机固件
  19. SQLException:null, message from server: “Host ‘xx‘ is not allowed to connect to this MySQL server“
  20. 七步教你制定网站SEO整体优化方案

热门文章

  1. ping命令英文全称
  2. 业务流程巡检拨测(开源工具)
  3. 对接海康威视ehome踩过的坑总结
  4. 我的世界mod开发(6)无敌的护甲
  5. Could not open the editor: URLDecoder: Illegal hex characters in escape (%) pattern - For input stri
  6. 数据统计分析(SPSS)【2】
  7. oracle字符集问题
  8. 海量数据、丰厚奖金,美团外卖推荐技术评测邀你来战!
  9. datetime取东八区时间只取到秒,返回为datetime类
  10. 时钟程序设计java_Java数字时钟实现代码详解