systemd:为什么默认路由有效时会出现“ens3:无法设置路由:网络不可达”的情况?

systemd:为什么默认路由有效时会出现“ens3:无法设置路由:网络不可达”的情况?

最近,我托管在 OVH 的 VPS 突然断网。经过进一步检查,systemd-networkd发现无法设置默认路由: ens3: Could not set route: Network is unreachable。我不清楚为什么会突然发生这种情况,因为以下配置在过去运行良好,据我所知,自上次维护以来,VPS 没有发生任何变化:


/etc/netplan/50-cloud-init.yaml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        ens3:
            dhcp4: false
            addresses:
                - 167.114.129.127/32
                - 2607:5300:201:3100:0:0:0:1225/64
            gateway4: 167.114.129.1
            gateway6: 2607:5300:0201:3100:0000:0000:0000:0001
            match:
                macaddress: fa:16:3e:65:ef:95
            set-name: ens3

/run/systemd/network/10-netplan-ens3.link

[Match]
MACAddress=fa:16:3e:65:ef:95

[Link]
Name=ens3
WakeOnLan=off

/运行/systemd/network/10-netplan-ens3.network

[Match]
MACAddress=fa:16:3e:65:ef:95
Name=ens3

[Network]
LinkLocalAddressing=ipv6
Address=167.114.129.127/32
Address=2607:5300:201:3100:0:0:0:1225/64
Gateway=167.114.129.1
Gateway=2607:5300:0201:3100:0000:0000:0000:0001
ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    inet 167.114.129.127/32 scope global ens3
       valid_lft forever preferred_lft forever

手动添加路线,,ip route add default 167.114.129.1 dev ens3失败nexthop has invalid gateway。我手动操作了这个问题onlink。有比我更有经验的人可以帮忙解释一下这里发生了什么,会很感激吗?

答案1

网关和地址应位于同一子网中:但您的/run/systemd/network/10-netplan-ens3.network文件却不位于同一子网中。尝试将 ens3 的地址设置为 167.114.129.127/24。

相关内容