diff --git a/README.md b/README.md index 256a231..13f1f6a 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,29 @@ OpenWrtScripts This is a set of scripts (sometimes also called "Openscripts") that report, configure and measure (and improve) latency in home routers (and everywhere else!) These scripts work equally well for both [LEDE](https://lede-project.org) and [OpenWrt](https://openwrt.org) and include: -* [getstats.sh](#getstatssh) - a script to collect troubleshooting information that helps to diagnose problems in the OpenWrt distribution. +* [getstats.sh](#getstatssh) - a script to collect troubleshooting + information that helps to diagnose problems in the OpenWrt distribution. -* [opkgscript.sh](#opkgscriptsh) - a script to save the list of -currently-installed packages (say, before a sysupgrade), -and then restore the full set of packages after the upgrade. +* [opkgscript.sh](#opkgscriptsh) - a script to save the list of + currently-installed packages (say, before a sysupgrade), + and then restore the full set of packages after the upgrade. -* [config-openwrt.sh](#config-openwrtsh) - a script to configure the OpenWrt router consistently after flashing factory firmware. +* [config-openwrt.sh](#config-openwrtsh) - a script to configure the + OpenWrt router consistently after flashing factory firmware. -* [betterspeedtest.sh](#betterspeedtestsh) & [netperfrunner.sh](#netperfrunnersh) & [networkhammer.sh](#networkhammersh) - scripts that measure the performance of your router or offer load to the network for testing. +* [config-spare-router.sh](#config-spare-routersh) - Configure a + "spare router" to known settings so it's easy to use in a new setting. -* [idlelatency.sh](#idlelatencysh) - a script to measure the latency of an "idle line" without any additional traffic generation from the script. +* [betterspeedtest.sh](#betterspeedtestsh) & + [netperfrunner.sh](#netperfrunnersh) & + [networkhammer.sh](#networkhammersh) - scripts that measure the + performance of your router or offer load to the network for testing. -* [tunnelbroker.sh](#tunnelbrokersh) - a script to set up a IPv6 6-in-4 tunnel to TunnelBroker.net. +* [idlelatency.sh](#idlelatencysh) - a script to measure the latency of + an "idle line" without any additional traffic generation from the script. + +* [tunnelbroker.sh](#tunnelbrokersh) - a script to set up a + IPv6 6-in-4 tunnel to TunnelBroker.net. These scripts can be saved in the `/usr/lib/OpenWrtScripts` directory. The easiest way to do this is to use ssh into the router and enter these commands: @@ -67,6 +77,41 @@ Cloned from Malte Forkel's [original script.](https://forum.openwrt.org/viewtopi `sh opkgscript.sh help` _display full help information for the script_ +## [config-spare-router.sh](https://github.com/richb-hanover/OpenWrtScripts/blob/master/config-spare-router.sh) + +Configure a "spare router" to known settings so that +it's easy to use in a new situation. +Many of us have a pile of routers that might be passed along to +friends, family, or neighbors. +But they're in an unknown state, and it's a hassle to figure out the +current configuration to reuse them. + +This script configures an OpenWrt router to a known state. +It also prints a label that can be taped to the outside of the router +so the next person "to touch it" can log in easily. + +When you're taking a router out of service, +reset it, then run this script. +Print the label below and tape it to the router. +It'll be easy to start using it again. + +``` +================================================= + Device: D-Link DIR-878 A1 + OpenWrt: 'OpenWrt 23.05.5 r24106-10cc5fcd00' + Connect to: http://SpareRouter.local + or: ssh root@SpareRouter.local + LAN: 172.30.42.1 + User: root + Login PW: SpareRouter + WiFi SSID: SpareRouter + WiFi PW: + Configured: 2024-Sep-26 +================================================= + +Power Brick Label: D-Link DIR-878 A1 +``` + ## [config-openwrt.sh](https://github.com/richb-hanover/OpenWrtScripts/blob/master/config-openwrt.sh) The `config-openwrt.sh` script updates the factory settings of OpenWrt to a known-good configuration. diff --git a/Why a Spare Router?.md b/Why a Spare Router?.md new file mode 100644 index 0000000..e50cdfa --- /dev/null +++ b/Why a Spare Router?.md @@ -0,0 +1,131 @@ +# Why a "Spare Router" Configuration? + +Many people who use OpenWrt wind up with unused routers when +they retire one for a newer device. +These are perfectly functioning devices that are perhaps older or missing a certain function. + +They could be easily re-used and passed along to friends, family or neighbors. +BUT... + +1. The router retains all your personal info: + passwords, certificates, idiosyncratic packages. etc. +2. You can't remember how it was configured, so you + can't even connect to it. + +**The remedy:** A "spare router" configuration script that +you can use when you take a router out of service. +It leaves the router with current OpenWrt firmware +configured for Wifi access, and +a known useful set of package to make it easy to reuse. +The script also prints a label that you can attach to +the router so that you can get started quickly the next +time you get it out. + +## Usage + +When you retire a router from service, run this script. To do this: + +* Connect via Ethernet to a LAN port +* Use the LuCI GUI to upgrade the firmware to the latest version. +* When the router starts up again, reset settings to + factory default (**System -> Backup/Flash firmware**) +* Connect to the router via ssh (you'll need an Ethernet connection) +* Run the script (`cd /tmp; cat > config.sh & paste; ^D; sh config.sh`) +* Print the results from the script to make a label. Tape it to the router +* _Pro tip:_ Snip the model number from the "Power Brick Label:" part of the results + and tape it directly to the power brick. +* _Pro tip:_ Place the router and its power brick in a ziploc bag + to keep them together. + +The `config-spare-router.sh` script may be run multiple times without bad effect. +When the script completes, it displays configuration like this, +suitable for printing and taping to the router. + +``` +================================================= + Device: D-Link DIR-878 A1 + OpenWrt: 'OpenWrt 23.05.5 r24106-10cc5fcd00' + Connect to: http://SpareRouter.local + or: ssh root@SpareRouter.local + LAN: 172.30.42.1 + User: root + Login PW: SpareRouter + WiFi SSID: SpareRouter + WiFi PW: + Configured: 2024-Sep-26 +================================================= + +Power Brick Label: D-Link DIR-878 A1 + +``` + +## When you (re)deploy the router + +The default settings are (intentionally) insecure. +Remember to change the following: + +* Root password (**System -> Administration**) +* Wifi credentials (**Network -> Wireless**) +* Enable other Wifi radios (**Network -> Wireless**) +* Change the LAN interace as needed (**Network -> Interfaces**) +* (Optional) Configure SQM (**Network -> SQM QoS**) +* (Optional) Change the hostname (**System -> System**) +* (Optional) Install other packages as needed +* (Optional) Travelmate (**Services -> Travelmate**) + Click the **Interface Wizard** button one time + +## Rationale for the configuration choices + +This script was designed for ease of use. +It presumes that it is being installed on a modern (post-2021) +router that has plenty of RAM and Flash storage, so that size +was not a consideration. + +* **Root password:** To make it easy to re-use the router, + the `root` password is set to `SpareRouter`. + There is no need for strong security here, as you will be changing + the password when you set it up in its new location. +* **LAN Address:** The LAN IP address is set to `172.30.42.1`. + This is a + [valid private IP address range](https://en.wikipedia.org/wiki/Private_network) + (like `10...` and `192.168...`) but it is less commonly used. + This means that you can bring the router into virtually any + network environment without concern for IP address conflicts, + then use the LuCI GUI to configure the LAN. +* **Hostname:** is set to "SpareRouter". + Because `umdns` is installed, you can connect using + `http://SpareRouter.local` or `ssh root@SpareRouter.local` + no matter what the LAN IP address is. +* **Wifi settings:** The SSID is of the _first_ radio is set + to `SpareRouter` without encryption. + No other radios are enabled. + As with the root password, there is no need for a strong password, + because you will be changing it immediately. +* **Time Zone:** As a convenience, the time zone is set to `Americas/New York`. + You can use the LuCI GUI to re-configure as needed. +* **Software packages:** The script installs a minimal set of useful + packages that are required to bootstrap a new router. + + * **luci** Released versions of OpenWrt already install `luci`, + re-installing does no harm. + * **umdns** To allow the router to advertise its name as "SpareRouter" + (e.g., connect using `ssh root@sparerouter`) + * **luci-app-sqm** All OpenWrt routers should have the SQM package installed + to minimize bufferbloat + * **travelmate** and + * **luci-app-travelmate** This package allows a router to + act as a Wifi repeater. + It also allows you to connect wirelessly to an "upstream router" for + additional downloads without requiring an Ethernet cable for the WAN port. + +## Modifications + +This script provides a stable platform for re-deploying old routers. +Feel free to make suggestions (create an Issue) for _minimal_ tweaks that +would improve the script. Enjoy! + +## Old information + +The script also has a large number of lines that are commented out. +These were steps for other packages that are not essential for the "Spare Router". +Feel free to experiment with these sections in your own copy of the script. diff --git a/config-spare-router.sh b/config-spare-router.sh index f32e958..50e5280 100644 --- a/config-spare-router.sh +++ b/config-spare-router.sh @@ -37,6 +37,7 @@ # === CONFIGURATION PARAMETERS === # Set the variables in this section to be used for configuration +HOSTNAME="SpareRouter" NEWPASSWD="SpareRouter" TIMEZONE='EST5EDT,M3.2.0,M11.1.0' # see link to other time zones below ZONENAME='America/New York' @@ -50,17 +51,24 @@ ENCRMODE='none' # === Update root password ===================== # Update the root password. # -echo 'Updating root password' +echo '*** Updating root password' passwd <