Skip to content

Commit 7eec6fb

Browse files
committed
Update label to use top-level DNS domain (from dhcp.dnsmasq.domain);
This is usually ".local", but might be ".lan" Use same code in print-router-label.sh and config-spare-router.sh
1 parent e34bd49 commit 7eec6fb

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ cd /usr/lib
4242
git clone https://github.com/richb-hanover/OpenWrtScripts.git
4343
```
4444

45+
**NB:** Some of these scripts have instructions for running the script
46+
from `/tmp`
47+
4548
## [getstats.sh](https://github.com/richb-hanover/OpenWrtScripts/blob/master/getstats.sh)
4649

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

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

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

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

293296
When you start this script, it concurrently uploads and downloads several

Why a Spare Router?.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ It is available at
2929
[config-spare-router.sh](https://github.com/richb-hanover/OpenWrtScripts/blob/master/config-spare-router.sh)
3030
To use it:
3131

32-
* Connect via Ethernet to a LAN port
32+
* Connect your laptop via Ethernet to a LAN port
33+
* Connect the router's WAN Ethernet to the Internet
34+
(perhaps the LAN port of the new router).
3335
* Use the LuCI GUI to reset settings to
3436
factory default (**System -> Backup/Flash firmware**)
3537
* Use the [Firmware Selector](https://firmware-selector.openwrt.org/)
3638
to find and flash the latest firmware
3739
* SSH into the router using the Ethernet connection
3840
* Run the attached script (see the instructions within it)
3941
* The script prints a label: cut it out and tape it to the router
42+
* _Pro tip:_ Printing the label in 12-point type produces a
43+
"business card" size label.
4044
* _Pro tip:_ Snip the model number from the paper
4145
and tape it directly to the power brick.
4246
(Use the text from the "Power Brick Label" section.)
@@ -58,7 +62,7 @@ suitable for printing and taping to the router.
5862
# Login PW: SpareRouter
5963
# Wifi SSID: SpareRouter
6064
# Wifi PW: <no password>
61-
# Configured: 2024-Nov-28
65+
# Configured: 2024-11-28
6266
# === See github.com/richb-hanover/OpenWrtScripts ===
6367
#
6468
# Label for Power Brick: Linksys E8450 (UBI)

config-spare-router.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
# Login PW: root-password
1919
# Wifi SSID: My Wifi SSID
2020
# Wifi PW: abcd9876
21-
# Configured: 2024-Nov-28
21+
# Configured: 2024-11-28
2222
# === See github.com/richb-hanover/OpenWrtScripts ===
2323
#
2424
# Label for Power Brick: Linksys E8450 (UBI)
2525

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

6366
# Create temporary file for both SSID and password
6467
TMPFILE=$(mktemp /tmp/wifi_creds.XXXXXX)
@@ -99,8 +102,8 @@ print_router_label() {
99102
echo "======= Printed with: print-router-label.sh ======="
100103
echo " Device: $DEVICE"
101104
echo " OpenWrt: $OPENWRTVERSION"
102-
echo " Connect to: http://$HOSTNAME.local"
103-
echo " or: ssh root@$HOSTNAME.local"
105+
echo " Connect to: http://$HOSTNAME.$LOCALDNSTLD"
106+
echo " or: ssh root@$HOSTNAME.$LOCALDNSTLD"
104107
echo " LAN: $LANIPADDRESS"
105108
echo " User: root"
106109
echo " Login PW: $ROOTPASSWD"

print-router-label.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#
1616
# Pro-tip: Snip out the power brick label, and tape it to the
1717
# power brick so the router and brick don't get separated.
18+
#
19+
# Pro-tip: Printing the label in 12-point type produces a
20+
# "business card" size label. Small text, but readable.
1821
#
1922
# If no root-password is supplied, the script prints "?".
2023
# You can then write the password on the label.
@@ -32,19 +35,20 @@
3235
# Login PW: root-password
3336
# Wifi SSID: My Wifi SSID
3437
# Wifi PW: <no password>
35-
# Configured: 2024-Nov-28
38+
# Configured: 2024-11-28
3639
# === See github.com/richb-hanover/OpenWrtScripts ===
3740
#
3841
# Label for Power Brick: Linksys E8450 (UBI)
3942
#
4043

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

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

0 commit comments

Comments
 (0)