如何解决 UNAS 重启后无法上网的问题
一次小区的意外停电后,UNAS 突然就不能上网了。下意识以为因为停电主板或者电源烧了。 但是插上 hdmi,嗯,能正常开机。
再次感谢 UNAS 是 Debian-based 系统。
检查物理网卡状态
首先,登录管理员账号 admin,执行 lspci
命令。
$ lspci
00:00.0 Host bridge: Intel Corporation Gemini Lake Host Bridge (rev 06)
00:02.0 VGA compatible controller: Intel Corporation GeminiLake [UHD Graphics 600] (rev 06)
00:0e.0 Audio device: Intel Corporation Celeron/Pentium Silver Processor High Definition Audio (rev 06)
00:0f.0 Communication controller: Intel Corporation Celeron/Pentium Silver Processor Trusted Execution Engine Interface (rev 06)
00:12.0 SATA controller: Intel Corporation Celeron/Pentium Silver Processor SATA Controller (rev 06)
00:13.0 PCI bridge: Intel Corporation Gemini Lake PCI Express Root Port (rev f6)
00:13.2 PCI bridge: Intel Corporation Gemini Lake PCI Express Root Port (rev f6)
00:13.3 PCI bridge: Intel Corporation Gemini Lake PCI Express Root Port (rev f6)
00:14.0 PCI bridge: Intel Corporation Gemini Lake PCI Express Root Port (rev f6)
00:15.0 USB controller: Intel Corporation Celeron/Pentium Silver Processor USB 3.0 xHCI Controller (rev 06)
00:1c.0 SD Host controller: Intel Corporation Celeron/Pentium Silver Processor SDA Standard Compliant SD Host Controller (rev 06)
00:1f.0 ISA bridge: Intel Corporation Celeron/Pentium Silver Processor LPC Controller (rev 06)
00:1f.1 SMBus: Intel Corporation Celeron/Pentium Silver Processor Gaussian Mixture Model (rev 06)
01:00.0 Non-Volatile memory controller: Silicon Motion, Inc. SM2263EN/SM2263XT SSD Controller (rev 03)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
04:00.0 SATA controller: ASMedia Technology Inc. ASM1062 Serial ATA Controller (rev 02)
看到倒数第二第三行,Ethernet controller 网络控制器能识别。看来网卡没坏。
既然硬件没坏,那最坏也不过是重装系统嘛。还行。
检查网口状态
执行 ip addr
$ ip addr
1: lo: ...
2: enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether c4:83:4f:27:32:04 brd ff:ff:ff:ff:ff:ff
3: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether c4:83:4f:27:32:05 brd ff:ff:ff:ff:ff:ff
4: virbr0: ...
5: docker0: ...
这里我手动隐藏了第1、4和5项配置,只关注 enp2s0、enp3s0 两个网络配置。这种命名格式的网口,对应的就是 UNAS 的两个物理网口。
enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
可以看到,这里的状态是 DOWN,网口离线。
尝试启动该网口:
首先,切换到 root 账后,不然没权限修改网络配置。
su root
然后:
[email protected]******:/# ifup enp3s0
ifup: unknown interface enp3s0
哦??竟然找不到网口!
再次查看本机设备:
cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 21371218 58207 0 0 0 0 0 0 21371218 58207 0 0 0 0 0 0
enp2s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
enp3s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
virbr0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
docker0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
可以看到,enp2s0 和 enp3s0 两个设备确实存在。
检查网口配置
接下来检查网络配置 cat /etc/network/interfaces
:
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
...
auto enp1s0
allow-hotplug enp1s0
iface enp1s0 inet dhcp
auto bond0
...
继续省略无关的内容。这里的网络配置,只配置了 enp1s0 。但实际上,这个设备并不存在(上一步的 cat /proc/net/dev
命令并没有输出这个设备)。
而 enp2s0 和 enp3s0 的配置是缺失的。非常奇怪。
Anyway,总之我们先把缺失的配置补回来。仿照配置文件,补完 enp2s0 和 enp3s0 配置:
首先,备份一下当前配置(或者你就直接复制文本,然后随便贴到哪)。
cat /etc/network/interfaces > /root/network_initeraces_backup.txt
然后修改文件:
输入vi命令。vi 是 Linux 下的文本编辑器。
vi /etc/network/interfaces
然后输入 i
。进入输入模式。也就是普通人最熟悉的文本编辑模式。
ps: 如何你进入 Insert 模式后,方向键无法移动光标,而是变成了英文字母(例如按下变成了B)。或者后退键无法删除文字。
先按 Esc 键退出输入模式。
然后输入:set nocompatible
,回车。
再次输入:set backspace=2
,回车。
再次输入 i 进入输入模式。
ps2: 你可以在任意时候按 Esc 退出输入(或者其他奇奇怪怪的模式),然后输入 :q!
并回车。该命令会丢弃所有修改并退出。
修改文件内容如下。
auto enp1s0
allow-hotplug enp1s0
iface enp1s0 inet dhcp
auto enp2s0
allow-hotplug enp2s0
iface enp2s0 inet dhcp
auto enp3s0
allow-hotplug enp3s0
iface enp3s0 inet dhcp
auto bond0
最后,按下 Esc 键退出输入模式。然后输入:wq
,回车。保存并退出。
重启
重启 UNAS。输入命令:
reboot
重启完成后,重新登录系统。
再次执行 ip addr
命令。
...
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether c4:83:4f:27:32:04 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.114/24 brd 10.0.0.255 scope global dynamic enp2s0
valid_lft 6740sec preferred_lft 6740sec
inet6 fe80::c683:4fff:fe27:3204/64 scope link
valid_lft forever preferred_lft forever
...
如果问题修复,你可以看到网口已经分配 ip。如下方加粗的文字所示。 inet 10.0.0.210/24 brd 10.0.0.255 scope global dynamic enp2s0
总结
个人推测,应该是之前尝试了配置端口聚合,发现不怎么好用,又取消了配置。 但是配置取消后,UNAS 新的网络配置并没有持久化。导致断电重启后,配置丢失。
当然,只是推测.