树莓派 4B 能获取到公网 ipv6 外网,但同局域网的其它设备却又可以

107 天前
jwj  jwj

目前树莓派和 Windows 电脑都是有线直连光猫,但是树莓派却无法使用 IPv6 访问互联网,很奇怪。 开始以为光猫有问题,但尝试过用 WIFI 连接路由器,同样是手机正常用 IPv6 ,但是树莓派不行。 在此请教各位大佬,看看有没有解决办法。

Windows

Windows 电脑能正常获取到 IPv6 ,也能正常访问:

以太网适配器 以太网:

   连接特定的 DNS 后缀 . . . . . . . :
   IPv6 地址 . . . . . . . . . . . . : 240e:1b1:18b1:4020:3fdf:b377:98ca:a6c0
   临时 IPv6 地址. . . . . . . . . . : 240e:1b1:18b1:4020:2c01:2dbb:7438:2b7
   本地链接 IPv6 地址. . . . . . . . : fe80::104f:45c6:f783:f13d%9
   IPv4 地址 . . . . . . . . . . . . : 192.168.1.5
   子网掩码  . . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . : fe80::1%9
                                       192.168.1.1

请求外网

# curl --ipv6 --max-time 30 -v ip.sb
* Host ip.sb:80 was resolved.
* IPv6: 2606:4700:20::ac43:4bac, 2606:4700:20::681a:d1f, 2606:4700:20::681a:c1f
* IPv4: (none)
*   Trying [2606:4700:20::ac43:4bac]:80...
* Connected to ip.sb (2606:4700:20::ac43:4bac) port 80
> GET / HTTP/1.1
> Host: ip.sb
> User-Agent: curl/8.9.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< Date: Wed, 06 Nov 2024 03:40:46 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< Cache-Control: no-cache
< cf-cache-status: DYNAMIC
< Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=%2BsybXgwsYFeIchZ3GiiiubR5WrfhpNwP8BeFKiJcKvcvnPpA2Z9O2zSmKXO8hv0qdqcCdz8cIiTyk7oqatr7igul%2FYDOHlBArq6yozFKBNSgKBUHOAMMg9DtL1gPjSitVu8T"}],"group":"cf-nel","max_age":604800}
< NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< Server: cloudflare
< CF-RAY: 8de21062ff115986-IAD
< alt-svc: h3=":443"; ma=86400
< server-timing: cfL4;desc="?proto=TCP&rtt=240531&sent=1&recv=3&lost=0&retrans=0&sent_bytes=0&recv_bytes=68&delivery_rate=0&cwnd=250&unsent_bytes=0&cid=0000000000000000&ts=0&x=0"
<
240e:1b1:18b1:4020:2c01:2dbb:7438:2b7

树莓派

有获取到公网 IPv6 ,局域网内能通,就是访问不了外网。

$ nmcli device show
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         DC:A6:32:87:E2:A7
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Wired connection 1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.1.2/24
IP4.GATEWAY:                            192.168.1.1
IP4.ROUTE[1]:                           dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 100
IP4.DNS[1]:                             192.168.1.1
IP4.WINS[1]:                            192.168.1.1
IP6.ADDRESS[1]:                         240e:1b1:18b1:4020:a8f9:a6e4:338a:c432/64
IP6.ADDRESS[2]:                         fe80::5b26:3a6e:e716:e310/64
IP6.GATEWAY:                            fe80::1
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 1024
IP6.ROUTE[2]:                           dst = 240e:1b1:18b1:4020::/64, nh = ::, mt = 100
IP6.ROUTE[3]:                           dst = ::/0, nh = fe80::1, mt = 100
IP6.DNS[1]:                             fe80::1

GENERAL.DEVICE:                         lo
GENERAL.TYPE:                           loopback
GENERAL.HWADDR:                         00:00:00:00:00:00
GENERAL.MTU:                            65536
GENERAL.STATE:                          100 (connected (externally))
GENERAL.CONNECTION:                     lo
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:                            --
IP6.ADDRESS[1]:                         ::1/128
IP6.GATEWAY:                            --

GENERAL.DEVICE:                         wlan0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         DC:A6:32:87:E1:A7
GENERAL.MTU:                            1500
GENERAL.STATE:                          30 (disconnected)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.GATEWAY:                            --
IP6.GATEWAY:                            --

GENERAL.DEVICE:                         p2p-dev-wlan0
GENERAL.TYPE:                           wifi-p2p
GENERAL.HWADDR:                         (unknown)
GENERAL.MTU:                            0
GENERAL.STATE:                          30 (disconnected)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --

访问外网:

$ curl --ipv6 --max-time 30 -v ip.sb
*   Trying [2606:4700:20::681a:c1f]:80...
* ipv6 connect timeout after 14918ms, move on!
*   Trying [2606:4700:20::681a:d1f]:80...
* ipv6 connect timeout after 7459ms, move on!
*   Trying [2606:4700:20::ac43:4bac]:80...
* Connection timed out after 30000 milliseconds
* Closing connection 0
curl: (28) Connection timed out after 30000 milliseconds

路由设置:

$ ip -6 route
240e:1b1:18b1:4020::/64 dev eth0 proto ra metric 100 pref medium
fe80::/64 dev eth0 proto kernel metric 1024 pref medium
default via fe80::1 dev eth0 proto ra metric 100 pref medium

Ping Windows 设备:

