如何查看 systemd-networkd DHCP v6 请求的结果

如何查看 systemd-networkd DHCP v6 请求的结果

我正在运行 Ubuntu 22.04 服务器,已删除 netplan.io。我已启用 systemd-networkd。

我的一个网络接口ens9已插入电缆调制解调器。我已将其配置如下:networkd

[Match]
Name=ens9

[Network]
DHCP=yes
LinkLocalAddressing=ipv6
IPv6PrivacyExtensions=false
ConfigureWithoutCarrier=yes
IPv6AcceptRA=yes

[DHCP]
RouteMetric=100
UseMTU=true
UseDNS=false
UseNTP=false
SendHostname=false
UseHostname=false
UseDomains=false

[DHCPV6]
WithoutRA=solicit
RapidCommit=no
PrefixDelegationHint=::/56

我的理解是,这不仅应该要求委派 IPV6 地址,还应该要求委派整个前缀。

当机器启动时,它会通过 DHCP 获取一些 IP:

4: ens9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc htb state UP group default qlen 1000
    link/ether 00:13:3b:4a:d9:a9 brd ff:ff:ff:ff:ff:ff
    altname enp0s9
    inet 70.122.36.176/22 metric 100 brd 70.122.39.255 scope global dynamic ens9
       valid_lft 28305sec preferred_lft 28305sec
    inet6 2605:6000:ffc0:7d:828:9be:7ce4:637f/128 scope global dynamic noprefixroute 
       valid_lft 551439sec preferred_lft 551439sec
    inet6 fe80::213:3bff:fe4a:d9a9/64 scope link 
       valid_lft forever preferred_lft forever

我的 IPV6 地址显然是2605:6000:ffc0:7d:828:9be:7ce4:637。我想要看到的是 DHCPv6 请求的结果以及所委托的结果前缀(如果有)。

我打开了日志记录systemd-networkd,但从日志来看并不清楚发生了什么

