以下是相关信息:
Host link IP: fe80::9eec:b32d:855c:5589
Server link IP: fe80::f03c:91ff:fe11:96c4
Host global IP: 2601:aaaa:bbbb:cccc:1854:46d6:c2f9:e727 (Ugh!)
Server global IP: 2601:aaaa:bbbb:cccc::1
服务器已为 2601:aaaa:bbbb:cccc::/64 分配路由块
DHCP试将此 IP 分配给主机:2601:aaaa:bbbb:cccc:1000::fa8d
主机必须是通用的: 主机无需自定义网络配置。所有主机都假定为任何人都有的计算机,只要将其插入,它们就应该可以正常工作而无需任何自定义。这意味着 dhclient 永远不应在 IPv6 客户端上使用:一切都应通过 SLAAC 或有状态 SLAAC 完成(我正在尝试实现这一点)。
主机在浏览器默认使用 IPv6 的情况下运行良好,并且能够毫无问题地访问所有站点,无论是 IPv6 还是 IPv4。
主机网络:
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 28:d2:44:6b:bf:9f brd ff:ff:ff:ff:ff:ff
inet 172.21.0.102/24 brd 172.21.0.255 scope global dynamic noprefixroute enp0s25
valid_lft 39535sec preferred_lft 39535sec
inet6 2601:aaaa:bbbb:cccc:ec25:e54d:4255:6c76/64 scope global temporary dynamic
valid_lft 86199sec preferred_lft 14199sec
inet6 2601:aaaa:bbbb:cccc:1854:46d6:c2f9:e727/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 86199sec preferred_lft 14199sec
inet6 fe80::9eec:b32d:855c:5589/64 scope link noprefixroute
valid_lft forever preferred_lft forever
服务器的radvd配置:
root@li336-239:/var# cat /etc/radvd.conf
interface tap0
{
AdvSendAdvert on;
AdvManagedFlag on;
AdvOtherConfigFlag on;
prefix 2601:aaaa:bbbb:cccc::/64
{
AdvOnLink on;
AdvAutonomous on;
};
};
在全局 IP 分配之前,主机和服务器可以毫无问题地互相看到:
Server: ping6 -c2 fe80::9eec:b32d:855c:5589%tap0 --> Success
Host: ping6 -c2 fe80::f03c:91ff:fe11:96c4%enp0s25 --> Success
主机和服务器通过其链接 IP 和全局 IP 完美地将对方视为邻居:
主机/服务器:ip -6 neigh --> 成功列出所有内容
ip6tables:所有 FORWARD 和 INPUT 链均不受限制:不会丢弃任何数据包
主机物理在线时的 DHCP 服务器:
10:16:39 li336-239 dhcpd[5067]: Solicit message from fe80::9eec:b32d:855c:5589 port 546, transaction ID 0x83D90700
10:16:39 li336-239 dhcpd[5067]: Advertise NA: address 2601:aaaa:bbbb:cccc:1000::fa8d to client with duid 00:01:00:01:22:b0:4f:4a:28:d2:44:6b:bf:9f iaid = 1147912095 valid for 600 seconds
10:16:39 li336-239 dhcpd[5067]: Sending Advertise to fe80::9eec:b32d:855c:5589 port 546
10:16:40 li336-239 dhcpd[5067]: Solicit message from fe80::9eec:b32d:855c:5589 port 546, transaction ID 0x83D90700
10:16:40 li336-239 dhcpd[5067]: Advertise NA: address 2601:aaaa:bbbb:cccc:1000::fa8d to client with duid 00:01:00:01:22:b0:4f:4a:28:d2:44:6b:bf:9f iaid = 1147912095 valid for 600 seconds
10:16:40 li336-239 dhcpd[5067]: Sending Advertise to fe80::9eec:b32d:855c:5589 port 546
10:16:42 li336-239 dhcpd[5067]: Solicit message from fe80::9eec:b32d:855c:5589 port 546, transaction ID 0x83D90700
10:16:42 li336-239 dhcpd[5067]: Advertise NA: address 2601:aaaa:bbbb:cccc:1000::fa8d to client with duid 00:01:00:01:22:b0:4f:4a:28:d2:44:6b:bf:9f iaid = 1147912095 valid for 600 seconds
10:16:42 li336-239 dhcpd[5067]: Sending Advertise to fe80::9eec:b32d:855c:5589 port 546
10:16:46 li336-239 dhcpd[5067]: Solicit message from fe80::9eec:b32d:855c:5589 port 546, transaction ID 0x83D90700
10:16:46 li336-239 dhcpd[5067]: Advertise NA: address 2601:aaaa:bbbb:cccc:1000::fa8d to client with duid 00:01:00:01:22:b0:4f:4a:28:d2:44:6b:bf:9f iaid = 1147912095 valid for 600 seconds
10:16:46 li336-239 dhcpd[5067]: Sending Advertise to fe80::9eec:b32d:855c:5589 port 546
10:16:55 li336-239 dhcpd[5067]: Solicit message from fe80::9eec:b32d:855c:5589 port 546, transaction ID 0x83D90700
10:16:55 li336-239 dhcpd[5067]: Advertise NA: address 2601:aaaa:bbbb:cccc:1000::fa8d to client with duid 00:01:00:01:22:b0:4f:4a:28:d2:44:6b:bf:9f iaid = 1147912095 valid for 600 seconds
10:16:55 li336-239 dhcpd[5067]: Sending Advertise to fe80::9eec:b32d:855c:5589 port 546
10:17:13 li336-239 dhcpd[5067]: Solicit message from fe80::9eec:b32d:855c:5589 port 546, transaction ID 0x83D90700
10:17:13 li336-239 dhcpd[5067]: Advertise NA: address 2601:aaaa:bbbb:cccc:1000::fa8d to client with duid 00:01:00:01:22:b0:4f:4a:28:d2:44:6b:bf:9f iaid = 1147912095 valid for 600 seconds
10:17:13 li336-239 dhcpd[5067]: Sending Advertise to fe80::9eec:b32d:855c:5589 port 546
...但是主机似乎给自己分配了 2601:aaaa:bbbb:cccc:1854:46d6:c2f9:e727 (每次都不同),如果我不想让它有状态的话,这会很棒。
物理连接时托管:
root@some-computer:~# ip monitor
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default
link/ether 28:d2:44:6b:bf:9f brd ff:ff:ff:ff:ff:ff
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default
link/ether 28:d2:44:6b:bf:9f brd ff:ff:ff:ff:ff:ff
Deleted ff02::1:ff5c:5589 dev enp0s25 lladdr 33:33:ff:5c:55:89 NOARP
Deleted ff02::2 dev enp0s25 lladdr 33:33:00:00:00:02 NOARP
Deleted fe80::f03c:91ff:fe11:96c4 dev enp0s25 lladdr f2:3c:91:11:96:c4 router STALE
Deleted ff02::fb dev enp0s25 lladdr 33:33:00:00:00:fb NOARP
Deleted ff02::1:2 dev enp0s25 lladdr 33:33:00:01:00:02 NOARP
Deleted ff02::16 dev enp0s25 lladdr 33:33:00:00:00:16 NOARP
Deleted ff02::1:ff55:6c76 dev enp0s25 lladdr 33:33:ff:55:6c:76 NOARP
Deleted ff02::1:fff9:e727 dev enp0s25 lladdr 33:33:ff:f9:e7:27 NOARP
ff00::/8 dev enp0s25 table local metric 256 pref medium
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default
link/ether 28:d2:44:6b:bf:9f brd ff:ff:ff:ff:ff:ff
Deleted ff00::/8 dev enp0s25 table local metric 256 pref medium
ff00::/8 dev enp0s25 table local metric 256 pref medium
fe80::/64 dev enp0s25 proto kernel metric 256 pref medium
2: enp0s25 inet 172.21.0.102/24 brd 172.21.0.255 scope global dynamic noprefixroute enp0s25
valid_lft 39738sec preferred_lft 39738sec
local 172.21.0.102 dev enp0s25 table local proto kernel scope host src 172.21.0.102
broadcast 172.21.0.255 dev enp0s25 table local proto kernel scope link src 172.21.0.102
broadcast 172.21.0.0 dev enp0s25 table local proto kernel scope link src 172.21.0.102
172.21.0.0/24 dev enp0s25 proto kernel scope link src 172.21.0.102 metric 100
default via 172.21.0.1 dev enp0s25 proto dhcp metric 20100
ipv4 dev enp0s25 rp_filter loose
172.21.0.1 dev enp0s25 lladdr 00:e0:4c:68:3b:72 REACHABLE
169.254.0.0/16 dev enp0s25 scope link metric 1000
10.16.0.1 dev enp0s25 lladdr f2:3c:91:11:96:c4 REACHABLE
2: enp0s25 inet6 fe80::9eec:b32d:855c:5589/64 scope link
valid_lft forever preferred_lft forever
local fe80::9eec:b32d:855c:5589 dev enp0s25 table local proto kernel metric 0 pref medium
2: enp0s25 inet6 fe80::9eec:b32d:855c:5589/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Deleted fe80::/64 dev enp0s25 proto kernel metric 256 pref medium
fe80::/64 dev enp0s25 proto kernel metric 256 pref medium
fe80::/64 dev enp0s25 proto kernel metric 100 pref medium
2: enp0s25 inet 172.21.0.102/24 brd 172.21.0.255 scope global dynamic noprefixroute enp0s25
valid_lft 39736sec preferred_lft 39736sec
default via 172.21.0.1 dev enp0s25 proto dhcp metric 100
Deleted default via 172.21.0.1 dev enp0s25 proto dhcp metric 20100
fe80::f03c:91ff:fe11:96c4 dev enp0s25 lladdr f2:3c:91:11:96:c4 router STALE
2: enp0s25 inet6 fe80::9eec:b32d:855c:5589/64 scope link noprefixroute
valid_lft forever preferred_lft forever
2601:aaaa:bbbb:cccc::/64 dev enp0s25 proto ra metric 100 pref medium
default via fe80::f03c:91ff:fe11:96c4 dev enp0s25 proto ra metric 100 pref medium
[!!HERE--->] 2: enp0s25 inet6 2601:aaaa:bbbb:cccc:ec25:e54d:4255:6c76/64 scope global temporary dynamic
valid_lft 86399sec preferred_lft 14399sec
local 2601:aaaa:bbbb:cccc:ec25:e54d:4255:6c76 dev enp0s25 table local proto kernel metric 0 pref medium
[!!HERE--->] 2: enp0s25 inet6 2601:aaaa:bbbb:cccc:1854:46d6:c2f9:e727/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 86399sec preferred_lft 14399sec
[!!HERE--->] local 2601:aaaa:bbbb:cccc:1854:46d6:c2f9:e727 dev enp0s25 table local proto kernel metric 0 pref medium
答案1
主机似乎将自己分配为 2601:aaaa:bbbb:cccc:1854:46d6:c2f9:e727
您的路由器通告有AdvAutonomous on
,这告诉他们网络支持无状态配置。如果您不想要自主地址自动配置,请不要启用自主地址自动配置。
即使 RA 已配置AdvManaged on
,并且主机收到 DHCPv6 通告,此规则仍然适用。(RFC 4862:“应当注意,主机可以同时使用无状态地址自动配置和 DHCPv6。”)
这意味着 dhclient 绝对不能在 IPv6 客户端上使用:一切都应该通过 SLAAC 或有状态 SLAAC 来完成(我正在尝试实现)。
不存在“有状态的 SLAAC”这样的东西(实际上“SL”代表“无状态”)。
SLAAC 通告最多可以提示客户端使用 DHCPv6,但它们不能力量客户端执行 DHCPv6。例如:
Linux 默认在内核中执行 SLAAC,并且内核将不会自动分叉 DHCP 客户端,既不是
dhclient -6
也不是dhcpcd -6
也不是wide-dhcp6c
。这仅有的如果能够理解该标志的用户空间(例如 NetworkManager 或 systemd-networkd)已在运行,则会发生这种情况。FreeBSD 的
dhclient
基础缺少 DHCPv6 支持;双版本在端口中。OpenBSD 基础中没有 DHCPv6 客户端(必须通过端口安装)。
Android 根本不支持 DHCPv6。
您的客户端似乎正在运行 NetworkManager,但即便如此,也不能保证它不需要手动配置,具体取决于它的版本以及安装了哪个外部 DHCPv6 客户端。(如果dhcp=internal
选择,当前版本仅支持 DHCPv4。)
客户端也有可能仅在自主配置为已禁用(参见答案的第一部分),但最终你会发现缺少 DHCPv6 的客户端无法使用 IPv6。
如果您的目标是实现责任制,我建议您保留 IPv6 地址与 MAC 地址关联的日志。这可以通过监控邻居通告或查看路由器的 ND 缓存 ( ip -6 neigh
) 来实现,其优点是无论使用哪种机制(SLAAC、隐私扩展、DHCPv6、DHCPv4,甚至静态配置的地址都将被跟踪),它都可以正常工作。