How to restart wan interface when get new public ipv6?

hi,
How to restart wan interface on get new public ipv6 from isp?
i want to restart wan interface when new ipv6 assign by isp after some hours/days.

Wouldn't that lead to continuous WAN restarts ?

No, ISP assign new IP in every some hours or day.
any way?

If the ISP's DHCP doesn't renew the existing lease and supplies a new lease, I would think that you wouldn't need to do anything to reflect the change.

What do you think you need to accomplish by restarting the interface?

1 Like

when new ipv6 assign by isp then another second ipv6 2409:.... add to wan interface and internet stop working. if i restart wan interface then old ipv6 removed and keep only one ipv6, and internet start working.
so, i want to restart interface when wan interface get new ipv6.

[SOLVED] Restart wan6 interface on get more than one ipv6

  1. Login ssh and Run bellow command and hit Enter to create file
    /etc/hotplug.d/iface/07-my-script

    • this file run on update ip adress on wan interface
    cat<<'EOF' > /etc/hotplug.d/iface/07-my-script
    #!/bin/sh
    #########
    ## "$INTERFACE" = "interface name"
    #######
    [ "$ACTION" = "ifupdate" -a "$INTERFACE" = "wan6" ] && {
    #    total_ip=$(($(ip -f inet6 addr show wan | sed -En -e 's/.*inet6 ([0-9a-fA-F:]+).*/\1/p' | grep -v ^fe80 | wc -l) + 0))
        total_ip=$(($(ip -6 addr show dev wan scope global | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | wc -l) + 0))
         echo "Total ip:  $total_ip"
         #
         if [ $total_ip -eq 1 ]
             then
                  echo "OK : Only 1 IP"
         elif [ $total_ip -gt 1 ]
             then
                  echo "More than 1 ip"
                  $(ifup wan6)
                  echo "wan interface restarted"
         elif [ $total_ip -eq 0 ]
             then
                  echo "Zero IP!"
         else
                  echo "Something error!"
         fi
         #
         exit 0
    }
    echo "OK"
    exit 0
    EOF
    
  2. Run bellow command to check script

     sh /etc/hotplug.d/iface/07-my-script
    
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.