$ ping 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432
PING 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432(240e:1b1:18b1:4020:a8f9:a6e4:338a:c432) 56 data bytes
64 bytes from 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432: icmp_seq=1 ttl=64 time=0.137 ms
64 bytes from 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432: icmp_seq=2 ttl=64 time=0.059 ms
64 bytes from 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432: icmp_seq=3 ttl=64 time=0.062 ms
64 bytes from 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432: icmp_seq=4 ttl=64 time=0.057 ms
64 bytes from 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432: icmp_seq=5 ttl=64 time=0.064 ms
64 bytes from 240e:1b1:18b1:4020:a8f9:a6e4:338a:c432: icmp_seq=6 ttl=64 time=0.074 ms
834 次点击
所在节点    BlackBerry
7 条回复
RobinHuuu
107 天前
盲猜是路由问题,看看 windows 的 v6 路由表
jwj
107 天前
@RobinHuuu 大佬,请看
```bash
route print
===========================================================================
接口列表
41...........................Tailscale Tunnel
9...50 eb f6 1e bc f4 ......Intel(R) Ethernet Connection (14) I219-V
5...88 69 99 35 65 73 ......MediaTek Wi-Fi 6/6E Wireless LAN Card
6...1e 7e 51 a1 26 a1 ......Microsoft Wi-Fi Direct Virtual Adapter
11...1e 7e 51 a1 26 b1 ......Microsoft Wi-Fi Direct Virtual Adapter #2
1...........................Software Loopback Interface 1
22...00 15 5d ea 76 60 ......Hyper-V Virtual Ethernet Adapter
31...00 15 5d 50 56 64 ......Hyper-V Virtual Ethernet Adapter #2
===========================================================================

IPv4 路由表
===========================================================================
活动路由:
网络目标 网络掩码 网关 接口 跃点数
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.5 25
100.67.47.125 255.255.255.255 在链路上 100.74.149.85 5
100.73.68.115 255.255.255.255 在链路上 100.74.149.85 5
100.74.149.85 255.255.255.255 在链路上 100.74.149.85 261
100.84.117.118 255.255.255.255 在链路上 100.74.149.85 5
100.100.100.100 255.255.255.255 在链路上 100.74.149.85 5
100.106.45.134 255.255.255.255 在链路上 100.74.149.85 5
100.111.81.26 255.255.255.255 在链路上 100.74.149.85 5
127.0.0.0 255.0.0.0 在链路上 127.0.0.1 331
127.0.0.1 255.255.255.255 在链路上 127.0.0.1 331
127.255.255.255 255.255.255.255 在链路上 127.0.0.1 331
172.24.240.0 255.255.240.0 在链路上 172.24.240.1 5256
172.24.240.1 255.255.255.255 在链路上 172.24.240.1 5256
172.24.255.255 255.255.255.255 在链路上 172.24.240.1 5256
172.26.160.0 255.255.240.0 在链路上 172.26.160.1 5256
172.26.160.1 255.255.255.255 在链路上 172.26.160.1 5256
172.26.175.255 255.255.255.255 在链路上 172.26.160.1 5256
192.168.1.0 255.255.255.0 在链路上 192.168.1.5 281
192.168.1.5 255.255.255.255 在链路上 192.168.1.5 281
192.168.1.255 255.255.255.255 在链路上 192.168.1.5 281
224.0.0.0 240.0.0.0 在链路上 127.0.0.1 331
224.0.0.0 240.0.0.0 在链路上 172.24.240.1 5256
224.0.0.0 240.0.0.0 在链路上 172.26.160.1 5256
224.0.0.0 240.0.0.0 在链路上 192.168.1.5 281
255.255.255.255 255.255.255.255 在链路上 127.0.0.1 331
255.255.255.255 255.255.255.255 在链路上 172.24.240.1 5256
255.255.255.255 255.255.255.255 在链路上 172.26.160.1 5256
255.255.255.255 255.255.255.255 在链路上 192.168.1.5 281
===========================================================================
永久路由:


IPv6 路由表
===========================================================================
活动路由:
接口跃点数网络目标 网关
9 281 ::/0 fe80::1
1 331 ::1/128 在链路上
9 281 240e:1b3:18b1:4020::/64 在链路上
9 281 240e:1b3:18b1:4020:2c01:2dbb:7438:2b7/128
在链路上
9 281 240e:1b3:18b1:4020:3fdf:b377:98ca:a6c0/128
在链路上
41 5 fd7a:115c:a1e0::/48 fd7a:115c:a1e0::53
41 5 fd7a:115c:a1e0::53/128 在链路上
41 261 fd7a:115c:a1e0:ab12:4843:cd96:624a:9555/128
在链路上
22 5256 fe80::/64 在链路上
31 5256 fe80::/64 在链路上
9 281 fe80::/64 在链路上
31 5256 fe80::e38:3721:2531:2104/128
在链路上
9 281 fe80::104f:45c6:f783:f13d/128
在链路上
22 5256 fe80::5d1c:3fbd:8b56:ba58/128
在链路上
1 331 ff00::/8 在链路上
22 5256 ff00::/8 在链路上
31 5256 ff00::/8 在链路上
9 281 ff00::/8 在链路上
===========================================================================
永久路由:

```
RobinHuuu
106 天前
看看派上面的 v6 防火墙设置以及 ip -6 rule show
jwj
106 天前
@RobinHuuu 大佬请看。
$ ip -6 rule show
0: from all lookup local
32766: from all lookup main
RobinHuuu
106 天前
派的 v6 防火墙主要看 mangle 表和 nat 表
jwj
102 天前
重新安装了个 OpenWrt 系统,也是 IPv6 无法上网,但是 IPv4 能。
之前的 Debian 没有安装 iptables 、ufw 和 firewalld ,大概可以理解为防火墙并没有启用?
然后 OpenWrt 的防火墙出站也是默认放通的,那大概率能排除防火墙问题?
jwj
77 天前
把光猫(Route) -> 树莓派,换成光猫(bridge) -> 路由器(PPPOE) -> 树莓派,树莓派能正常上网了。所以可能是树莓派系统不够完善,或光猫不够完善?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1087098

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX