#!/bin/shINT="em0"FILE="/tmp/oldWanIp"if [ -f "$FILE" ]; then oldIP=`cat "$FILE"`else oldIP=""finewIP=`ifconfig "$INT" | grep -v deprecated | awk '/inet6 2001/{print $2}'`echo "Old IP: $oldIP"echo "New IP: $newIP"if [ "$oldIP" != "$newIP" ]; then echo "reload WAN interface" /usr/local/sbin/configctl interface linkup stop "$INT" /usr/local/sbin/configctl interface reconfigure "$INT" /usr/local/sbin/configctl interface linkup start "$INT" echo "$newIP" > "$FILE"fi
#!/bin/shwan_ip="$(ifconfig igb0 | grep inet6 | grep 2003 | grep -v deprecated | awk '{print $2}')"lan_ip="$(ifconfig igb1 | grep inet6 | grep 2003 | grep -v deprecated | awk '{print $2}')"#check if tmpfile existsif [ ! -f "/tmp/v6addr" ]; then ifconfig igb0 | grep inet6 | grep 2003 | grep -v deprecated | awk '{print $2}' >/tmp/v6addr ; fiold_ip="$(cat /tmp/v6addr)"[ -z $old_ip ] && old_ip="-"if [ $wan_ip != $old_ip ]then echo "ip changed!!" >> /tmp/v6addr.log /usr/local/sbin/configctl interface reconfigure && ifconfig igb0 | grep inet6 | grep 2003 | grep -v deprecated | awk '{print $2}' >/tmp/v6addr && sleep 3 && pkill -9 unbound && pluginctl dnselse echo "ip did not change" >>/tmp/v6addr.log exit 0fi
Edit: Seems to work
#!/bin/sh## checkwanipv6.sh# # Script for checking WAN IPv6 changes.# E.g. Updated prefix after PPPoE reconnect or simply prefix renew# Interface name like igc1, igb1 etc.INTERFACE="pppoe0"FILE="/tmp/wanipv6.old"# Get current WAN IPv6 address. Ignore APIPA and ULA.wanipv6=`ifconfig "$INTERFACE" | grep inet6 | grep -v '[[:space:]]fe80:\|[[:space:]]fd31:' | grep -v '\%' | grep -v deprecated | awk '{print $2}'`# Ensure that wanipv6.old exists. Otherwise create with current WAN IPv6 entry.if [ ! -f "$FILE" ]; then echo "$wanipv6" > "$FILE"fi# Get old WAN IPv6 address from file.wanipv6old=`cat "$FILE"`echo "Old WAN IPv6: $wanipv6old"echo "New WAN IPv6: $wanipv6"if [ "$wanipv6old" != "$wanipv6" ]; then echo "WAN IPv6 address has changed. Reload WAN interface." /usr/local/sbin/configctl interface linkup stop "$INTERFACE" /usr/local/sbin/configctl interface reconfigure "$INTERFACE" /usr/local/sbin/configctl interface linkup start "$INTERFACE" echo "$wanipv6" > "$FILE"fi
#!/bin/sh## checkwanipv6.sh# # Script for checking WAN IPv6 changes.# E.g. Updated prefix after PPPoE reconnect or simply prefix renew.# Interface name like pppoe0, igc1, igb1 etc.WAN_INTERFACE="pppoe0"LAN_INTERFACE="igc0"WANFILE="/tmp/wanipv6.old"LANFILE="/tmp/lanipv6.old"# Get current WAN IPv6 address. Ignore APIPA and ULA.wanipv6=`ifconfig "$WAN_INTERFACE" | grep inet6 | grep -v '[[:space:]]fe80:\|[[:space:]]fd31:' | grep -v '\%' | grep -v deprecated | awk '{print $2}'`lanipv6=`ifconfig "$LAN_INTERFACE" | grep inet6 | grep -v '[[:space:]]fe80:\|[[:space:]]fd31:' | grep -v '\%' | grep -v deprecated | awk '{print $2}'`# Ensure that wanipv6.old exists. Otherwise create with current WAN IPv6 entry.if [ ! -f "$WANFILE" ]; then echo "$wanipv6" > "$WANFILE"fi# Ensure that lanipv6.old exists. Otherwise create with current LAN IPv6 entry.if [ ! -f "$LANFILE" ]; then echo "$lanipv6" > "$LANFILE"fi# Get old WAN and LAN IPv6 addresses from file.wanipv6old=`cat "$WANFILE"`lanipv6old=`cat "$LANFILE"`echo "Old WAN IPv6: $wanipv6old"echo "New WAN IPv6: $wanipv6"echo "Old LAN IPv6: $lanipv6old"echo "New LAN IPv6: $lanipv6"# Reload WAN interface as LAN IPv6 address seems to be stuck or empty after WAN IPv6 change.if [ "$wanipv6old" != "$wanipv6" ] && [ "$lanipv6old" == "$lanipv6" ]; then echo "WAN IPv6 address has changed while LAN IPv6 address seems to be stuck. Reload WAN interface." /usr/local/sbin/configctl interface linkup stop "$WAN_INTERFACE" /usr/local/sbin/configctl interface reconfigure "$WAN_INTERFACE" /usr/local/sbin/configctl interface linkup start "$WAN_INTERFACE"elif [ "$wanipv6old" != "$wanipv6" ] && [ "$lanipv6" == "" ] && [ "$lanipv6old" != "" ]; then echo "WAN IPv6 address has changed while LAN IPv6 address seems to be empty. Reload WAN interface." /usr/local/sbin/configctl interface linkup stop "$WAN_INTERFACE" /usr/local/sbin/configctl interface reconfigure "$WAN_INTERFACE" /usr/local/sbin/configctl interface linkup start "$WAN_INTERFACE"fi# Save current (empty) IPv6 addresses to file.echo "$wanipv6" > "$WANFILE"echo "$lanipv6" > "$LANFILE"
# opnsense-patch 05c6f2e
# opnsense-revert -z dhcp6c