前言

首先确实是否安装了网卡驱动。

1
2
3
4
5
6
7
8
9
$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        inet6 ::1 prefixlen 128 scopeid 0x10<host>
        loop txqueuelen 1000 (Local Loopback)
        RX packets 3549 bytes 283497 (283.4 KB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 3549 bytes 283497 (283.4 KB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo开头的表示本地连接。如果没有en开头的,表示有线网卡驱动存在问题。因此,需要进一步确定网卡的驱动型号。

1
2
3
4
5
6
$ lspci -v | grep Ethernet
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (7) I219-V (r
ev 10)
        DeviceName: Onboard - Ethernet
        Subsystem: Micro-Star International Co., Ltd. [MSI] Ethernet Connection 
(7) I219-V

百度一下,可知为e1000e驱动,上Intel的官网下载(https://downloadcenter.intel.com/download/15817/Intel-Network-Adapter-Driver-for-PCIe-Intel-Gigabit-Ethernet-Network-Connections-under-Linux-) 即可。我下载的目前最新的版本3.8.4。

安装驱动

1
2
3
4
5
6
# 1.解压
$ tar zxf e1000e-3.8.4.tar.gz
# 2.进入安装目录
$ cd e1000e-3.8.4/src
# 3.安装
$ sudo make install

一般会安装在/lib/modules/`uname -r`/updates/drivers/net/ethernet/intel/e1000e/e1000e.ko下, 不过要让驱动能正常使用,需要将e1000e.ko复制到 /lib/modules/`uname -r`/kernel/drivers/net/ethernet/e1000e.ko中

1
2
3
4
5
6
7
8
# 4.重载
$ sudo depmod -a
# 5.Rebuild initramfs
$ sudo update-initramfs -u -k all
# 6.Check the driver version
$ modinfo e1000e | grep version
# 7.Load the driver module
$ modprobe e1000e

之后,可能需要重启,然后再次确认ifconfig的结果:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        inet6 ::1 prefixlen 128 scopeid 0x10<host>
        loop txqueuelen 1000 (Local Loopback)
        RX packets 3549 bytes 283497 (283.4 KB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 3549 bytes 283497 (283.4 KB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno1: flags=4163 <UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet xxxx netmask xxxx
        inet6 ::1 prefixlen 128 scopeid 0x10<host>
        loop txqueuelen 1000 (Local Loopback)
        RX packets 3549 bytes 283497 (283.4 KB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 3549 bytes 283497 (283.4 KB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

如果出现了en开头的字符,比如上面的eno1或其他字符,则表明网卡驱动安装成功。这时候, 如果打开Ubuntu的网络设置界面,可能仍然看不到关于有限网连接的菜单。但是,我们可以通过 在命令行手动设置一些网络参数来上网。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 8.将eno1设置为活动模式
$ sudo ip link set dev eno1 up
# 9.进入网络设置目录
$ cd /etc/netplan
# 10.修改其中的网络配置文件的参数
$ ls
01-netcfg.yaml
# 下面是我修改的结果
$ cat 01-netcfg.yaml
# This file describes the networks interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4:yes

参数文件中的eno1需要和自己ifconfig所对应的en开头的名称一致。

参考资料

[1] https://razeencheng.com/post/ubutun-realtek-r8125-driver-install

[2] http://www.njcto.com/ubuntu-intel-e1000e.html

[3] https://forum.openmediavault.org/index.php?thread/27791-troubles-with-the-installation-of-the-e1000e-intel-driver-i219-v/

[4] https://my.oschina.net/u/4398725/blog/4743473

修订历史

  • 2021-03-11: 完成初稿