Repository navigation
feat: add IoT network routing through Tailscale (Allow Remote Access IoT) - #16
Open
schrodienieur wants to merge 1 commit into
Open
schrodienieur wants to merge 1 commit into
schrodienieur wants to merge 1 commit into
Conversation
Contributor
|
Thanks for this PR. I replied on #15 with where it stands for v1.0.22 and v1.0.23: #15 (comment) |
…IoT) Rebased onto v1.0.22. GL's "Advertise LAN Subnets" only covers the primary LAN, so smart-home devices on the AP-isolated IoT network were unreachable from tailnet devices. This adds the remote-access side the kill switch coverage in v1.0.22 does not provide: the IoT subnet route advertisement and the iot <-> tailscale0 firewall forwardings. Files: - src/config/ts-fix: add the route_iot option. - src/scripts/ts-fix-reapply: IoT route advertise/remove, policy route fixup, forwardings, teardown and reset, mirroring Route Guest. - src/rpc/ts-fix: get_iot_subnet, update_iot_route, set_iot_ts_fw and fix_iot_policy_route, plus get_config/set_config wiring. - src/www/ts-fix.js: the "Allow Remote Access IoT" toggle row, tooltip, state, reapply and verify. - pkg/prerm: IoT policy route and forwarding cleanup on removal. - README.md / pkg/control: feature and package description. - tests/unit/test-iot-net.sh: new suite for the IoT helper and advertisement block, mirroring test-guest-net.sh. - tests/unit: extend the existing Route Guest and kill switch suites to cover the IoT path. Written against the v1.0.22 code rather than rebasing the v1.0.21 diff: - The subnet comes from an iot_net helper (ipcalc.sh) beside the existing guest_net, not from zeroing the last octet, which is right only for a /24 and would miss GL's own "from <net>" rule on any other prefix. - The advertised-routes read is separated from the write and its failure leaves the daemon-pending flag for the watchdog, so a failed read cannot be taken for "no routes" and drop every other advertised route. Route removal uses route_list_drop; the sed form failed on a subnet containing "/". - Every tailscale CLI call runs under timeout 10 and logs its failure. - route_list_drop moved into its own marked block. It was defined inside the guest_net block but is now called by both networks, so it belongs to neither one's helper block. Behaviour is unchanged. - The kill switch moved to its own engine in v1.0.22, so this no longer installs ip rules of its own. The engine already covers iot (KS_SWAP_ZONES), and the disabled path re-asserts its rule layer via rules-ensure, the same way the guest path does. Verified: sh -n on the scripts, node --check on the injected JS, the Lua module compiles, all 15 unit suites pass (including both legacy negative controls, whose 7 DEFECT cases each fail against the pre-fix code), and ./pkg/build.sh 1.0.22 builds the ipk. Live-tested on a GL-BE6500 (firmware 4.9.0) running v1.0.22, with the plugin upgraded from v1.0.21: with the toggle on, the IoT subnet advertises, the iot <-> tailscale0 forwardings and the destination-based policy rule are installed, and a device on 192.168.10.0/24 is reachable from a tailnet peer. Turning the toggle off removes the route, both forwardings and the policy rule while leaving the other advertised routes intact.
schrodienieur
force-pushed
the
feat/iot-routing
branch
from
October 5, 2026 09:45
698911d to
951cb45
Compare
Author
Rebased onto 1.0.22 and force-pushed, 12 files changed, tested on GL-BE6500 4.9 firmware. Mind if you take a look when you get a chance? |
Contributor
|
Sorry for the slow reply, @schrodienieur, and thanks for rebasing and testing on the BE6500. IoT routing is planned for v1.0.23 and your PR is the starting point for it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15
What
Adds the "Allow Remote Access IoT" toggle to the Tailscale Enhanced section, mirroring the existing Guest Network Access feature for the IoT zone (firmware 4.9+).
GL's "Advertise LAN Subnets" only covers the primary LAN. Smart-home devices on the AP-isolated IoT network (e.g. 192.168.10.0/24) were previously unreachable from tailnet devices.
Since v1.0.22 the kill switch covers the IoT zone, but not the remote-access side: advertising the IoT subnet and the iot ↔ tailscale0 forwardings. This adds those.
What it does
tailscale set --advertise-routesiot <-> tailscale0firewall forwardings (both directions)Files changed (12)
src/config/ts-fix— addroute_iotoptionsrc/scripts/ts-fix-reapply— IoT route advertise/remove, policy route, forwardings, teardown, reset (mirrors guest)src/rpc/ts-fix—get_iot_subnet,update_iot_route,set_iot_ts_fw,fix_iot_policy_route,get_config/set_configwiringsrc/www/ts-fix.js— "Allow Remote Access IoT" toggle row, tooltip, state, reapply + verify, firmware gatingpkg/prerm— IoT policy route + forwardings cleanupREADME.md/pkg/control— feature and package descriptiontests/unit/test-iot-net.sh— new suite for the IoT helper and advertisement blocktests/unit/test-guest-net.sh,tests/unit/test-ks-armdisarm.sh,tests/unit/test-ts-state.sh,tests/README.md— extended to cover the IoT path (see notes below)Notes for review
iot_nethelper (ipcalc.sh) beside the existingguest_net, not from zeroing the last octet, which is right only for a /24 and would miss GL's ownfrom <net>rule on any other prefix.route_list_drop; the sed form it replaces failed on a subnet containing/.route_list_dropmoved into its own marked block. It was defined inside theguest_netblock but is now used by both networks, so it no longer belongs to either one's helper block. Behaviour is unchanged.test-guest-net.shhas two forced edits.extract()also pulls theroute_list_dropblock (it moved, and the suite still needs it for itsdropcases), and theipcalc.shcount is scoped toget_guest_subnet's body instead of the whole file, since a second network's helper makes a global count of 1 wrong. Nothing else in that file changed.test-ks-armdisarm.shchanges are exact counts that the added calls made wrong:rules-ensure2 → 3 in reapply and 1 → 2 in the RPC,tailscale setcalls 10 → 15, and the bound total 17 → 25. No assertion was weakened.iotfirewall zone to forward to on older firmware.Verification
sh -non the shell scripts,node --checkon the injected JS, the Lua RPC module compileslegacynegative controls (7 DEFECT cases each fail against the pre-fix code, as intended)./pkg/build.sh 1.0.22builds the ipkiot <-> tailscale0forwardings and the destination-based policy rule are installed, and a device on 192.168.10.0/24 is reachable from a tailnet peer. Turning the toggle off removes the route, both forwardings and the policy rule while leaving the other advertised routes intact.