Networking
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
您在 OVH 上有一台伺服器,它的 IPv6 網關位於與分配給您的 /64 不同的子網中,儘管它位於相同的第 2 層物理鏈路上。
這意味著您需要告訴 systemd-networkd 它需要創建您手動創建的靜態路由。
您需要從那裡刪除它並創建一個部分來保存 IPv6 網關和必要的參數,而不是在該部分中使用 IPv6
Gateway=
快捷方式。這告訴核心網關可以在 LAN 上直接訪問,它將自己創建必要的靜態路由。[Network]``[Route]``GatewayOnLink=yes
[Route] Gateway=2001:41d0:whatever GatewayOnLink=yes