移动光猫允许IPv6入站解决方案

起因是我有使用IPv6远程访问家庭设备的需求,但又不想改桥接,光猫也支持IPv6,问题是局域网内可以使用V6地址访问软路由,但切到移动数据后却不可访问,在AI和Google的帮助下成功探索出了解决方案(看来群里说的与Google合作是真的),便有此文以记录。

我家的网络拓扑:光猫拨号,下面接r2s,硬路由改AP

首先我以为是软路由的问题,在软路由侧开启IPv6后问题依旧。

接着我进入光猫后台查看IPv6连接情况发现是可以获取到IP地址的,配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
连接名称  
5_INTERNET_R_VID_2001
模式
上网
IP获取方式
SLAAC
IP地址
2409:xxxx:xxx:xxx:xxx:xxxx:fe16:39a8/64
网关
fe80::fa75:xxxx:xxxx:60
WAN MAC
xx:xx:xx:xx:xx:xx
前缀获取方式
DHCPv6
获取前缀
2409:8a50:xxx:xxx::/60
DNS获取方式
DHCPv6
DNS1
2409:8050:2000:1000::1
DNS2
2409:8050:2000::1
连接状态
已连接
--
在线时长
4天8时29分

全局地址获取方式
SLAAC
网关获取方式
SLAAC
DNS获取方式
DHCPv6
前缀获取方式
DHCPv6

于是我询问ChatGPT,提示我需要开启IPv6透明代理/RA/ND转发,但开启后问题依旧没有解决

1
2
3
4
5
6
7
8
9
IP地址
fe80:1/64
DNS获取方式 HGWProxy
前缀配置方式WANConnection 广域网连接 5_INTERNET_R_VID_2001
RA使能√
RA配置
M√ O√ DHCPv6使能√
起始IP地址∷2(后64位有效)
结束IP地址 :255(后64位有效)

既然软路由侧没有问题,光猫配置也没有错误,那就是光猫背后在不为人知的地方动了手脚。

于是我参考网上的资料开启光猫的telnet,拿到root权限,查看防火墙规则列表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/ # ip6tables -nvL --line-number
Chain INPUT (policy ACCEPT 29295 packets, 2535K bytes)
num pkts bytes target prot opt in out source destination
1 42564 4524K fwports all * * ::/0 ::/0
2 42564 4524K firewall all * * ::/0 ::/0
3 29298 2536K srvdrop all * * ::/0 ::/0
4 29298 2536K srvctlext all * * ::/0 ::/0
5 29298 2536K devaccrt all * * ::/0 ::/0

Chain FORWARD (policy ACCEPT 387K packets, 71M bytes)
num pkts bytes target prot opt in out source destination
1 768K 239M webfilter all * * ::/0 ::/0
2 768K 239M wfmode all * * ::/0 ::/0
3 768K 239M macfilter all * * ::/0 ::/0
4 768K 239M firewall all * * ::/0 ::/0
5 387K 71M algfilter all * * ::/0 ::/0
6 387K 71M portmapp all * * ::/0 ::/0
7 387K 71M url_redir all * * ::/0 ::/0
8 387K 71M ACCRT_L3_FORWARD all * * ::/0 ::/0

Chain OUTPUT (policy ACCEPT 61684 packets, 7635K bytes)
num pkts bytes target prot opt in out source destination

Chain ACCRT_L3_FORWARD (1 references)
num pkts bytes target prot opt in out source destination

Chain algfilter (1 references)
num pkts bytes target prot opt in out source destination

Chain devaccrt (1 references)
num pkts bytes target prot opt in out source destination

Chain firewall (2 references)
num pkts bytes target prot opt in out source destination
1 367K 168M ACCEPT all * * ::/0 ::/0 DEVWL match:WANDEV
state RELATED,ESTABLISHED
2 10 1665 ACCEPT udp * * ::/0 ::/0 udp dpt:546 DEVWL match:WANDEV

3 644 59489 ACCEPT icmpv6 * * ::/0 ::/0 DEVWL match:WANDEV

4 0 0 ACCEPT icmpv6 * * ::/0 ::/0 ipv6-icmptype 128 DEVWL match:WANDEV

5 26989 2850K DROP all * * ::/0 ::/0 DEVWL match:WANDEV


Chain fwports (1 references)
num pkts bytes target prot opt in out source destination

Chain macfilter (1 references)
num pkts bytes target prot opt in out source destination

Chain portmapp (1 references)
num pkts bytes target prot opt in out source destination

Chain srvctlext (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 REJECT udp * * ::/0 ::/0 udp dpt:547 DEVWL match:WANDEV
reject-with icmp6-port-unreachable
2 0 0 REJECT udp * * ::/0 ::/0 udp dpt:546 DEVWL match:LANDEV
reject-with icmp6-port-unreachable

Chain srvdrop (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 REJECT tcp * * ::/0 ::/0 tcp dpt:80 DEVWL match:WANDEV
reject-with tcp-reset

Chain url_redir (1 references)
num pkts bytes target prot opt in out source destination

Chain webfilter (1 references)
num pkts bytes target prot opt in out source destination

Chain wfmode (1 references)
num pkts bytes target prot opt in out source destination

我看到了可疑之处

1
5    26989 2850K DROP       all      *      *       ::/0                 ::/0                 DEVWL match:WANDEV

问了下GPT:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
规则 1–4 允许:

已建立的连接(RELATED,ESTABLISHED)

DHCPv6 响应 (UDP 546)

ICMPv6(必要的控制包,如 ping、邻居发现响应等)

规则 5 则 丢弃了所有新连接(NEW),包括你试图从公网访问的 TCP 新连接(例如 TCP 5244)。

这意味着当前光猫防火墙确实禁止任何 新的 IPv6 入站连接(NEW):

✅ 可以接收已有连接/响应包、ping,但无法建立 TCP/UDP 新连接。

那么删除那条丢弃连接的规则就行了。

执行ip6tables -D firewall 5即可(各位具体情况具体分析,不一定都是第五条)

参考资料:

https://www.right.com.cn/forum/forum.php?mod=viewthread&tid=8408984

https://www.right.com.cn/forum/thread-8282065-1-1.html

https://www.022y.cn/?id=51