趁着系统在升级,记录一下ubuntu recovery mode的网络恢复功能。我的系统是Ubuntu1610,因为不是LTS,官方已经不支持更新了,因此也无法通过正常的手段升级,曲线升级的方法参考这里

Revoery 模式下网络连接

在升级过程中,可能会出现重启后无法连接网络的问题,其中最严重的就是网卡驱动没有了。解决方法如下,

  1. 重启系统;
  2. 选择Advanced options for ubuntu;
  3. 选择最近的image的recover mode;
  4. 进入后,选择network enable network;
  5. 再次重启。

DNS server

另一种情况是,DNS server出现问题,例如/etc/reconv.conf文件为空,或者出现问题。解决方法是自己添加,默认的配置如下

1
2
3
4
5
6
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.53

也可以自己修改成如下形式,

1
2
nameserver 114.114.114.114
nameserver 8.8.8.8

多网卡的配置

除了网络恢复问题,多网卡的配置也是我关注的问题,这样可以一定程度上保证电脑处在联网状态。以我的系统为例,分别有两块网卡,有线网卡enp0s31f6和无线网卡wlp4s0,二者将连接到不同的网络,以有线网卡作为主要网卡,则配置如下,配置文件为/etc/network/interfaces

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
# The wireless network interface with dhcp
auto wlp4s0
iface wlp4s0 inet dhcp
address 192.168.30.100
netmask 255.255.255.0
network 192.168.30.0
gateway 192.168.30.1
wpa-ssid WIFI-NAME # SSID name
wpa-key-mgmt WPA-PSK # Encryption method
wpa-psk YOYR-PASSWORD-HERE # WIFI password

References