我不确定发生了什么。我运行一台 Ubuntu 20.04.2 LTS 机器,没有头。它在夜间的某个时候进行了更新,当我登录时,它提示我需要重新启动。所以我照做了,但是,它似乎没有恢复。
在将显示器连接到它之后,我发现它正在运行,但网络接口不起作用。实际上甚至没有出现,就像它刚刚被删除或移除一样。我会尝试在这里分享尽可能多的信息,但我只是不确定可能出了什么问题,老实说,我不知道还能去哪里查找。
尝试了以下所有方法后,我仍然无法连接互联网。更糟糕的是,重启后,在我的 LAN 上获取允许 SSH 的 IP 地址的唯一方法是使用:
$ sudo ip link set enp3s0 down
$ sudo ip link set enp3s0 up
$ sudo ip addr add 192.168.1.150/24 dev enp3s0
$ sudo lshw -class network
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:03:00.0
logical name: enp3s0
version: 0c
serial: 2c:56:dc:97:80:9f
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.8.0-48-generic duplex=full firmware=rtl8168g-2_0.0.1 02/06/13 ip=192.168.1.150 latency=0 link=yes multicast=yes port=MII speed=1Gbit/s
resources: irq:18 ioport:e000(size=256) memory:fea00000-fea00fff memory:f0800000-f0803fff
$ sudo nano /etc/netplan/netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: no
addresses:
- 192.168.1.150/24
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
重新启动后,上述netplan
配置仍然存在,但是,某些行中添加了额外的间距 - 导致其失败。
$ ip a
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 2c:56:dc:97:80:9f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.150/24 scope global enp3s0
valid_lft forever preferred_lft forever
inet6 2001:1970:4a26:8100:2e56:dcff:fe97:809f/64 scope global dynamic mngtmpaddr
valid_lft 86140sec preferred_lft 14140sec
$ ip route show
default via 192.168.1.1 dev enp3s0
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.18.0.0/16 dev br-5c71e5479641 proto kernel scope link src 172.18.0.1
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.150
我只能让default via 192.168.1.1 dev enp3s0
运行后出现的部分sudo ip route add default via 192.168.1.1
。
$ sudo netplan --debug try
DEBUG:enp3s0 not found in {}
DEBUG:Merged config:
network:
ethernets:
enp3s0:
addresses:
- 192.168.1.150/24
dhcp4: false
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
renderer: networkd
version: 2
DEBUG:New interfaces: set()
** (generate:53716): DEBUG: 22:58:01.445: Processing input file /etc/netplan/netcfg.yaml..
** (generate:53716): DEBUG: 22:58:01.445: starting new processing pass
** (generate:53716): DEBUG: 22:58:01.446: We have some netdefs, pass them through a final round of validation
** (generate:53716): DEBUG: 22:58:01.446: enp3s0: setting default backend to 1
** (generate:53716): DEBUG: 22:58:01.446: Configuration is valid
** (generate:53716): DEBUG: 22:58:01.446: Generating output files..
An error occurred: the configuration could not be generated
Reverting.
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:enp3s0 not found in {}
DEBUG:Merged config:
network:
ethernets:
enp3s0:
addresses:
- 192.168.1.150/24
dhcp4: false
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
renderer: networkd
version: 2
DEBUG:no netplan generated NM configuration exists
DEBUG:enp3s0 not found in {}
DEBUG:Merged config:
network:
ethernets:
enp3s0:
addresses:
- 192.168.1.150/24
dhcp4: false
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
renderer: networkd
version: 2
DEBUG:Link changes: {}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp3s0
DEBUG:netplan triggering .link rules for br-5c71e5479641
DEBUG:netplan triggering .link rules for docker0
DEBUG:netplan triggering .link rules for vethf90fcb2
DEBUG:netplan triggering .link rules for veth71540be
DEBUG:netplan triggering .link rules for veth18e90b7
DEBUG:netplan triggering .link rules for vetheb58aaa
DEBUG:netplan triggering .link rules for veth728e8e9
DEBUG:netplan triggering .link rules for veth96def70
DEBUG:netplan triggering .link rules for vetha4b92ad
DEBUG:netplan triggering .link rules for vethd43e21c
DEBUG:netplan triggering .link rules for vethb777853
DEBUG:netplan triggering .link rules for veth2b054d4
DEBUG:netplan triggering .link rules for veth8f6354f
DEBUG:netplan triggering .link rules for vethc69182e
DEBUG:netplan triggering .link rules for veth9e52006
DEBUG:netplan triggering .link rules for veth9b90b02
DEBUG:netplan triggering .link rules for veth3f22dda
DEBUG:netplan triggering .link rules for vethc39e6d3
DEBUG:netplan triggering .link rules for vetha38ae56
DEBUG:netplan triggering .link rules for vethf68a144
DEBUG:enp3s0 not found in {}
DEBUG:Merged config:
network:
ethernets:
enp3s0:
addresses:
- 192.168.1.150/24
dhcp4: false
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
renderer: networkd
version: 2
这是我所掌握的全部信息。我只是不确定哪里出了问题、怎么发生的、什么时候发生的。
非常感谢您的帮助。谢谢!
答案1
我在 Ubuntu 20.x 更新后也遇到了同样的网络离线问题。
我发现这个错误报告:https://bugs.launchpad.net/netplan/+bug/1922898
以下是我修复 Ubuntu 20.x 服务器的方法:
下载最新版本
netplan.io_0.102
:cd /tmp wget http://security.ubuntu.com/ubuntu/pool/main/n/netplan.io/netplan.io_0.102-0ubuntu1~20.04.1_amd64.deb
以 root 身份运行以下命令:
sudo dpkg -i netplan.io_0.102-0ubuntu1~20.04.1_amd64.deb
确认
netplan
和libnetplan
同步:$ sudo dpkg -l | grep netpl libnetplan0:amd64 0.102-0ubuntu1~20.04.1 amd64 YAML network configuration abstraction runtime library netplan.io 0.102-0ubuntu1~20.04.1 amd64 YAML network configuration abstraction for various backends
重启。
答案2
Google Cloud 用户:我在 GCP 的三台机器上遇到了同样的问题。由于无法传输文件,我无法直接实施 user15523715 提供的修复。但是,我能够通过以下修改来实现它。
创建或转到在 GCP 中运行的 Ubuntu VM
创建一个空白磁盘并附加。请参阅:https://cloud.google.com/compute/docs/disks/add-persistent-disk
通过 SSH 或控制台进入虚拟机并格式化和安装磁盘。请参阅:https://devopscube.com/mount-extra-disks-on-google-cloud/
将 netplan.io 下载到该磁盘
cd /demo-mount
wget http://security.ubuntu.com/ubuntu/pool/main/n/netplan.io/netplan.io_0.102-0ubuntu1~20.04.1_amd64.deb
- 卸载磁盘
sudo umount /demo-mount
从虚拟机中删除磁盘
将磁盘附加到受影响的虚拟机
将磁盘安装到受影响的虚拟机
sudo mkdir -p /demo-mount
- 进入挂载目录
sudo mount -o discard,defaults /dev/sdb /demo-mount
- 安装新包
sudo dpkg -i netplan.io_0.102-0ubuntu1~20.04.1_amd64.deb
停止虚拟机
移除磁盘
启动虚拟机