我正在尝试使用 Raspberry Pi Zero 2 W 作为具有基于 debian 的操作系统的 IPV6 路由器。我有一个面向 wan 的 usb wifi 适配器(接口 Wlan1)。内置 wifi(Wlan0)面向 LAN,hostapd 在此接口上运行。我对 IPV4 没有任何问题,一切正常。LAN 客户端获得 IPV4 地址。但系统无法向 LAN 客户端提供 IPV6 地址。
对我来说,问题似乎出在 dhcpcd 设置上,因为 pi 收到带有 ipv6 前缀的路由器通告并将 IPV6 地址分配给 wlan1,但没有为 wlan0(LAN 接口)分配任何 IPV6 地址。
这是我的 dhcpcd.conf:
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
slaac private
debug
logfile /home/pi/dhcpcd.log
noipv6rs
waitip 6
interface wlan1
option rapid_commit
ipv6rs
ia_na 0
ia_pd 1 wlan0/0
interface wlan0
nohook wpa_supplicant
nogateway
static ip_address=10.10.0.1/24
static routers=10.10.0.0
static domain_name_servers=8.8.4.4 8.8.8.8
hostapd.conf
interface=wlan0
driver=nl80211
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ssid=*******
wpa_passphrase=*******
dnsmasq配置文件
interface=wlan0 # Use interface wlan1
listen-address=10.10.0.1 # Specify the address to listen on
#bind-interfaces # Bind to the interface
server=8.8.8.8 # Use Google DNS
domain-needed # Don't forward short names
bogus-priv # Drop the non-routed address spaces.
dhcp-range=10.10.0.50,10.10.0.150,12h # IP range and lease time
对我来说,问题似乎出在 dhcpcd 设置上,因为 pi 收到带有 ipv6 前缀的路由器通告并将 IPV6 地址分配给 wlan1,但没有为 wlan0(LAN 接口)分配任何 IPV6 地址。这是 dhcpcd 日志:
Jan 31 14:17:46 [1439]: dhcpcd-8.1.2 starting
Jan 31 14:17:46 [1439]: udev: starting
Jan 31 14:17:46 [1439]: dev: loaded udev
Jan 31 14:17:46 [1439]: wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT
Jan 31 14:17:46 [1439]: wlan0: connected to Access Point `'
Jan 31 14:17:46 [1439]: wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER
Jan 31 14:17:46 [1439]: wlan1: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT
Jan 31 14:17:46 [1439]: wlan1: connected to Access Point `'
Jan 31 14:17:46 [1439]: wlan1: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER
Jan 31 14:17:46 [1439]: DUID 00:01:00:01:2d:01:4e:61:d8:3a:dd:65:09:0b
Jan 31 14:17:46 [1439]: wlan0: IAID dd:65:09:0b
Jan 31 14:17:46 [1439]: wlan0: using ClientID 01:d8:3a:dd:65:09:0b
Jan 31 14:17:46 [1439]: wlan0: using static address 10.10.0.1/24
Jan 31 14:17:46 [1439]: wlan0: adding IP address 10.10.0.1/24 broadcast 10.10.0.255
Jan 31 14:17:46 [1439]: wlan0: adding route to 10.10.0.0/24
Jan 31 14:17:47 [1439]: wlan0: ARP announcing 10.10.0.1 (1 of 2), next in 2.0 seconds
Jan 31 14:17:47 [1439]: wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' STATIC
Jan 31 14:17:47 [1439]: waiting for an IPv6 address
Jan 31 14:17:47 [1439]: wlan1: waiting for carrier
Jan 31 14:17:49 [1439]: wlan0: ARP announcing 10.10.0.1 (2 of 2)
Jan 31 14:17:49 [1439]: wlan1: carrier acquired
Jan 31 14:17:49 [1439]: wlan1: connected to Access Point `XXXXXX'
Jan 31 14:17:49 [1439]: wlan1: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER
Jan 31 14:17:49 [1439]: wlan1: IAID 24:8f:8d:b2
Jan 31 14:17:49 [1439]: wlan1: IA type 3 IAID 00:00:00:00
Jan 31 14:17:49 [1439]: wlan1: IA type 25 IAID 00:00:00:01
Jan 31 14:17:49 [1439]: wlan1: adding address fe80::5fd5:83b1:4372:ecbb
Jan 31 14:17:49 [1439]: wlan1: pltime infinity, vltime infinity
Jan 31 14:17:49 [1439]: wlan1: delaying IPv6 router solicitation for 0.7 seconds
Jan 31 14:17:49 [1439]: wlan1: delaying DHCPv6 soliciation for LL address
Jan 31 14:17:49 [1439]: wlan1: delaying IPv4 for 0.5 seconds
Jan 31 14:17:50 [1439]: wlan1: using ClientID 01:00:e0:24:8f:8d:b2
Jan 31 14:17:50 [1439]: wlan1: reading lease `/var/lib/dhcpcd/wlan1-XXXXXX.lease'
Jan 31 14:17:50 [1439]: wlan1: rebinding lease of 192.168.191.210
Jan 31 14:17:50 [1439]: wlan1: ARP announcing 192.168.191.210 (1 of 2), next in 2.0 seconds
Jan 31 14:17:50 [1439]: wlan1: sending REQUEST (xid 0x302bcf59), next in 3.8 seconds
Jan 31 14:17:50 [1439]: wlan1: acknowledged 192.168.191.210 from 192.168.191.185
Jan 31 14:17:50 [1439]: wlan1: leased 192.168.191.210 for 3600 seconds
Jan 31 14:17:50 [1439]: wlan1: renew in 1800 seconds, rebind in 3150 seconds
Jan 31 14:17:50 [1439]: wlan1: writing lease `/var/lib/dhcpcd/wlan1-XXXXXX.lease'
Jan 31 14:17:50 [1439]: wlan1: adding IP address 192.168.191.210/24 broadcast 192.168.191.255
Jan 31 14:17:50 [1439]: wlan1: adding route to 192.168.191.0/24
Jan 31 14:17:50 [1439]: wlan1: adding default route via 192.168.191.185
Jan 31 14:17:50 [1439]: wlan1: ARP announcing 192.168.191.210 (1 of 2), next in 2.0 seconds
Jan 31 14:17:50 [1439]: wlan1: executing `/lib/dhcpcd/dhcpcd-run-hooks' REBOOT
Jan 31 14:17:50 [1439]: waiting for an IPv6 address
Jan 31 14:17:50 [1439]: wlan1: soliciting an IPv6 router
Jan 31 14:17:50 [1439]: wlan1: delaying Router Solicitation for LL address
Jan 31 14:17:50 [1439]: wlan1: bound, ignoring 192.168.191.210 from 192.168.191.185
Jan 31 14:17:52 [1439]: wlan1: ARP announcing 192.168.191.210 (2 of 2)
Jan 31 14:18:00 [1439]: wlan1: reading lease `/var/lib/dhcpcd/wlan1-XXXXXX.lease6'
Jan 31 14:18:00 [1439]: wlan1: soliciting a DHCPv6 lease
Jan 31 14:18:00 [1439]: wlan1: delaying SOLICIT6 (xid 0x90602f), next in 0.3 seconds
Jan 31 14:18:00 [1439]: wlan1: sending Router Solicitation
Jan 31 14:18:00 [1439]: wlan1: Router Advertisement from fe80::947c:b8ff:fe17:80
Jan 31 14:18:00 [1439]: wlan1: adding address 2409:XXXX:XXXX:343e:92c3:fe06:2398:8026/64
Jan 31 14:18:00 [1439]: wlan1: pltime 3600 seconds, vltime 3600 seconds
Jan 31 14:18:00 [1439]: wlan1: adding route to 2409:XXXX:XXXX:343e::/64
Jan 31 14:18:00 [1439]: wlan1: adding default route via fe80::947c:b8ff:fe17:80
Jan 31 14:18:00 [1439]: wlan1: waiting for Router Advertisement DAD to complete
Jan 31 14:18:00 [1439]: wlan1: No DHCPv6 instruction in RA
Jan 31 14:18:00 [1439]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 0.9 seconds
Jan 31 14:18:01 [1439]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 1.8 seconds
Jan 31 14:18:02 [1439]: wlan1: Router Advertisement from fe80::947c:b8ff:fe17:80
Jan 31 14:18:02 [1439]: wlan1: adding address 2409:XXXX:XXXX:343e:92c3:fe06:2398:8026/64
Jan 31 14:18:02 [1439]: wlan1: pltime 3600 seconds, vltime 3600 seconds
Jan 31 14:18:02 [1439]: wlan1: waiting for Router Advertisement DAD to complete
Jan 31 14:18:02 [1439]: wlan1: No DHCPv6 instruction in RA
Jan 31 14:18:03 [1439]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 3.7 seconds
Jan 31 14:18:07 [1439]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 7.1 seconds
Jan 31 14:18:11 [1439]: wlan1: Router Advertisement DAD completed
Jan 31 14:18:11 [1439]: wlan1: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jan 31 14:18:11 [1439]: forking to background
Jan 31 14:18:11 [1493]: wlan1: sending NA for 2409:XXXX:XXXX:343e:92c3:fe06:2398:8026/64
Jan 31 14:18:11 [1439]: forked to background, child pid 1493
Jan 31 14:18:12 [1493]: wlan1: sending NA for 2409:XXXX:XXXX:343e:92c3:fe06:2398:8026/64
Jan 31 14:18:13 [1493]: wlan1: sending NA for 2409:XXXX:XXXX:343e:92c3:fe06:2398:8026/64
Jan 31 14:18:14 [1493]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 14.0 seconds
Jan 31 14:18:28 [1493]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 27.7 seconds
Jan 31 14:18:55 [1493]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 55.2 seconds
Jan 31 14:19:51 [1493]: wlan1: broadcasting SOLICIT6 (xid 0x90602f), next in 109.9 seconds
这里是 wlan1 接收到的路由器通告的 tcpdump (sudo tcpdump -vvvv -ttt -i wlan1 icmp6 and 'ip6[40] = 134' ):
hop limit 63, Flags [none], pref high, router lifetime 3600s, reachable time 0ms, retrans timer 0ms
source link-address option (1), length 8 (1): 96:7c:b8:17:00:80
0x0000: 967c b817 0080
mtu option (5), length 8 (1): 1500
0x0000: 0000 0000 05dc
prefix info option (3), length 32 (4): 2409:XXXX:XXXX:343e::/64, Flags [onlink, auto], valid time 3600s, pref. time 3600s
0x0000: 40c0 0000 0e10 0000 0e10 0000 0000 2409
0x0010: 4052 8e17 343e 0000 0000 0000 0000
rdnss option (25), length 24 (3): lifetime 3600s, addr: 2409:XXXX:XXXX:343e::86
0x0000: 0000 0000 0e10 2409 4052 8e17 343e 0000
0x0010: 0000 0000 0086
00:00:02.443370 IP6 (flowlabel 0x9275e, hlim 255, next-header ICMPv6 (58) payload length: 88) fe80::947c:b8ff:fe17:80 > ip6-allnodes: [icmp6 sum ok] ICMP6, router advertisement, length 88
hop limit 63, Flags [none], pref high, router lifetime 3600s, reachable time 0ms, retrans timer 0ms
source link-address option (1), length 8 (1): 96:7c:b8:17:00:80
0x0000: 967c b817 0080
mtu option (5), length 8 (1): 1500
0x0000: 0000 0000 05dc
prefix info option (3), length 32 (4): 2409:XXXX:XXXX:343e::/64, Flags [onlink, auto], valid time 3600s, pref. time 3600s
0x0000: 40c0 0000 0e10 0000 0e10 0000 0000 2409
0x0010: 4052 8e17 343e 0000 0000 0000 0000
rdnss option (25), length 24 (3): lifetime 3600s, addr: 2409:XXXX:XXXX:343e::86
0x0000: 0000 0000 0e10 2409 4052 8e17 343e 0000
0x0010: 0000 0000 0086
请帮忙 。
答案1
确保已radvd
安装二进制文件,例如通过运行which radvd
获取非空字符串,如/usr/bin/radvd
。根据需要安装它。
尝试手动添加所需的地址(wlan0 是面向 LAN 的接口,将 IP 改回您在 tcpdump 中看到的 IP,不要忘记1
冒号后面的)。此命令需要在每次启动时运行:
echo 0 > /proc/sys/net/ipv6/conf/wlan0/accept_ra
echo 0 > /proc/sys/net/ipv6/conf/wlan0/accept_dad
ip addr add 2409:XXXX:XXXX:343e::1/64 dev wlan0
(以 开头的几行echo
提供了基本的强化措施,以防止配置错误的客户端将您的路由器从网络中踢出。)
然后删除尝试配置以使 DHCPv6 暂时工作,并首先使 radvd 工作。即使您最终部署了 DHCPv6,您仍然需要 radvd,因此请限制出错的可能性。radvd.conf
使用此内容创建并运行它radvd -C /etc/radvd.conf start
:
interface wlan0 {
MinRtrAdvInterval 3;
MaxRtrAdvInterval 4;
AdvLinkMTU 1500;
AdvSendAdvert on;
MinDelayBetweenRAs 3;
prefix 2409:XXXX:XXXX:343e::/64 {
AdvOnLink on;
AdvAutonomous on;
AdvValidLifetime 86400;
AdvPreferredLifetime 86400;
};
RDNSS 2409:XXXX:XXXX:343e::1 {
AdvRDNSSLifetime 86400;
};
DNSSL local {
FlushDNSSL on;
};
};
将2409:XXXX:XXXX:343e::
和更改wlan0
为您的实际值,可选择自定义local
为不同于任何 TLD 的词;流行的选择包括lan
和home
。
首先尝试从路由器后面的客户端访问 IPv6 内容 - 路由器本身无法使用 IPv6 连接而用户可以使用,这是一个常见问题。这是当 WAN IP 不公开时发生的。要解决此问题,您需要告诉路由器对所有传出连接使用 LAN IP。有几种配置方法,每种方法都适用于不同的发行版子集。我的是ip -6 route replace default via <GATEWAY> dev <WAN_IF> src <LAN_IPv6>
。所以谷歌一下看看。不过,最后一条建议 - IPv6 地址的分配和更改传出 IP 的可能性之间似乎存在竞争条件;我只是sleep 2
在它们之间使用。