问题
关机前我通过以太网建立了有效的互联网连接,但现在我重新启动后却无法连接到自己的网络,更不用说互联网了。
我在之前安装的 Ubuntu 20.04 桌面版(而不是我现在使用的服务器)上遇到了非常类似的网络问题(以及大量显示问题),该桌面版安装在同一个 SSD 上,这个 SSD 已经很旧了(Windows 机器上的启动驱动器大约 6 年)。可能是驱动器损坏了?
我运行sudo lshw -C network
并得到以下结果:
*-network DISABLED
description: Ethernet Interface
product: Killer E220x Gigabit Ethernet Controller
...
logical name: enp2so
首次尝试解决方案
根据这里的问题(Ubuntu Server 20.04.2 重启后以太网不工作)我运行了以下命令ip link show
:
1: lo: ...
2: enp2so: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether d8:cb:8a:a4:0a:b3 brd ff:ff:ff:ff:ff:ff
我尝试运行命令,sudo ip link set enp2s0 up
后跟sudo netplan apply
,但显然 netplan 由于某种原因未安装在我的 Ubuntu 实例上。我在确认/etc/netplan/00-installer-config.yaml
指向后执行了此操作enp2s0
。
其他信息
我发现的唯一其他建议是关于编辑系统上不存在的文件:
/etc/NetworkManager/conf.d
(该文件夹中唯一的文件是dispatcher.d
)/etc/network/interfaces
(文件不存在)/var/lib/NetworkManager/NetworkManager.state
(没有此文件夹/var/lib/
)- 当我尝试时
sudo service network-manager restart
我只是收到一个错误Failed to restart network-manager.service: Unit network-manager.service not found.
运行服务
~ systemctl list-units --type service --state running
UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
cron.service loaded active running Regular background program processing daemon
dbus.service loaded active running D-Bus System Message Bus
[email protected] loaded active running Getty on tty1
irqbalance.service loaded active running irqbalance daemon
multipathd.service loaded active running Device-Mapper Multipath Device Controller
plexmediaserver.service loaded active running Plex Media Server
polkit.service loaded active running Authorization Manager
rsyslog.service loaded active running System Logging Service
ssh.service loaded active running OpenBSD Secure Shell server
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-networkd.service loaded active running Network Service
systemd-resolved.service loaded active running Network Name Resolution
systemd-timesyncd.service loaded active running Network Time Synchronization
systemd-udevd.service loaded active running udev Kernel Device Manager
thermald.service loaded active running Thermal Daemon Service
udisks2.service loaded active running Disk Manager
[email protected] loaded active running User Manager for UID 1000
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
19 loaded units listed.
编辑12/21
猫/etc/netplan/*.yaml
~ cat /etc/netplan/*.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp2s0:
dhcp4: true
version: 2
sudo lshw -C 网络
~ sudo lshw -C network
*-network DISABLED
description: Ethernet interface
product: Killer E220x Gigabit Ethernet Controller
vendor: Qualcomm Atheros
physical id: 0
bus info: pci@0000:02:00.0
logical name: enp2s0
version: 13
serial: d8:cb:8a:a4:0a:b3
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi msix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=alx latency=0 link=no multicast=yes port=twisted pair
resources: irq:19 memory:f7c00000-f7c3ffff ioport:e000(size=128)
编辑 12/22
研究(以及来自@heynnema 的一些有用的评论)让我相信,netplan
绝对应该在我的系统上安装才能使网络正常工作 - 但事实并非如此。鉴于网络在重启之前工作正常,这是否意味着某些东西损坏了?
编辑 12/23 其他一些可能有用的信息。
dpkg -l *netplan*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un netplan.io <none> <none> (no description available)
和
grep -i netplan /var/log/dpkg.log*
021-08-24 08:43:10 install libnetplan0:amd64 <none> 0.99-0ubuntu1
2021-08-24 08:43:10 status half-installed libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:43:10 status unpacked libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:43:22 install netplan.io:amd64 <none> 0.99-0ubuntu1
2021-08-24 08:43:22 status half-installed netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:43:22 status unpacked netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:43:34 configure libnetplan0:amd64 0.99-0ubuntu1 <none>
2021-08-24 08:43:34 status unpacked libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:43:34 status half-configured libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:43:34 status installed libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:43:57 configure netplan.io:amd64 0.99-0ubuntu1 <none>
2021-08-24 08:43:57 status unpacked netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:43:57 status half-configured netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:43:57 status installed netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:45:10 upgrade libnetplan0:amd64 0.99-0ubuntu1 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:10 status half-configured libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:45:10 status unpacked libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:45:10 status half-installed libnetplan0:amd64 0.99-0ubuntu1
2021-08-24 08:45:10 status unpacked libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:11 upgrade netplan.io:amd64 0.99-0ubuntu1 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:11 status half-configured netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:45:11 status unpacked netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:45:11 status half-installed netplan.io:amd64 0.99-0ubuntu1
2021-08-24 08:45:11 status unpacked netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:12 configure libnetplan0:amd64 0.102-0ubuntu1~20.04.2 <none>
2021-08-24 08:45:12 status unpacked libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:12 status half-configured libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:12 status installed libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:17 configure netplan.io:amd64 0.102-0ubuntu1~20.04.2 <none>
2021-08-24 08:45:17 status unpacked netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:17 status half-configured netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-08-24 08:45:17 status installed netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 upgrade libnetplan0:amd64 0.102-0ubuntu1~20.04.2 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:39 status half-configured libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 status unpacked libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 status half-installed libnetplan0:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 status unpacked libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:39 upgrade netplan.io:amd64 0.102-0ubuntu1~20.04.2 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:39 status half-configured netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 status unpacked netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 status half-installed netplan.io:amd64 0.102-0ubuntu1~20.04.2
2021-12-11 07:27:39 status unpacked netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:44 configure libnetplan0:amd64 0.103-0ubuntu5~20.04.5 <none>
2021-12-11 07:27:44 status unpacked libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:44 status half-configured libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:44 status installed libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:52 configure netplan.io:amd64 0.103-0ubuntu5~20.04.5 <none>
2021-12-11 07:27:52 status unpacked netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:52 status half-configured netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-11 07:27:52 status installed netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:12:51 status installed netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:12:51 remove netplan.io:amd64 0.103-0ubuntu5~20.04.5 <none>
2021-12-19 23:12:51 status half-configured netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:12:51 status half-installed netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:12:51 status config-files netplan.io:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:12:51 status not-installed netplan.io:amd64 <none>
2021-12-19 23:16:52 status installed libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:16:52 remove libnetplan0:amd64 0.103-0ubuntu5~20.04.5 <none>
2021-12-19 23:16:52 status half-configured libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:16:52 status half-installed libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:16:52 status config-files libnetplan0:amd64 0.103-0ubuntu5~20.04.5
2021-12-19 23:16:52 status not-installed libnetplan0:amd64 <none>
编辑 12/23 第 2 部分 我注意到启动时出现红色错误消息 - 它立即消失,所以我需要以慢动作在手机上记录我的启动过程(大概有更好的方法......)
消息内容为[FAILED] Failed to start Service for snap application lxd.activate
。然后我运行了推荐的命令并得到了以下输出:
● snap.lxd.activate.service - Service for snap application lxd.activate
Loaded: loaded (/etc/systemd/system/snap.lxd.activate.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2021-12-24 01:17:58 UTC; 3min 12s ago
Process: 678 ExecStart=/usr/bin/snap run lxd.activate (code=exited, status=203/EXEC)
Main PID: 678 (code=exited, status=203/EXEC)
Dec 24 01:17:58 ullr systemd[1]: Starting Service for snap application lxd.activate...
Dec 24 01:17:58 ullr systemd[678]: snap.lxd.activate.service: Failed to execute command: No such file or directory
Dec 24 01:17:58 ullr systemd[678]: snap.lxd.activate.service: Failed at step EXEC spawning /usr/bin/snap: No such file or directory
Dec 24 01:17:58 ullr systemd[1]: snap.lxd.activate.service: Main process exited, code=exited, status=203/EXEC
Dec 24 01:17:58 ullr systemd[1]: snap.lxd.activate.service: Failed with result 'exit-code'.
Dec 24 01:17:58 ullr systemd[1]: Failed to start Service for snap application lxd.activate.
我实际上并不确定这是否相关 - 但除了网络不工作之外,这是我注意到的唯一不寻常的事情。
编辑 12/28
祝大家节日快乐,尤其是那些帮助我的人。我现在不在有问题的电脑旁,但下一步是重新安装netplan.io
并libnetplan0
从闪存驱动器安装,因为这些显然已被卸载。更新这些并不困难,但现在我的首要任务是理解如何这首先发生了。也许有可能跑步
sudo apt update
sudo apt upgrade
破坏了某些东西,但直到重新启动计算机才生效?
答案1
硬件更改
就我而言,我进行了硬件更改,enp4s0 变成了 enp5s0。不幸的是,/etc/netplan/*.yaml 仍然有 enp4s0,不再可用。
答案2
我遇到了这个问题,和你一样,我的 netplan 似乎无缘无故消失了。这可能是由于自动升级设置而发生的,直到重新启动才显现出来。
您正在运行systemd-networkd.service
,可以通过将文件放入 /etc/systemd/network/ 中来手动配置。创建并编辑一个名为的文件,例如/etc/systemd/network/10-wired.network
:
[Match]
Name=enp* # make this match your interface
[Network]
Gateway=192.168.1.254
Address=192.168.1.55/24
DNS=192.168.1.2 # use setting specific to your network
[Route]
Destination=192.168.1.254
Scope=link
此示例适用于静态地址。您可以在 systemd 的手册页中找到 DHCP 的示例(关联)。
您需要使用 重新启动 systemd.networkd sudo systemctl restart systemd-networkd
。此操作应在重启后继续,您无需重新安装 netplan。
答案3
这不是一个令人满意的答案 - 但我最终从头开始重新安装了操作系统。其他方法都不起作用。
答案4
我到处寻找解决我的 ubuntu 22.04 LTS 启动时无以太网启动的问题的方法。幸运的是,我通过简单的调整成功解决了这个问题
在这 3 个位置发现冲突和/或重复的网络设置,@Netplan、@ifupdown 和 @NM。我删除了 2 个位置的设置。
瞧,一切变得轻而易举
位置:1,@ Netplan,/etc/netplan/*.yaml ;将所有设置的注释放入*.yaml文件中:
位置:2,@ ifupdown,/etc/network/interfaces ;在 /etc/network/interfaces 文件中添加所有设置的 #comments
位置:3,@ NM,/etc/NetworkManager/system-connections ;保留此设置