将 Ubuntu 22.04 LTS(Jammy)升级到 23.10(Mantic)会破坏网络配置:如何升级网络配置?

将 Ubuntu 22.04 LTS(Jammy)升级到 23.10(Mantic)会破坏网络配置:如何升级网络配置?

我在基于 OpenVZ 的虚拟远程服务器上运行 Ubuntu 22.04 LTS(Jammy)版本。我只能通过 SSH 访问服务器。当我尝试升级到 23.10(Mantic)时,下次重启后我就被锁定在服务器之外了。在我通过主机 WebUI 启动恢复系统并 chroot 到生产系统后,journalctl似乎发现在升级后的生产系统的上次启动过程中只配置了环回设备lo。(这也解释了为什么我不能再通过 SSH 登录。)

我有一个“纯”systemd 安装,它使用systemd-resolvedsystemd-networkd.service。在 Jammy 中,所有这些守护进程都是软件包的一部分systemd。在 Mantic 中,resolvectl似乎已移入其自己的软件包中systemd-resolved,升级过程似乎错过了该软件包。但即使我在 chroot 环境中额外安装了该软件包,升级后的系统仍然无法正常工作。

这是基于 Ubuntu Jammy 的旧(工作)系统的配置:

root@myhost:~ # ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/void 

root@myhost:~ # ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default 
    link/void 
    inet 127.0.0.1/32 scope host venet0
       valid_lft forever preferred_lft forever
    inet w.x.y.z/32 brd 85.215.93.43 scope global venet0:0
       valid_lft forever preferred_lft forever
    inet6 xxxx:yyyy:zzzz:wwww:xxxx:yyyy:zzzz:wwww/128 scope global 
       valid_lft forever preferred_lft forever

root@myhost:~ # ip route show
default dev venet0 scope link

(请注意,出于隐私考虑,我用占位符替换了全局可路由的 IP 地址。)

root@myhost:/etc # cat /etc/network/interfaces
# This configuration file is auto-generated.
# WARNING: Do not edit this file, otherwise your changes will be lost.
# Please edit template /etc/network/interfaces.template instead.

auto lo
iface lo inet loopback

# Auto generated venet0 interfaces
auto venet0
iface venet0 inet static
        address 127.0.0.1
        netmask 255.255.255.255
        broadcast 0.0.0.0
        up route add default dev venet0
auto venet0:0
iface venet0:0 inet static
        address w.x.y.z
        netmask 255.255.255.255


iface venet0 inet6 static
        address xxxx:yyyy:zzzz:wwww:xxxx:yyyy:wwww:zzzz/128
        up ip -6 r a default dev venet0

请注意,尽管上面的文件包含内容是自动生成的注释,但这是配置 IP 地址的唯一位置。(我grep在里面运行了递归/etc。)就我个人而言,我从未碰过这个文件,它是我的托管商完成的初始安装/配置的一部分。也没有interfaces.template。也许这是问题的一部分?

root@h2917298:/etc # ls -lh /etc/systemd/network/
total 0


root@h2917298:/etc/systemd # cat /etc/systemd/resolved.conf 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the resolved.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.

[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
# Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
# Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
DNS=81.169.163.106 85.214.7.22
#FallbackDNS=
Domains=my-domain.tld my-second-domain.tld
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no

我如何将 Ubuntu 22.04 LTS(Jammy)的配置转换为 23.10(Mantic)的配置,以便它在升级后仍然有效?

相关内容