openwrt 如何只让内网中指定的设备才能获取到 slaac ipv6

197 天前
 mikususu33

如题,不想给内网设备有公网 ipv6 地址,但是部分设备又需要 我知道可以批量关闭其他所有设备的 ipv6 选项(太麻烦了

609 次点击
所在节点    OpenWrt
8 条回复
a90405
197 天前
# 下面的代码中 mac1 mac2 mac3 是你想获得 ipv6 地址的客户端的 mac 地址,自己换上就行了,想更多加个,号继续填就行了

nft insert rule inet fw4 mangle_prerouting meta nfproto ipv6 udp dport 547 ether saddr !={ mac1, mac2, mac3 } counter drop comment \" 阻止 dhcpv6 \"

nft insert rule inet fw4 mangle_prerouting icmpv6 type { 133-143 } ether saddr !={ mac1, mac2, mac3 } counter drop comment \" 阻止 slaac \"
mikususu33
197 天前
@a90405 大佬牛逼,可以提供 ip6tables 版本的吗
a90405
197 天前
@mikususu33

ipset create ipv6macs hash:mac
ipset add ipv6macs mac1
ipset add ipv6macs mac2
ipset add ipv6macs mac3

ip6tables -I input_lan_rule -p ipv6-icmp -m set ! --match-set ipv6macs src -j DROP
ip6tables -I input_lan_rule -p udp --dport 547 -m set ! --match-set ipv6macs src -j DROP

没有环境,没测试过,你试试
mikususu33
197 天前
@a90405 使用了这个之后,依旧所有设备正常获取 ipv6 地址,只是只有指定设备才可以联网,请问有办法让其他设备不获取到 ipv6 地址吗
a90405
196 天前
@mikususu33
ipset create ipv6macs hash:mac
ipset add ipv6macs mac1
ipset add ipv6macs mac2
ipset add ipv6macs mac3

ip6tables -t mangle -I PREROUTING -i br-lan -p ipv6-icmp -m set ! --match-set ipv6macs src -j DROP
ip6tables -t mangle -I PREROUTING -i br-lan -p udp --dport 547 -m set ! --match-set ipv6macs src -j DROP

刚特地下了个 lean 版本的测试了,上面的防火墙规则,确保可行,把上面的代码,复制到 自定义防火墙规则 里面,mac 1 mac2 mac3 替换成需要获取 ipv6 的机器。
a90405
196 天前
@mikususu33
-i br-lan 这里,如果你的局域网接口不是 br-lan 这个设备,请自己替换 br-lan 为指定的接口。
mikususu33
192 天前
@a90405 其他设备还是可以正常获取 ipv6,只是 v6 不能联网,还是干扰了内网,这个有办法吗
a90405
192 天前

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

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

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

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

© 2021 V2EX