May 02 01:58:02 gateway-v systemd-networkd[405]: ens9: Received remembered route: dst: n/a, src: n/a, gw: 70.122.36.1, prefsrc: 70.122.36.176, scope: global, table: main(254), proto: dhcp, type: unicast, nexthop: 0, priority: 100
May 02 01:58:02 gateway-v systemd-networkd[405]: ens9: link_check_ready(): dhcp4:yes ipv4ll:no dhcp6_addresses:no dhcp6_routes:no dhcp6_pd_addresses:no dhcp6_pd_routes:no ndisc_addresses:no ndisc_routes:no
May 02 01:58:02 gateway-v systemd-networkd[405]: ens9: State changed: configuring -> configured
May 02 01:58:03 gateway-v systemd-networkd[405]: ens9: Remembering foreign address: fe80::213:3bff:fe4a:d9a9/64 (valid forever, preferred forever), flags: permanent
May 02 01:58:03 gateway-v systemd-networkd[405]: ens9: Gained IPv6LL
May 02 01:58:03 gateway-v systemd-networkd[405]: ens9: Discovering IPv6 routers
May 02 01:58:03 gateway-v systemd-networkd[405]: ens9: NDISC: Started IPv6 Router Solicitation client
May 02 01:58:03 gateway-v systemd-networkd[405]: ens9: Remembering foreign route: dst: fe80::213:3bff:fe4a:d9a9/128, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: local(255), proto: kernel, type: local, nexthop: 0, priority: 0
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: NDISC: Sent Router Solicitation, next solicitation in 4s
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: NDISC: Received Router Advertisement: flags MANAGED preference medium lifetime 1800 sec
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: NDISC: Invoking callback for 'router' event.
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Started in Managed mode
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Acquiring DHCPv6 lease on NDisc request
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Requesting route: dst: n/a, src: n/a, gw: fe80::217:10ff:fe86:c7e1, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Requesting route: dst: 2605:6000:c00:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Requesting route: dst: 2605:6000:ffc0:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Requesting route: dst: 2605:6000:400:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Requesting route: dst: 2605:6000:700:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Setting NDisc routes.
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: State changed: configured -> configuring
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: link_check_ready(): dhcp4:yes ipv4ll:no dhcp6_addresses:no dhcp6_routes:no dhcp6_pd_addresses:no dhcp6_pd_routes:no ndisc_addresses:yes ndisc_routes:no
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: State changed: configuring -> configured
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Configuring route: dst: n/a, src: n/a, gw: fe80::217:10ff:fe86:c7e1, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Configuring route: dst: 2605:6000:c00:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Configuring route: dst: 2605:6000:ffc0:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Configuring route: dst: 2605:6000:400:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Configuring route: dst: 2605:6000:700:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Sent SOLICIT
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Next retransmission in 1s
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Received remembered route: dst: n/a, src: n/a, gw: fe80::217:10ff:fe86:c7e1, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Received remembered route: dst: 2605:6000:c00:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Received remembered route: dst: 2605:6000:ffc0:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Received remembered route: dst: 2605:6000:400:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Received remembered route: dst: 2605:6000:700:7d::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main(254), proto: ra, type: unicast, nexthop: 0, priority: 100
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: NDisc routes set.
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Removing old NDisc information obtained from fe80::217:10ff:fe86:c7e1.
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Recv ADVERTISE
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Sent REQUEST
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Next retransmission in 968ms
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: T1 expires in 3d 9h 29min 34s
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: T2 expires in 5d 6h 28min 7s
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 address 2605:6000:ffc0:7d:828:9be:7ce4:637f/128 (valid for 6d 21h 57min 32s, preferred for 6d 21h 57min 32s)
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Requesting address: 2605:6000:ffc0:7d:828:9be:7ce4:637f/128 (valid for 6d 21h 57min 32s, preferred for 6d 21h 57min 32s), flags: no-prefixroute
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Setting DHCPv6 addresses
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: State changed: configured -> configuring
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: link_check_ready(): dhcp4:yes ipv4ll:no dhcp6_addresses:no dhcp6_routes:yes dhcp6_pd_addresses:no dhcp6_pd_routes:no ndisc_addresses:yes ndisc_routes:yes
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: State changed: configuring -> configured
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 client: Recv REPLY
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Configuring address: 2605:6000:ffc0:7d:828:9be:7ce4:637f/128 (valid for 6d 21h 57min 32s, preferred for 6d 21h 57min 32s), flags: no-prefixroute
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: Remembering updated address: 2605:6000:ffc0:7d:828:9be:7ce4:637f/128 (valid for 6d 21h 57min 32s, preferred for 6d 21h 57min 32s), flags: tentative,no-prefixroute
May 02 01:58:04 gateway-v systemd-networkd[405]: ens9: DHCPv6 addresses set
May 02 01:58:05 gateway-v systemd-networkd[405]: ens9: Remembering updated address: 2605:6000:ffc0:7d:828:9be:7ce4:637f/128 (valid for 6d 21h 57min 31s, preferred for 6d 21h 57min 31s), flags: no-prefixroute
May 02 01:58:05 gateway-v systemd-networkd[405]: ens9: Remembering foreign route: dst: 2605:6000:ffc0:7d:828:9be:7ce4:637f/128, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: local(255), proto: kernel, type: local, nexthop: 0, priority: 0
May 02 01:58:15 gateway-v systemd-networkd[405]: ens9: NDISC: No RA received before link confirmation timeout
May 02 01:58:15 gateway-v systemd-networkd[405]: ens9: NDISC: Invoking callback for 'timeout' event.
May 02 01:58:15 gateway-v systemd-networkd[405]: ens9: NDisc handler get timeout event

日志中有一行显示“已收到路由器通告:标志管理首选项中等寿命 1800 秒”,但也有“ens9:NDISC:链接确认超时前未收到 RA”

是否有networkctl命令可以实际显示收到的 IPV6 租约?

答案1

tcpdump -i ens9 -s 0 -n -vv '(udp port 546 or 547) or icmp6' -w /tmp/file.pcap

可能会有帮助

相关内容