systemd 网络 ipv6 网关未设置

systemd 网络 ipv6 网关未设置

交叉发布于github

我不明白为什么我的 systemd 网络配置没有设置 ipv6 网关路由,XXX.XXX.XXX.XXX并且YYYY:YYYY:YYYY:YYYY::始终是相同的 ip。我的服务器由 OVH 托管:

[Match]
Name=eth0
 
[Network]
DHCP=false
 
DNS=91.121.161.184
DNS=91.121.164.227
 
Address=XXX.XXX.XXX.XXX/24
Gateway=XXX.XXX.XXX.254
 
DNS=2001:41d0:1:e2b8::1
DNS=2001:41d0:1:e5e3::1
 
Address=YYYY:YYYY:YYYY:YYYY::/64
Gateway=YYYY:YYYY:YYYY:YYFF:FF:FF:FF:FF

这对于 ivp4 正确工作:

networkctl status eth0
● 2: eth0
                     Link File: n/a
                  Network File: /etc/systemd/network/eth0.network
                          Type: ether
                         State: routable (configuring)
                  Online state: online
                        Vendor: Intel Corporation
                         Model: Ethernet Controller 10G X550T
                    HW Address: xx:xx:xx:xx:xx:xx (ASRock Incorporation)
                           MTU: 1500 (min: 68, max: 9710)
                         QDisc: mq
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 64/64
              Auto negotiation: yes
                         Speed: 10Gbps
                        Duplex: full
                          Port: tp
                       Address: XXX.XXX.XXX.XXX
                                YYYY:YYYY:YYYY:YYYY::
                                fe80::d250:99ff:fed9:a09d
                       Gateway: XXX.XXX.XXX.254
                           DNS: 91.121.161.184
                                91.121.164.227
                                2001:41d0:1:e2b8::1
                                2001:41d0:1:e5e3::1
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000000000000000000000000000
 
Jul 13 23:21:15 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 4s
Jul 13 23:21:19 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 8s
Jul 13 23:21:25 optomata systemd-networkd[557]: eth0: NDISC: No RA received before link confirmation timeout
Jul 13 23:21:25 optomata systemd-networkd[557]: eth0: NDISC: Invoking callback for 'timeout' event.
Jul 13 23:21:25 optomata systemd-networkd[557]: eth0: NDisc handler get timeout event
Jul 13 23:21:25 optomata systemd-networkd[557]: eth0: link_check_ready(): static routes are not configured.
Jul 13 23:21:27 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 17s
Jul 13 23:21:45 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 33s
Jul 13 23:22:19 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 1min 10s
Jul 13 23:23:29 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 2min 21s
ping google.fr
PING google.fr (142.250.201.195) 56(84) bytes of data.
64 bytes from bud02s35-in-f3.1e100.net (142.250.201.195): icmp_seq=1 ttl=111 time=15.5 ms
64 bytes from bud02s35-in-f3.1e100.net (142.250.201.195): icmp_seq=2 ttl=111 time=15.5 ms
64 bytes from bud02s35-in-f3.1e100.net (142.250.201.195): icmp_seq=3 ttl=111 time=15.5 ms
64 bytes from bud02s35-in-f3.1e100.net (142.250.201.195): icmp_seq=4 ttl=111 time=15.5 ms
64 bytes from bud02s35-in-f3.1e100.net (142.250.201.195): icmp_seq=5 ttl=111 time=15.5 ms
^C
--- google.fr ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 15.461/15.471/15.488/0.009 ms

但 ipv6 不起作用:

ping -6 google.fr
ping: connect: Network is unreachable
ip -6 route show dev eth0
YYYY:YYYY:YYYY:YYYY::/64 proto kernel metric 256 pref medium
fe80::/64 proto kernel metric 256 pref medium

但如果我手动添加路线:

