Skip to content

Commit

Permalink
Update label to use top-level DNS domain (from dhcp.dnsmasq.domain);
Browse files Browse the repository at this point in the history
   This is usually ".local", but might be ".lan"
Use same code in print-router-label.sh and config-spare-router.sh
  • Loading branch information
richb-hanover committed Dec 13, 2024
1 parent e34bd49 commit 7eec6fb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ cd /usr/lib
git clone https://github.com/richb-hanover/OpenWrtScripts.git
```

**NB:** Some of these scripts have instructions for running the script
from `/tmp`

## [getstats.sh](https://github.com/richb-hanover/OpenWrtScripts/blob/master/getstats.sh)

The `getstats.sh` script helps diagnose problems with OpenWrt.
Expand Down Expand Up @@ -117,7 +120,7 @@ to encounter the router (which may be you) can access it.

This process is reasonably secure - if the bad guy
can read the label, they can also factory-reset the router
(or steal TV or your silverware). Here's a sample label:
(or steal your TV or your silverware). Here's a sample label:

```text
======= Printed with: print-router-label.sh =======
Expand All @@ -130,7 +133,7 @@ can read the label, they can also factory-reset the router
Login PW: abcd9876
Wifi SSID: My Wifi SSID
Wifi PW: <no password>
Configured: 2024-Nov-28
Configured: 2024-11-28
=== See github.com/richb-hanover/OpenWrtScripts ===
Label for Power Brick: Linksys E8450 (UBI)
Expand Down Expand Up @@ -287,7 +290,7 @@ root@openwrt# sh betterspeedtest.sh root@openwrt# sh bette

