1、安装检查
检查是否安装了网卡驱动
cat /proc/version
命令:lspci | grep -i eth
lspci |grep -i enp4s0
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
如显示 说明驱动未安装
2、升级系统内核(找个外置网卡链接wifi进行升级,本人用的是360wifi 连接公司网络,(个人水平)源码无法解决依赖问题)
sudo dnf install gcc kernel-headers kernel-devel
升级完成,重启
内核:4.5.5-201.fc23.x86_64
[matt@localhost ~]$ uname -a
Linux localhost.localdomain
127.0.0.1 localhost 4.5.5-201.fc23.x86_64 #1 SMP Sat May 21 15:29:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
3、官网下载驱动 : 0005-r8168-8.042.00.tar.bz2 tar jxvf 文件名解压
4、按照安装说明书进行安装(自行阅读README 文件,里面很详细)
sudo ./autorun.sh
完成之后,检查是否安装成功lsmod|grep r8168
[matt@localhost r8168-8.042.00]$ lsmod|grep r8168
r8168 491520 0
成功有显示
5、安装完毕,找到模块安装到的路径
查看所有内核模块
lsmod
查看指定名称的内核模块
modinfo 模块名称
查看内核模块
modinfo r8168
[matt@localhost ~]$ modinfo r8168
filename: /lib/modules/4.5.5-201.fc23.x86_64/kernel/drivers/net/ethernet/realtek/r8168.ko
version: 8.042.00-NAPI
license: GPL
description: RealTek RTL-8168 Gigabit Ethernet driver
author: Realtek and the Linux r8168 crew <netdev@vger.kernel.org>
srcversion: 28926493B00CB7DDA5FFED3
filename最关键:驱动安装的绝对路径(后面用得到)
6、制作系统自启动加载网卡驱动模块(r8168.ko)
---------------------------------------- start ---------------------------------------------
sudo touch /etc/rc.d/rc.local
sudo vim /etc/rc.d/rc.local
在/etc/rc.d/rc.local文件中写入, 然后使用:wq命令 保存并退出.
#!/bin/bash
# 在这个文件中写入开机启动需要执行的命令
赋予可执行权限:
sudo chmod+x /etc/rc.d/rc.local
设置开机启动:
sudo systemctl enable rc-local.service
如果出现以下错误提示:
[root@dev-zhanghua ~]# systemctl enable rc-local.service
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
sudo vim /usr/lib/systemd/system/rc-local.service
在rc-local.service文件末尾加入:
[Install]
WantedBy=multi-user.target
并重新设置开机启动:
sudo systemctl enable rc-local.service
查看状态, 如果出现以下提示, 设置成功!
[zhanghua@dev-zhanghua ~]$ systemctl status rc-local.service
rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled)
Active: active (running) since Wed 2015-04-15 11:37:40 CST; 1h 44min ago
---------------------------------------------- end ---------------------------------------------
接下来:编写shell (enp4s0:是我的网卡设备名称)
sudo vim /etc/rc.d/rc.local
#!/bin/bash
# 在这个文件中写入开机启动需要执行的命令
#卸载相应的系统内核加载的驱动
rmmod r8169
rmmod /lib/modules/4.5.5-201.fc23.x86_64/kernel/drivers/net/ethernet/realtek/r8168.ko
#这个是r8168.ko文件的绝对路径,加载自己的
insmod /lib/modules/4.5.5-201.fc23.x86_64/kernel/drivers/net/ethernet/realtek/r8168.ko
#启动网卡
ifconfig enp4s0 up
保存退出。
6、reboot,重启,检测
lsmod|grep r8168
[matt@localhost ~]$ lsmod|grep r8168
r8168 491520 0
ethtool -i enp4s0
[matt@localhost ~]$ ethtool -i enp4s0
driver: r8168
version: 8.042.00-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:04:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
至此安装成功。