ip -6 route add YYYY:YYYY:YYYY:YYFF:FF:FF:FF:FF dev eth0
networkctl status eth0
● 2: eth0
                     Link File: n/a
                  Network File: /etc/systemd/network/eth0.network
                          Type: ether
                         State: routable (configured)
                  Online state: online
                        Vendor: Intel Corporation
                         Model: Ethernet Controller 10G X550T
                    HW Address: xx:xx:xx:xx:xx:xx (ASRock Incorporation)
                           MTU: 1500 (min: 68, max: 9710)
                         QDisc: mq
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 64/64
              Auto negotiation: yes
                         Speed: 10Gbps
                        Duplex: full
                          Port: tp
                       Address: XXX.XXX.XXX.XXX
                                YYYY:YYYY:YYYY:YYYY::
                                fe80::d250:99ff:fed9:a09d
                       Gateway: XXX.XXX.XXX.254
                                YYYY:YYYY:YYYY:YYFF:FF:FF:FF:FF
                           DNS: 91.121.161.184
                                91.121.164.227
                                2001:41d0:1:e2b8::1
                                2001:41d0:1:e5e3::1
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000000000000000000000000000

Jul 13 23:23:29 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 2min 21s
Jul 13 23:25:51 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 4min 38s
Jul 13 23:30:30 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 9min 18s
Jul 13 23:39:49 optomata systemd-networkd[557]: eth0: NDISC: Sent Router Solicitation, next solicitation in 18min 42s
Jul 13 23:47:49 optomata systemd-networkd[557]: eth0: Remembering foreign route: dst: YYYY:YYYY:YYYY:YYff:ff:ff:ff:ff/128, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: boot, type: unicast, nexthop: 0, priority: 1024
Jul 13 23:47:49 optomata systemd-networkd[557]: eth0: Configuring route: dst: n/a, src: n/a, gw: YYYY:YYYY:YYYY:YYff:ff:ff:ff:ff, prefsrc: n/a, scope: global, table: main(254), proto: static, type: unicast, nexthop: 0, priority: 1024
Jul 13 23:47:49 optomata systemd-networkd[557]: eth0: Received remembered route: dst: n/a, src: n/a, gw: YYYY:YYYY:YYYY:YYff:ff:ff:ff:ff, prefsrc: n/a, scope: global, table: main(254), proto: static, type: unicast, nexthop: 0, priority: 1024
Jul 13 23:47:49 optomata systemd-networkd[557]: eth0: Routes set
Jul 13 23:47:49 optomata systemd-networkd[557]: eth0: link_check_ready(): dhcp4:no ipv4ll:no dhcp6_addresses:no dhcp6_routes:no dhcp6_pd_addresses:no dhcp6_pd_routes:no ndisc_addresses:yes ndisc_routes:yes
Jul 13 23:47:49 optomata systemd-networkd[557]: eth0: State changed: configuring -> configured
ping -6 google.com
PING google.com(fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e)) 56 data bytes
64 bytes from fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e): icmp_seq=1 ttl=113 time=1.39 ms
64 bytes from fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e): icmp_seq=2 ttl=113 time=1.41 ms
64 bytes from fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e): icmp_seq=3 ttl=113 time=1.39 ms
64 bytes from fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e): icmp_seq=4 ttl=113 time=1.40 ms
64 bytes from fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e): icmp_seq=5 ttl=113 time=1.42 ms
64 bytes from fra24s08-in-x0e.1e100.net (2a00:1450:4001:82b::200e): icmp_seq=6 ttl=113 time=1.40 ms
ip -6 route show dev eth0
YYYY:YYYY:YYYY:YYYY::/64 proto kernel metric 256 pref medium
YYYY:YYYY:YYYY:YYff:ff:ff:ff:ff metric 1024 pref medium
fe80::/64 proto kernel metric 256 pref medium
default via YYYY:YYYY:YYYY:YYff:ff:ff:ff:ff proto static metric 1024 pref medium

系统信息:

cat /etc/os-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux
uname -a
Linux optomata 5.12.15-arch1-1 #1 SMP PREEMPT Wed, 07 Jul 2021 23:35:29 +0000 x86_64 GNU/Linux
systemctl --version
systemd 249 (249-2-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

journalctl -u systemd-networkd.service

答案1

您在 OVH 上有一个服务器,其 IPv6 网关位于与分配给您的 /64 不同的子网中,尽管它位于同一第 2 层物理链路上。

这意味着您需要告诉 systemd-networkd 它需要创建您一直手动创建的静态路由。

Gateway=您不需要在部分中使用 IPv6快捷方式[Network],而是需要将其从那里删除,并创建一个[Route]部分来保存 IPv6 网关和必要的参数GatewayOnLink=yes。这会告诉内核该网关在 LAN 上可直接访问,它将自行创建必要的静态路由。

[Route]
Gateway=2001:41d0:whatever
GatewayOnLink=yes

相关内容