解释:
mac1 mac2 mac3 自己替换成需要获取 ipv6 地址的设备 mac ,你可以继续添加按格式添加 mac4 mac5 之类的
如果你要拒绝你设置的 mac 获取 ipv6 地址:
iptables 规则,请把 -m set 后面的 ! 号删掉
nftables 规则,请把 != 删掉
如果你的 lan 口设备不是 br-lan ,你把代码的 br-lan 替换成相应的设备名
iptables 规则:下面的代码放到 防火墙自定义规则 里面
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
nftables: 新建一个 xxx.nft 文件,复制下面代码进去,放到/usr/share/nftables.d/chain-pre/mangle_prerouting/ ,没有目
录就新建,注意 xxx.nft 的换行格式要换成 linux 的,否则会报错。
iifname br-lan meta nfproto ipv6 udp dport 547 ether saddr !={ mac1, mac2, mac3 } counter drop comment
iifname br-lan icmpv6 type { 133-143 } ether saddr !={ mac1, mac2, mac3 } counter drop comment
mac1 mac2 mac3 自己替换成需要获取 ipv6 地址的设备 mac ,你可以继续添加按格式添加 mac4 mac5 之类的
如果你要拒绝你设置的 mac 获取 ipv6 地址:
iptables 规则,请把 -m set 后面的 ! 号删掉
nftables 规则,请把 != 删掉
如果你的 lan 口设备不是 br-lan ,你把代码的 br-lan 替换成相应的设备名
iptables 规则:下面的代码放到 防火墙自定义规则 里面
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
nftables: 新建一个 xxx.nft 文件,复制下面代码进去,放到/usr/share/nftables.d/chain-pre/mangle_prerouting/ ,没有目
录就新建,注意 xxx.nft 的换行格式要换成 linux 的,否则会报错。
iifname br-lan meta nfproto ipv6 udp dport 547 ether saddr !={ mac1, mac2, mac3 } counter drop comment
iifname br-lan icmpv6 type { 133-143 } ether saddr !={ mac1, mac2, mac3 } counter drop comment