Alert if Public IP address changes

I wrote this flow to send me a push message (could be twitter, email, etc) if my home IP address changes.

My ISP issues dynamic IP addresses, so occasionally my broadband would encounter a problem, and a new IP address would be issued which triggers an alert, giving me the new IP address where I can access my home network (I must get a domain!!).

It can also give an indication of router/line problems, if the IP address changes too frequently.

The flow needs little explanation, it obtains your current public IP address via but there are other services available - and and passes the result through a 'switch' node programmed only to accept data in the format of a IP address - regex validity check (thanks Nick). The IP address is then compared to the previous recorded IP address, and if they differ - then an alert is raised, otherwise the flow ends.

[{"id":"f3296a2a.0cd698","type":"inject","name":"Get IP","topic":"ip","payload":"eth0","payloadType":"none","repeat":"300","crontab":"","once":false,"x":82,"y":556.5,"z":"4487e413.bb781c","wires":[["b58a9192.4a757"]]},{"id":"c1c8efe9.3e371","type":"function","name":"Compare IP","func":"context.lastip = context.lastip || 'initial';\nvar currentip = msg.payload;\n\nif (context.lastip == 'initial') {\ncontext.lastip = currentip;\n}\nelse if (context.lastip != currentip) {\nmsg.payload = \"My current IP is \"+currentip;\ncontext.lastip = currentip;\nreturn msg;\n}","outputs":1,"x":703,"y":544,"z":"4487e413.bb781c","wires":[[]]},{"id":"b58a9192.4a757","type":"exec","command":"wget -qO- ; echo","append":"","useSpawn":"","name":"Call IP -","x":285,"y":556,"z":"4487e413.bb781c","wires":[["7f00c505.80ff3c"],[],[]]},{"id":"7f00c505.80ff3c","type":"switch","name":"Integrity check","property":"payload","rules":[{"t":"regex","v":"\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"},{"t":"else"}],"checkall":"true","outputs":2,"x":531,"y":543,"z":"4487e413.bb781c","wires":[["c1c8efe9.3e371"],[]]}]

Flow Info

created 4 years, 2 months ago

Node Types

  • exec (x1)
  • function (x1)
  • inject (x1)
  • switch (x1)


  • IP
  • address
  • network
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option