Raspberry PI eth0 static IP network configuration via Dashboard

This flows allows users to manually change the static IP configuration of the Raspberry PI.

Before using this flow you need to edit your /etc/dhcpcd.conf file:

sudo nano /etc/dhcpcd.conf

And add this lines to the end of the file (If not already present). Remember to replace the IP address based on your local network configuration or your Raspberry will not be visible on your local network after reboot.

interface eth0

static ip_address=192.168.1.xx/24
static routers=192.168.1.xx
static domain_name_servers=192.168.1.xx

The flow will edit this file with a find/replace so be careful and make sure you set a valid configuration before reboot your Raspberry.

UI Preview

alt text

Flow

alt text

Enjoy

[{"id":"561cc462.32ebcc","type":"inject","z":"67e0c126.cf1fe","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":235,"y":2977,"wires":[["989d4c8f.8ada9"]]},{"id":"989d4c8f.8ada9","type":"exec","z":"67e0c126.cf1fe","command":"cat /etc/dhcpcd.conf","addpay":false,"append":"","useSpawn":"","timer":"","name":"","x":461,"y":2976,"wires":[["e1581214.1a656"],[],[]]},{"id":"e1581214.1a656","type":"function","z":"67e0c126.cf1fe","name":"","func":"var lines = msg.payload.split(\"\\n\");\nvar data = [];\n\nfor(var i=0; i< lines.length; i++){\n    if(lines[i].indexOf(\"interface eth0\") != -1)\n        break;\n}\n\nif(i != lines.length){\n   for(i; i< lines.length; i++){\n        var tmp = lines[i].split(\"=\");\n        if(tmp.length==2){\n            var value = {};\n            value.text = tmp[0].trim();\n            value.payload = tmp[1].trim();\n            data.push(value);\n        }\n    } \n}\n\nif(data.length != 3)\n msg = null;\nelse\n msg = data;\n\n\n \nreturn msg;","outputs":"3","noerr":0,"x":712,"y":2963,"wires":[["7e441aa2.9d9db4"],["7e441aa2.9d9db4"],["7e441aa2.9d9db4","f973c18e.15668"]]},{"id":"7e441aa2.9d9db4","type":"switch","z":"67e0c126.cf1fe","name":"","property":"text","propertyType":"msg","rules":[{"t":"eq","v":"static ip_address","vt":"str"},{"t":"eq","v":"static routers","vt":"str"},{"t":"eq","v":"static domain_name_servers","vt":"str"}],"checkall":"false","outputs":3,"x":891,"y":2961,"wires":[["3f025484.56631c"],["a3529261.87591"],["cc8fb912.feb3a8"]]},{"id":"4feeb529.1d151c","type":"ui_text_input","z":"67e0c126.cf1fe","name":"ip_address","label":"Indirizzo IP","group":"69087b07.4360a4","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"","x":1222,"y":2918,"wires":[["fe2a7dbb.0174a"]]},{"id":"59ea213a.27cac","type":"ui_text_input","z":"67e0c126.cf1fe","name":"router","label":"Router","group":"69087b07.4360a4","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"","x":1201,"y":2961,"wires":[["4b3c09c3.1a3208"]]},{"id":"5e21af7c.a9f17","type":"ui_text_input","z":"67e0c126.cf1fe","name":"dns","label":"DNS","group":"69087b07.4360a4","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"","x":1201,"y":3004,"wires":[["bc9b788.ab60088"]]},{"id":"540e4657.a99e18","type":"exec","z":"67e0c126.cf1fe","command":"sudo sed -i ","addpay":true,"append":"","useSpawn":"","timer":"","name":"","x":1558,"y":2959,"wires":[[],[],[]]},{"id":"3f025484.56631c","type":"function","z":"67e0c126.cf1fe","name":"","func":"flow.set(\"ip_address\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":1072.5,"y":2918,"wires":[["4feeb529.1d151c"]]},{"id":"a3529261.87591","type":"function","z":"67e0c126.cf1fe","name":"","func":"flow.set(\"router\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":1071,"y":2961,"wires":[["59ea213a.27cac"]]},{"id":"cc8fb912.feb3a8","type":"function","z":"67e0c126.cf1fe","name":"","func":"flow.set(\"dns\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":1074,"y":3004,"wires":[["5e21af7c.a9f17"]]},{"id":"fe2a7dbb.0174a","type":"template","z":"67e0c126.cf1fe","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"'s/static ip_address={{flow.ip_address}}/static ip_address={{payload}}/g;' /etc/dhcpcd.conf","x":1382.5,"y":2918,"wires":[["540e4657.a99e18"]]},{"id":"4b3c09c3.1a3208","type":"template","z":"67e0c126.cf1fe","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"'s/static routers={{flow.router}}/static routers={{payload}}/g;' /etc/dhcpcd.conf","x":1381,"y":2961,"wires":[["540e4657.a99e18"]]},{"id":"bc9b788.ab60088","type":"template","z":"67e0c126.cf1fe","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"'s/static domain_name_servers={{flow.dns}}/static domain_name_servers={{payload}}/g;' /etc/dhcpcd.conf","x":1380,"y":3004,"wires":[["540e4657.a99e18"]]},{"id":"3a57c06d.d7355","type":"link in","z":"67e0c126.cf1fe","name":"","links":["f364cbf7.39e3a8"],"x":286.5,"y":2919,"wires":[["989d4c8f.8ada9"]]},{"id":"4988e57a.a091fc","type":"ui_button","z":"67e0c126.cf1fe","name":"reboot","group":"69087b07.4360a4","order":0,"width":"3","height":"1","label":"Riavvia","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":281.6666564941406,"y":3125.5555686950684,"wires":[["dcd40d92.4dc8e"]]},{"id":"dcd40d92.4dc8e","type":"exec","z":"67e0c126.cf1fe","command":"sudo reboot","addpay":false,"append":"","useSpawn":"","timer":"","name":"","x":492.22217178344727,"y":3125.8888463974,"wires":[[],[],[]]},{"id":"93e55463.8de588","type":"ui_button","z":"67e0c126.cf1fe","name":"refresh","group":"69087b07.4360a4","order":0,"width":"3","height":"1","label":"Aggiorna valori","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":96.44442749023438,"y":3044.332911491394,"wires":[["7b136c33.f61304"]]},{"id":"d6786736.f264d8","type":"ui_toast","z":"67e0c126.cf1fe","position":"top right","displayTime":"3","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":1057.777744293213,"y":3135.5553007125854,"wires":[]},{"id":"f973c18e.15668","type":"change","z":"67e0c126.cf1fe","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Valori aggiornati","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920.5554542541504,"y":3054.4442138671875,"wires":[["d6786736.f264d8"]]},{"id":"7b136c33.f61304","type":"delay","z":"67e0c126.cf1fe","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":263.8888740539551,"y":3044.444511413574,"wires":[["989d4c8f.8ada9"]]},{"id":"69087b07.4360a4","type":"ui_group","z":"","name":"Configurazione IP","tab":"4266a760.b04e98","disp":true,"width":"6"},{"id":"4266a760.b04e98","type":"ui_tab","z":"","name":"Impostazioni","icon":"settings"}]
robertsLando

Flow Info

created 6 months, 3 weeks ago

Node Types

Core
  • change (x1)
  • delay (x1)
  • exec (x3)
  • function (x4)
  • inject (x1)
  • switch (x1)
  • template (x3)
Other
  • link in (x1)
  • ui_button (x2)
  • ui_group (x1)
  • ui_tab (x1)
  • ui_text_input (x3)
  • ui_toast (x1)

Tags

  • raspberry
  • raspberrypi
  • dashboard
  • network
  • configuration
  • ip
  • staticip
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option