Ticket #1135 (new)

Opened 6 years ago

Last modified 6 years ago

Enable existing nodes to flash routers with factory settings

Reported by: Musti Owned by: kostko
Priority: normal Milestone: Ideas for the future
Component: firmware Version:
Keywords: Cc: valentt
Related nodes: Realization state:
Blocking: Effort: normal
Blocked by: Security sensitive: no

Description

To enable easier flashing of new nodes and much faster deployment, existing wlan-si nodes should be able to flash routers with factory settings with firmware generated by nodewatcher.

It enables new nodes to be created by simply connecting them to existing ones, could be extended for nodewatcher support to just choose the existing node via which you wish to flash the new one.

While this can be implemented in a complicated manner, lets start by a simple tool with the following functionality deployed to TP-Link nodes:

  • simple web interface that takes in the link to the firmware and has the button Flash
  • the tool then tries to ping default IPs of known routers and checks MAC for identification on LAN port 1.
vendor ip username password
ubiquiti 192.168.1.20 ubnt ubnt
tp-link 192.168.0.1 admin admin
tp-link 192.168.1.1 admin admin
  • flashes tp-link routers through http
  • flashes ubiquiti routers via ssh, using this method
  • if ssh not accessible, do it via tftp

Change History

comment:1 Changed 6 years ago by mitar

  • Milestone set to Ideas for the future

comment:2 Changed 6 years ago by mitar

This should be made as independent OpenWrt package. You should check as well if something like this does not already exist.

You want to use admin web interface of the factory firmware or TFTP?

Be careful that such button cannot be used to DOS the node (somebody pressing it over the network many times). Maybe it should be available only to locally connected clients.

comment:3 Changed 6 years ago by Musti

Both admin web interface of the factory firmware and TFTP.

It should be available to any client in the network as it is easy to tell someone just plug in the router I will flash it remotely. Here is a cool idea that prevents DOSing. At least all tp-link routers have a QSS button, that we are not using anyhow, so it might be useful to start the lined up firmware upgrade or alternatively initiated via ssh.

For the start, ssh only script would be sufficient.

comment:4 Changed 6 years ago by valentt

I can create script for tplink routers. I'm just not sure what is the goal. Should this script flash new router with specific firmware than node, or just flash it with blank firmware without any config files?

comment:5 Changed 6 years ago by mitar

Do you know that we have nodeupgrade script? It is not maintained anymore, but the idea was to make flashing from inside the node easy (before OpenWrt had their solution for this). So you just run nodeupgrade URL_TO_NODEWATCHER_FIRMWARE_IMAGE and it flashed.

Now, make a script called peerupgrade which you run with peerupgrade URL_TO_NODEWATCHER_FIRMWARE_IMAGE and it flashes the router connected to the router you ran this on.

comment:6 Changed 6 years ago by Musti

The goal is to hook up an out-of-the-box to an existing wlan slovenija node and by using this peerupgrade function it reflashes with a provided firmware. Making the whole flashing procedure of nodes much easier.

comment:7 Changed 6 years ago by Musti

comment:8 Changed 6 years ago by Musti

For a start, here is a shell script that uses curl to flash factory default nodes from OS X or linux, execute it with: ./scriptname.sh <url to firmware>

#!/bin/bash

#
# Adopted from Serval Project Mesh Extender.
# Pass the firmware file to be flashed as the first parameter.
#
# The second curl call will time out, but it's expected. Once the
# script exits you can unplug the ethernet cable and proceed to the
# next router, but KEEP each router ON POWER until the new image is
# fully written! When flashing is done the router automatically
# reboots, wait until the wireless light is blinking.

firmware=firmware.bin
IPADDR="192.168.0.1"

curl -o firmware.bin $1

sleep 1
echo "File downloaded!"

curl --user admin:admin --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0' --referer 'http://$IPADDR/userRpm/SoftwareUpgradeRpm.htm' --form "Filename=@$firmware" -F 'Upgrade=Upgrade' "http://$IPADDR/incoming/Firmware.htm" > /dev/null
  
echo "File uploaded!"

sleep 1

curl --max-time 2 --user admin:admin --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0' --referer 'http://$IPADDR/incoming/Firmware.htm'  "http://$IPADDR/userRpm/FirmwareUpdateTemp.htm" >  /dev/null

echo "This timeout was expected, wait ~60s for the node to reboot!"
Note: See TracTickets for help on using tickets.