The `netperfrunner.sh` script runs several netperf commands simultaneously.
This mimics the stress test of
[netperf-wrapper](https://github.com/tohojo/netperf-wrapper)
[Flent](https://github.com/tohojo/flent)
[Github] but without the nice GUI result.

When you start this script, it concurrently uploads and downloads several
Expand Down
8 changes: 6 additions & 2 deletions Why a Spare Router?.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ It is available at
[config-spare-router.sh](https://github.com/richb-hanover/OpenWrtScripts/blob/master/config-spare-router.sh)
To use it:

* Connect via Ethernet to a LAN port
* Connect your laptop via Ethernet to a LAN port
* Connect the router's WAN Ethernet to the Internet
(perhaps the LAN port of the new router).
* Use the LuCI GUI to reset settings to
factory default (**System -> Backup/Flash firmware**)
* Use the [Firmware Selector](https://firmware-selector.openwrt.org/)
to find and flash the latest firmware
* SSH into the router using the Ethernet connection
* Run the attached script (see the instructions within it)
* The script prints a label: cut it out and tape it to the router
* _Pro tip:_ Printing the label in 12-point type produces a
"business card" size label.
* _Pro tip:_ Snip the model number from the paper
and tape it directly to the power brick.
(Use the text from the "Power Brick Label" section.)
Expand All @@ -58,7 +62,7 @@ suitable for printing and taping to the router.
# Login PW: SpareRouter
# Wifi SSID: SpareRouter
# Wifi PW: <no password>
# Configured: 2024-Nov-28
# Configured: 2024-11-28
# === See github.com/richb-hanover/OpenWrtScripts ===
#
# Label for Power Brick: Linksys E8450 (UBI)
Expand Down
15 changes: 9 additions & 6 deletions config-spare-router.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
# Login PW: root-password
# Wifi SSID: My Wifi SSID
# Wifi PW: abcd9876
# Configured: 2024-Nov-28
# Configured: 2024-11-28
# === See github.com/richb-hanover/OpenWrtScripts ===
#
# Label for Power Brick: Linksys E8450 (UBI)

# ***** To run this script *****
#
# 0. (Optional) Make a backup of the current router config.
# It'll be easy to restore if necessary.
# 1. Connect your laptop on a wired LAN port (Ethernet):
# some of these changes can reset the wireless network.
# 2. Connect the router's WAN port to the internet: this
Expand All @@ -50,15 +52,16 @@
# === print_router_label() ===
# This function is copy/pasted from "print-router-label.sh"
# to keep the "config-spare-router.sh" script a single file.
# Maintenance hassle: Changes to the printing must be updated
# in both places
# THIS IS A MAINTENANCE HASSLE:
# Changes to the printing must be updated in both places
print_router_label() {
local ROOTPASSWD="${1:-"?"}"
TODAY=$(date +"%Y-%b-%d")
TODAY=$(date +"%Y-%m-%d")
DEVICE=$(cat /tmp/sysinfo/model)
OPENWRTVERSION=$(grep "DISTRIB_DESCRIPTION" /etc/openwrt_release | cut -d"=" -f2 | tr -d '"' | tr -d "'")
HOSTNAME=$(uci get system.@system[0].hostname)
LANIPADDRESS=$(uci get network.lan.ipaddr)
LOCALDNSTLD=$(uci get dhcp.@dnsmasq[0].domain) # top level domain for local names

# Create temporary file for both SSID and password
TMPFILE=$(mktemp /tmp/wifi_creds.XXXXXX)
Expand Down Expand Up @@ -99,8 +102,8 @@ print_router_label() {
echo "======= Printed with: print-router-label.sh ======="
echo " Device: $DEVICE"
echo " OpenWrt: $OPENWRTVERSION"
echo " Connect to: http://$HOSTNAME.local"
echo " or: ssh root@$HOSTNAME.local"
echo " Connect to: http://$HOSTNAME.$LOCALDNSTLD"
echo " or: ssh root@$HOSTNAME.$LOCALDNSTLD"
echo " LAN: $LANIPADDRESS"
echo " User: root"
echo " Login PW: $ROOTPASSWD"
Expand Down
12 changes: 8 additions & 4 deletions print-router-label.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#
# Pro-tip: Snip out the power brick label, and tape it to the
# power brick so the router and brick don't get separated.
#
# Pro-tip: Printing the label in 12-point type produces a
# "business card" size label. Small text, but readable.
#
# If no root-password is supplied, the script prints "?".
# You can then write the password on the label.
Expand All @@ -32,19 +35,20 @@
# Login PW: root-password
# Wifi SSID: My Wifi SSID
# Wifi PW: <no password>
# Configured: 2024-Nov-28
# Configured: 2024-11-28
# === See github.com/richb-hanover/OpenWrtScripts ===
#
# Label for Power Brick: Linksys E8450 (UBI)
#

print_router_label() {
local ROOTPASSWD="${1:-"?"}"
TODAY=$(date +"%Y-%b-%d")
TODAY=$(date +"%Y-%m-%d")
DEVICE=$(cat /tmp/sysinfo/model)
OPENWRTVERSION=$(grep "DISTRIB_DESCRIPTION" /etc/openwrt_release | cut -d"=" -f2 | tr -d '"' | tr -d "'")
HOSTNAME=$(uci get system.@system[0].hostname)
LANIPADDRESS=$(uci get network.lan.ipaddr)
LOCALDNSTLD=$(uci get dhcp.@dnsmasq[0].domain) # top level domain for local names

# Create temporary file for both SSID and password
TMPFILE=$(mktemp /tmp/wifi_creds.XXXXXX)
Expand Down Expand Up @@ -85,8 +89,8 @@ print_router_label() {
echo "======= Printed with: print-router-label.sh ======="
echo " Device: $DEVICE"
echo " OpenWrt: $OPENWRTVERSION"
echo " Connect to: http://$HOSTNAME.local"
echo " or: ssh root@$HOSTNAME.local"
echo " Connect to: http://$HOSTNAME.$LOCALDNSTLD"
echo " or: ssh root@$HOSTNAME.$LOCALDNSTLD"
echo " LAN: $LANIPADDRESS"
echo " User: root"
echo " Login PW: $ROOTPASSWD"
Expand Down

0 comments on commit 7eec6fb

Please sign in to comment.