IPv6 NAT

只有在一些特殊的场景下,比如在校园网环境中,才需要IPv6 NAT。通过以下步骤来启用:

opkg install ip6tables kmod-ipt-nat6 kmod-ip6tables kmod-ip6tables-extra luci-proto-ipv6 iputils-traceroute6

首先要设置IPv6 Global ULA Prefix。 可以使用ULA Generator获取一个以fd开头的地址,并将开头的fd改为dd,即修改为RFC协议中规定的Reserved地址段。

定义/etc/hotplug.d/iface/90-ipv6,以便在IPv6端口上线时自动设置路由表:

#!/bin/sh
[ "$ACTION" = ifup ] || exit 0

[ "$INTERFACE" = wan6 ] && {
    route -A inet6 add 2000::/3 gw $(route -A inet6 | grep ::/0 | grep eth0.2 |  awk '{print $2}') dev $(uci -q get network.wan6.ifname)
}

并在Luci/cgi-bin/luci/admin/network/firewall/custom中定义防火墙规则:

# Set up IPv6 routing.
WAN6=eth0.2
LAN=br-lan
ip6tables -t nat -A POSTROUTING -o $WAN6 -j MASQUERADE
ip6tables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
ip6tables -A FORWARD -i $LAN -j ACCEPT

参考链接: