Skip to content

Instantly share code, notes, and snippets.

@shibeta
Created August 18, 2024 05:40
Show Gist options
  • Save shibeta/d6ecfc275a4808ea13322821e6005e5e to your computer and use it in GitHub Desktop.
Save shibeta/d6ecfc275a4808ea13322821e6005e5e to your computer and use it in GitHub Desktop.
因为家里的光猫不会自动重新下发ipv6-pd,所以写了一个脚本,当openwrt路由器ipv6路由不可达时自动重启wan6接口
#!/bin/sh
FLAG_FILE="/tmp/ipv6_prefix_change_flag"
FLAG_VALUE=$(cat $FLAG_FILE 2>/dev/null)
if [ "$FLAG_VALUE" = "1" ]; then
logger -t prefix_change "Script is already running. Skipping execution."
exit 0
fi
echo "1" > $FLAG_FILE
IPV6_DEFAULT_ROUTE=$(ip -6 route | grep default 2>/dev/null)
if [ -z "$IPV6_DEFAULT_ROUTE" ] ; then
logger -t prefix_change "IPv6 route missing detected. Reconnecting wan6 interface."
ifdown wan6
ifup wan6
fi
echo "0" > $FLAG_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment