Systemd-networkd 无法自动配置 IPv6,而 ifupdown 可以成功

Systemd-networkd 无法自动配置 IPv6,而 ifupdown 可以成功

标题有点模糊,因为我不知道发生了什么。我想切换到 systemd-networkd,并希望它自动配置 IPv4 和 IPv6。我来自 ifupdown,配置如下:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens3
iface ens3 inet dhcp
# This is an autoconfigured IPv6 interface
iface ens3 inet6 auto

这有效:

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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:4f:e8:63 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet <valid ipv4>/24 brd <valid stuff> scope global dynamic ens3
       valid_lft 86031sec preferred_lft 86031sec
    inet6 2a01:7c8:****:***:****:ff:fe4f:e863/64 scope global dynamic mngtmpaddr 
       valid_lft 2591987sec preferred_lft 604787sec
    inet6 fe80::5054:ff:fe4f:e863/64 scope link 
       valid_lft forever preferred_lft forever

然后我想切换到 systemd-networkd,因此我创建了以下配置

[Match]
Name=ens3

[Network]
DHCP=yes

然后我清除 ifupdown 以将其移除,启用 systemd-networkd 和 systemd-resolved 并重新启动。IPv4 运行正常,IPv6 出现故障:

ip a                                                                                                                                                                                                                                                  130 ↵
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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:4f:e8:63 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet <valid ipv4> brd <valid stuff> scope global dynamic ens3
       valid_lft 86371sec preferred_lft 86371sec
    inet6 fe80::5054:ff:fe4f:e863/64 scope link 
       valid_lft forever preferred_lft forever

因此没有全局 ipv6 地址。查看 systemd-networkd 的调试日志显示:

jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: Configuring route: dst: 2a01:7c8:d003::/48, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: Setting NDisc routes.
jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: State changed: configured -> configuring
jan 23 16:01:43 transip-vps systemd-networkd[3251]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=52 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
jan 23 16:01:43 transip-vps systemd-networkd[3251]: rtnl: received non-static neighbor, ignoring.
jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: NDisc routes set.
jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: Removing old NDisc information obtained from fe80::d003:1.
jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: link_check_ready(): dhcp4:yes dhcp6_addresses:no dhcp_routes:no dhcp_pd_addresses:no dhcp_pd_routes:no ndisc_addresses:yes ndisc_routes:yes
jan 23 16:01:43 transip-vps systemd-networkd[3251]: ens3: State changed: configuring -> configured
jan 23 16:01:43 transip-vps systemd-networkd[3251]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=53 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
jan 23 16:01:46 transip-vps systemd-networkd[3251]: NDISC: Received Router Advertisement: flags none preference medium lifetime 12 sec
jan 23 16:01:46 transip-vps systemd-networkd[3251]: NDISC: Invoking callback for 'router' event.
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: Configuring route: dst: n/a, src: n/a, gw: fe80::d003:1, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
jan 23 16:01:46 transip-vps systemd-networkd[3251]: NDISC: Invalid prefix length, ignoring prefix for stateless autoconfiguration.
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: Configuring route: dst: 2a01:7c8:d003::/48, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: Setting NDisc routes.
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: State changed: configured -> configuring
jan 23 16:01:46 transip-vps systemd-networkd[3251]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=54 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
jan 23 16:01:46 transip-vps systemd-networkd[3251]: rtnl: received non-static neighbor, ignoring.
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: NDisc routes set.
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: Removing old NDisc information obtained from fe80::d003:1.
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: link_check_ready(): dhcp4:yes dhcp6_addresses:no dhcp_routes:no dhcp_pd_addresses:no dhcp_pd_routes:no ndisc_addresses:yes ndisc_routes:yes
jan 23 16:01:46 transip-vps systemd-networkd[3251]: ens3: State changed: configuring -> configured
jan 23 16:01:46 transip-vps systemd-networkd[3251]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=55 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
jan 23 16:01:47 transip-vps systemd-networkd[3251]: NDISC: Received Router Advertisement: flags none preference medium lifetime 12 sec
jan 23 16:01:47 transip-vps systemd-networkd[3251]: NDISC: Invoking callback for 'router' event.
jan 23 16:01:47 transip-vps systemd-networkd[3251]: ens3: Configuring route: dst: n/a, src: n/a, gw: fe80::d003:1, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
jan 23 16:01:47 transip-vps systemd-networkd[3251]: NDISC: Invalid prefix length, ignoring prefix for stateless autoconfiguration.
jan 23 16:01:47 transip-vps systemd-networkd[3251]: ens3: Configuring route: dst: 2a01:7c8:d003::/48, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast

无限。我看到的是前缀2a01:7c8:d003::/48看起来是正确的(除了 /48 而不是 64?),但它无法设置这样的地址,只能一直尝试。

我应该怎么做才能使 systemd-networkd ipv6 正常工作?

相关内容