我一直在 Raspberry Pi 3 上安装新的 Ubuntu。我从这里,更新并升级了所有软件包,升级了发行版,并升级了 rPi 固件。
一切进展顺利,但在这个过程的某个时刻,我完全失去了网络连接。很难说具体什么时候,因为我在重启之前做了多个步骤。
由于发生了其他奇怪的事情(启动有时可以工作,有时不工作),我决定重新开始,并详细记录安装过程。它们如下:
- 将基础映像写入 SD 卡
- 引导
- 登录时按提示更改密码
- 安装 rpi-update:
sudo curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update && sudo chmod +x /usr/bin/rpi-update
- 注意到一条消息“无法解析主机 ubuntu”,因此将其添加
127.0.0.1 ubuntu
到我的 /etc/hosts 文件中
- 重新启动(只是为了确保网络仍然畅通)
- 跑步
rpi-update
:sudo apt-get install binutils
sudo rpi-update
- 重新启动以激活新固件(并确认网络仍然有效)
sudo apt-get update
sudo apt-get upgrade
(升级了 85 个软件包,下载量约 65MB)- 重启
此时网络不再起作用。我注意到启动输出中有这些错误(取自/var/log/syslog):
Jul 14 01:18:34 ubuntu systemd[1]: Starting LXD - container startup/shutdown...
Jul 14 01:18:34 ubuntu lxd[18312]: error: open /var/lib/lxd/containers: no such file or directory
Jul 14 01:18:34 ubuntu systemd[1]: lxd-containers.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 01:18:34 ubuntu systemd[1]: Failed to start LXD - container startup/shutdown.
Jul 14 01:18:34 ubuntu systemd[1]: lxd-containers.service: Unit entered failed state.
Jul 14 01:18:34 ubuntu systemd[1]: lxd-containers.service: Failed with result 'exit-code'.
...
Jul 14 01:19:24 ubuntu systemd[1]: Starting Raise network interfaces...
Jul 14 01:19:24 ubuntu dhclient[887]: Internet Systems Consortium DHCP Client 4.3.3
Jul 14 01:19:24 ubuntu ifup[822]: Internet Systems Consortium DHCP Client 4.3.3
Jul 14 01:19:24 ubuntu ifup[822]: Copyright 2004-2015 Internet Systems Consortium.
Jul 14 01:19:24 ubuntu ifup[822]: All rights reserved.
Jul 14 01:19:24 ubuntu ifup[822]: For info, please visit https://www.isc.org/software/dhcp/
Jul 14 01:19:24 ubuntu dhclient[887]: Copyright 2004-2015 Internet Systems Consortium.
Jul 14 01:19:24 ubuntu dhclient[887]: All rights reserved.
Jul 14 01:19:24 ubuntu dhclient[887]: For info, please visit https://www.isc.org/software/dhcp/
Jul 14 01:19:24 ubuntu dhclient[887]:
Jul 14 01:19:24 ubuntu ifup[822]: Cannot find device "eth0"
Jul 14 01:19:24 ubuntu dhclient[887]: Error getting hardware address for "eth0": No such device
Jul 14 01:19:24 ubuntu ifup[822]: Error getting hardware address for "eth0": No such device
Jul 14 01:19:24 ubuntu ifup[822]: If you think you have received this message due to a bug rather
Jul 14 01:19:24 ubuntu ifup[822]: than a configuration issue please read the section on submitting
Jul 14 01:19:24 ubuntu ifup[822]: bugs on either our web page at www.isc.org or in the README file
Jul 14 01:19:24 ubuntu ifup[822]: before submitting a bug. These pages explain the proper
Jul 14 01:19:24 ubuntu ifup[822]: process and the information we find helpful for debugging..
Jul 14 01:19:24 ubuntu ifup[822]: exiting.
Jul 14 01:19:24 ubuntu dhclient[887]:
Jul 14 01:19:24 ubuntu ifup[822]: Failed to bring up eth0.
Jul 14 01:19:24 ubuntu dhclient[887]: If you think you have received this message due to a bug rather
Jul 14 01:19:24 ubuntu dhclient[887]: than a configuration issue please read the section on submitting
Jul 14 01:19:24 ubuntu dhclient[887]: bugs on either our web page at www.isc.org or in the README file
Jul 14 01:19:24 ubuntu dhclient[887]: before submitting a bug. These pages explain the proper
Jul 14 01:19:24 ubuntu dhclient[887]: process and the information we find helpful for debugging..
Jul 14 01:19:24 ubuntu dhclient[887]:
Jul 14 01:19:24 ubuntu dhclient[887]: exiting.
Jul 14 01:19:24 ubuntu systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 01:19:24 ubuntu systemd[1]: Failed to start Raise network interfaces.
Jul 14 01:19:24 ubuntu systemd[1]: Dependency failed for Initial cloud-init job (metadata service crawler).
Jul 14 01:19:24 ubuntu systemd[1]: cloud-init.service: Job cloud-init.service/start failed with result 'dependency'.
Jul 14 01:19:24 ubuntu systemd[1]: networking.service: Unit entered failed state.
Jul 14 01:19:24 ubuntu systemd[1]: networking.service: Failed with result 'exit-code'.
我现在在启动过程中也遇到了不稳定的情况。有时它可以正常工作,有时我会收到异常跟踪,最后一条消息是:
Fixing recursive fault but reboot is needed!
我见过这并且运行sudo service lxd restart
确实修复了 LXD 问题(经过很长时间的延迟),但网络问题仍然存在。
我也见过这,这似乎是我遇到的确切问题,直到我尝试启动错误命名的以太网网络:
ifconfig enxb827eb0ecff3 up
SIOCSIFFLAGS: Operation not permitted
sudo ifconfig enxb827eb0ecff3 up
(no output)
sudo ip link set enxb827eb0ecff3 name eth0
RTNETLINK answers: Device or resource busy
所以现在,当谈到 Linux 故障排除时,我真的是力不从心。有人能告诉我如何恢复系统上的网络吗?也许可以告诉我为什么在全新安装时会发生这种情况?
输出ifconfig
:
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1600 errors:0 dropped:0 overruns:0 frame:0
TX packets:1600 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:118400 (118.4 KB) TX bytes:118400 (118.4 KB)
输出ifconfig -a
:
enxb827eb0ecff3 Link encap:Ethernet HWaddr b8:27:eb:0e:cf:f3
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1600 errors:0 dropped:0 overruns:0 frame:0
TX packets:1600 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:118400 (118.4 KB) TX bytes:118400 (118.4 KB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:5b:9a:a6
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
输出networkctl
:
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback n/a n/a
2 sit0 sit n/a n/a
3 enxb827eb0ecff3 ether n/a n/a
4 wlan0 wlan n/a n/a
4 links listed.
答案1
我遇到了同样的问题。如果你同意可预测的网络接口名称您可以简单地在“/etc/network/interfaces”中使用 NIC 的新名称...
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# See LP: #1262951
source /etc/network/interfaces.d/*.cfg
auto enxb827eb2f0bbd
iface enxb827eb2f0bbd inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
#dns-search example.com
dns-nameservers 192.168.1.254
我一直搞不清楚为什么名称没有设置为“eth0”。Systemd 有一个正确的配置,应该将名称设置为“eth0”。只需检查'/etc/systemd/network/50-cloud-init-eth0.link'。
我还删除了
net.ifnames=0 biosdevname=0
从'/boot/firmware/cmdline.txt'但还是没用!
唯一的办法重命名该死的网卡是 udev 的方式。我已经创建了一个新文件'/etc/udev/rules.d/10-network.rules'...
子系统=="net", 动作=="添加", ATTR{地址}=="b8:27:eb:2f:0b:bd", 名称="net0"
创建此文件后,NIC 将被称为“net0”。显然不建议用这种方式将其重命名为‘eth0’。
但是‘net0’对我来说没问题,而且我可以在‘/etc/network/interfaces’中使用新名称...
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# See LP: #1262951
source /etc/network/interfaces.d/*.cfg
auto net0
iface net0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
#dns-search example.com
dns-nameservers 192.168.1.254
看到这么多不同的地方可以影响网络,真是有趣。但对我来说,这也感觉有点“混乱”。
/托马斯
答案2
我也遇到过同样的问题。重启后无法联网,但完全关机后通常就可以了。这似乎是最新网络管理器软件包中的一个已知问题。最后,我按照以下说明安装了 wicd: https://help.ubuntu.com/community/WICD 我的所有网络问题现在都解决了,除了没有网络面板图标。但这没什么大不了的。