.ipk for log public ip change is needed

Hello everyone, I have a dynamic public ip and I need an .apk that keeps track of it every time it changes. As did banip which also memorized the date and time of the change but which now does more. Thank you.

script it ?

poll any random whatsmyip site every X hr/min/sec, and do whatever you need to do, once there's a change.

1 Like

I would use /etc/udhcpc.user to monitor the udhcpc events.

# /etc/udhcpc.user

[ "${INTERFACE}" = "wan" -a -n "${ip}" ] || exit 0
last_IP=/etc/lastIP.txt

   if [ -f "$last_IP" ]; then
         last_known_IP=$(cat $last_IP)
        else
         echo "$ip" > "$last_IP"
   fi
   if [ "$ip" == "$last_known_IP" ]; then
         exit 0
        else
      logger -t IPchange "wan IP changed to: $ip"
      echo "$ip" > "$last_IP"
   fi
exit 0

The only reason not to save the last known wan IP address in the tmp directory is that it may change when the router reboots.

1 Like

Yes, it can be the reboot but previously it saved it anyway. Unless it depends on the log level. This I have to ask the specific tread.I checked and save only the last public ip.

…and actually this is already logged to syslog by default, without having to change anything.

1 Like