文章

运营商不下发ipv6前缀的地区,通过OpenWrt热插拔特性,自动下发前缀

运营商不下发IPv6前缀的地区,通过openwrt热插拔特性,可自动下发前缀,亲测有效。

1
2
3
4
5
6
7
8
vim /etc/hotplug.d/iface/99-ipv6

#!/bin/sh
[ "$ACTION" = ifup ] || exit 0
[ "$INTERFACE" = wan_6 ] || exit 0
uci set network.globals.ula_prefix="$(ip -6 route show | grep default | sed -e 's/^.*from //g' | sed 's/ via.*$//g')"
uci commit network
/sbin/ifup lan

也可以在系统-启动项-本地启动脚本exit 0之前加入以下代码

1
2
3
4
5
6
7
8
cat > /etc/hotplug.d/iface/99-ipv6 <<EOF
#!/bin/sh
[ "\$ACTION" = ifup ] || exit 0
[ "\$INTERFACE" = wan_6 ] || exit 0
uci set network.globals.ula_prefix="\$(ip -6 route show | grep default | sed 's/^.*from //g' | sed 's/ via.*$//g')"
uci commit network
/sbin/ifup lan
EOF
本文由作者按照 CC BY 4.0 进行授权