Update Dynamic DNS service when IP address changes

Thanks to Paul Reed and his Alert flow for inspiration.

This flow is built from Paul's, but adds IP persistence via Firebase and sends a Dynamic DNS update request when the IP changes.

To use this flow, you'll need to update :

  • the Firebase nodes with your own Firebase
  • the Dynamic DNS request with your own DynDNS service (it's ready to go for Zoneedit)
  • the mqtt notifier (you can also replace these components completely)

You'll also want to install the Firebase nodes at https://github.com/hovissimo/node-red-firebase

[{"id":"3d8d2e6c.cba89a","type":"mqtt-broker","broker":"home.bunkercode.com","port":"1883","clientid":""},{"id":"b12fd22.ccb38b","type":"inject","name":"Get IP","topic":"ip","payload":"eth0","payloadType":"none","repeat":"","crontab":"00 08 * * *","once":false,"x":167,"y":247,"z":"e7bb1ba1.345a5","wires":[["49301a6a.3ebb14","cd5a5417.366988"]]},{"id":"cd5a5417.366988","type":"exec","command":"wget -qO- http://bot.whatismyipaddress.com/ ; echo","append":"","useSpawn":"","name":"wget whatismyipaddress.com","x":390,"y":278.5,"z":"e7bb1ba1.345a5","wires":[["2eb875f3.73cb92"],[],[]]},{"id":"2eb875f3.73cb92","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":616,"y":265.5,"z":"e7bb1ba1.345a5","wires":[["97bdc2b3.6c8f88"],[]]},{"id":"109900cf.9f7077","type":"firebase query","name":"","firebaseurl":"https://busknight.firebaseio.com/nodered/home/ip/value","child":"","x":344,"y":416,"z":"e7bb1ba1.345a5","wires":[["1a43a779.8ce5c1"]]},{"id":"4892ffec.fb5e1","type":"change","action":"replace","property":"newip","from":"","to":"msg.payload","reg":false,"name":"","x":182,"y":416,"z":"e7bb1ba1.345a5","wires":[["109900cf.9f7077"]]},{"id":"1a43a779.8ce5c1","type":"function","name":"Swallow unchanged IP message","func":"var lastip = msg.payload;\nvar currentip = msg.newip;\n\nif (lastip != currentip) {\n\tmsg.payload = {\n\t\t\"value\": currentip.trim(),\n\t\t\"updated\": new Date(),\n\t};\n\treturn msg;\n} else {\n\tconsole.log(\"Dynamic DNS: IP has not changed, abort!\");\n}","outputs":1,"x":574,"y":416,"z":"e7bb1ba1.345a5","wires":[["54ed0610.b9fea","4ce6bac0.35db14"]]},{"id":"54ed0610.b9fea","type":"firebase modify","name":"","firebaseurl":"https://busknight.firebaseio.com/nodered/home/ip","child":"","method":"update","x":867,"y":417,"z":"e7bb1ba1.345a5","wires":[]},{"id":"4ce6bac0.35db14","type":"http request","name":"Update zoneedit","method":"GET","url":"https://dynamic.zoneedit.com/auth/dynamic.html?zones=bunkercode.com","x":386,"y":543,"z":"e7bb1ba1.345a5","wires":[["963dc28f.f4582","d6000748.79e4c8"]]},{"id":"963dc28f.f4582","type":"switch","name":"","property":"payload","rules":[{"t":"regex","v":"2\\d\\d"},{"t":"else"}],"checkall":"false","outputs":2,"x":566,"y":543,"z":"e7bb1ba1.345a5","wires":[["17d31a4d.dce036","d133fc9d.b3509"],["d133fc9d.b3509","7fcf8740.e0f858"]]},{"id":"17d31a4d.dce036","type":"file","name":"","filename":"dyndns.log","appendNewline":true,"overwriteFile":false,"x":710,"y":509,"z":"e7bb1ba1.345a5","wires":[]},{"id":"d133fc9d.b3509","type":"debug","name":"Dynamic DNS update results","active":true,"console":"true","complete":"true","x":767,"y":543,"z":"e7bb1ba1.345a5","wires":[]},{"id":"dc4ac786.89d63","type":"debug","name":"Notice","active":true,"console":"true","complete":"false","x":515,"y":222,"z":"e7bb1ba1.345a5","wires":[]},{"id":"49301a6a.3ebb14","type":"change","action":"replace","property":"payload","from":"","to":"Running Dynamic DNS flow...","reg":false,"name":"","x":351,"y":222,"z":"e7bb1ba1.345a5","wires":[["dc4ac786.89d63"]]},{"id":"7fcf8740.e0f858","type":"mqtt out","name":"","topic":"/hovis/notify","broker":"3d8d2e6c.cba89a","x":711,"y":583,"z":"e7bb1ba1.345a5","wires":[]},{"id":"cbc88ce1.7d115","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":184,"y":540,"z":"e7bb1ba1.345a5","wires":[["4ce6bac0.35db14"]]},{"id":"d6000748.79e4c8","type":"debug","name":"","active":true,"console":false,"complete":false,"x":584,"y":625,"z":"e7bb1ba1.345a5","wires":[]},{"id":"97bdc2b3.6c8f88","type":"function","name":"trim","func":"msg.payload = msg.payload.trim();\nreturn msg;","outputs":1,"x":766,"y":259,"z":"e7bb1ba1.345a5","wires":[["4892ffec.fb5e1"]]}]

Flow Info

Created 10 years, 6 months ago
Updated 9 years, 4 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x2)
  • debug (x3)
  • exec (x1)
  • file (x1)
  • function (x2)
  • http request (x1)
  • inject (x2)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • switch (x2)
Other

Tags

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