Sync vault notes: April-November 2026 sessions, projects, and architecture

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
garfieldandClaude Sonnet 5.5 committed 2026-11-13 11:00:53 -05:00
1 parent fe4fe656be
commit 994c7ae577
379 files changed
+55216 -107

No files matched your search

@@ -0,0 +1,82 @@
---
date: 2026-09-15
tags: [art0, security, watchdog, tailscale, infrastructure, runbook]
status: active-monitor-only
---
# art0 security watchdog: Tailscale-safe bans and restart preparation
## Earlier decision and status (superseded below)
The watchdog and daily SSH report remain suspended in garfield's crontab, verified again when this runbook was written. The dedicated SNAT persistence service is enabled and active. The watchdog was neither run nor re-enabled during the review or changes.
Recommendation: re-enable the existing five-minute watchdog after explicit user authorization, and verify the first completed run alongside downstream connectivity. Its Slack/email alerts are part of normal operation; running the watchdog is not a read-only test. No live ban or notification test has been performed. The daily report is a separate job and should be explicitly included in any restart instruction.
## Why these changes were necessary
There were separate networking problems:
1. On art0, legacy Calico forwarding cleared bits in Tailscale's packet mark. This stopped Tailscale's marked masquerade rule from matching. An explicit source/interface SNAT rule restored the exit node. Watchdog suspension alone did not fix this.
2. The watchdog's previous automatic SSH bans rejected **all protocols** from an offending public IP. Three matching failed-login log lines within 24 hours could cause a full source ban, potentially blocking the UDP transport of a direct Tailscale connection from the same public IP. The new rule limits new bans to the actual SSH listener, **TCP/2222**, while retaining the 100.64.0.0/10 tailnet exclusion.
3. The later Mac/Nexxt outage after a Mac restart involved a changed tunnel interface and incorrect local return routing. That is separate from the watchdog and was addressed in the linked Mac runbook.
The new watchdog helper inserts:
```sh
iptables -I INPUT 1 -s "$ip" -p tcp --dport 2222 -m comment --comment security-watchdog-ssh -j REJECT --reject-with tcp-reset
```
Ban detection was also adjusted to ignore unrelated port/protocol bans while still recognizing pre-existing broad bans. Historical broad bans were not removed or narrowed. Legitimate failed public SSH logins can still trigger an SSH ban; the change prevents such a new ban from also blocking Tailscale UDP.
## Original schedules (still commented out)
- Every five minutes: `/home/garfield/hermes-mcp/scripts/security-watchdog.sh`
- Daily at 08:00 in the cron scheduler's timezone: `/home/garfield/hermes-mcp/scripts/security-watchdog-daily-report.sh`
Restore only the intended commented entries when authorized; preserve all unrelated cron jobs. Do not infer UTC from the schedule without checking the server/cron timezone.
## Re-enable validation checklist
- Confirm only the intended cron entries were restored and no duplicate schedules were introduced.
- Observe the first scheduled watchdog run and completion in `/home/garfield/security-watchdog.log`; the script uses a lock to avoid overlap.
- Confirm any newly inserted watchdog ban is TCP/2222 only.
- Check that the single explicit SNAT rule remains present and passes traffic.
- Test a phone or Windows device on **coralsprings**, with any device-local VPN and cellular fallback disabled: exact expected IPv4 **104.190.60.129**.
- If a regression occurs, suspend only the restored watchdog entries and investigate. Do not flush the firewall or remove the SNAT workaround.
## Deployment record and rollback
# art0 Tailscale exit SNAT persistence — 2026-09-15
Calico's legacy forwarding chain clears bits used by Tailscale's NAT mark. Explicit IPv4 source NAT for 100.64.0.0/10 through enp2s0 restores exit-node forwarding.
## Installed
- tailscale-exit-snat.sh → /usr/local/sbin/tailscale-exit-snat (root-owned, 0755).
- tailscale-exit-snat.service → /etc/systemd/system/; enabled and started.
- tailscaled-exit-snat.conf → /etc/systemd/system/tailscaled.service.d/exit-snat.conf.
- Added the matching rule to the existing *nat section of /etc/iptables/rules.v4 without replacing other saved rules.
The helper locks and checks for the rule before inserting it. The oneshot runs after network-online, netfilter-persistent, and tailscaled at boot. ExecStartPost runs it after future Tailscale daemon starts. No daemon restart or reboot was performed during installation.
## Watchdog
/home/garfield/hermes-mcp/scripts/security-watchdog.sh now adds only TCP destination-port 2222 bans, with comment security-watchdog-ssh and tcp-reset rejection. Tailnet exclusion remains. Ban detection ignores unrelated protocol/port bans. Existing broad bans were retained. Both watchdog cron entries remain suspended; the watchdog itself was not executed.
## Validation
Shell syntax, existing ban-detection regression, and mocked SSH-only/tailnet-exclusion checks passed. iptables-restore --test accepted the updated saved file. systemd-analyze verify passed. Running the helper twice left one live matching rule. Service enabled/active, daemon hook loaded, saved rule present. Mac public IPv4 remained 104.190.60.129. A real reboot/restart recovery test remains outstanding.
## Backups and rollback
- Watchdog: /home/garfield/security-watchdog-backup-20260915-032939/security-watchdog.sh
- Saved firewall: /root/tailscale-snat-persistence-20260915-033030/rules.v4
To undo persistence, disable tailscale-exit-snat.service, remove only its installed unit/helper and the exit-snat.conf drop-in, restore the saved rules backup after checking for subsequent changes, and daemon-reload. Disabling this oneshot does not remove the live NAT rule. Removing the live NAT rule would break the workaround; do so only deliberately. Restoring the watchdog backup restores broad future bans. Do not re-enable watchdog cron as part of rollback.
The Mac's separate PF sharing fix is still temporary; this change only makes the art0 NAT workaround persistent.
## Related notes
- [[2026-09-14-mac-nexxt-tailscale-art0-sharing]] — full session history, Mac PF scripts, return-route recovery, and coralsprings tests.
Changes are present in the remote working copies and installed system files. No git commit or push was performed. This runbook records configured persistence; an actual art0 reboot/restart recovery test remains outstanding.
## Superseding decision: monitoring only, no automatic bans
User authorized resuming monitoring with **no automatic banning** while travelling in Jamaica. On September 15 the live watchdog was changed so `check_and_ban_ssh_attackers` logs monitor-only mode and returns without scanning or banning; `ban_ssh_ip` refuses action; `iptables_save` refuses writes; and `iptables_cmd` accepts only the exact read-only `-S INPUT` request. These are code-level restrictions, not environment-variable defaults. Existing bans were retained.
Mocked tests confirmed that the disabled entry points cannot invoke iptables or Docker and that firewall-write requests are rejected. Existing ban-detection regression and shell syntax passed. Daily report source was reviewed: its firewall access is read-only. A live monitoring cycle is being validated before schedules resume. Backup: `/home/garfield/watchdog-monitor-only-20260915-035701/` (watchdog script and crontab).
Earlier recommendations in this note to resume SSH auto-bans are superseded. Restoring an older script backup would reintroduce banning logic and must not be done without authorization.
### Confirmed activation — monitor-only
The live monitoring cycle completed successfully at 03:59:15 server time, logging both "Automatic banning disabled; monitoring and alerts only" and "All checks passed." INPUT firewall rules had the identical SHA-256 before and after: `d7474a758fbd6aa693304c715fd43b46d59a12f491ea1d74cf47e7da65657218`.
The five-minute watchdog and daily 08:00 report cron entries were then restored and read back for verification. **Monitoring and scheduled reporting are active; automatic banning and firewall saving in this watchdog are disabled.** Existing firewall bans remain. The Mac still returned public IPv4 **104.190.60.129**. No new phone/Windows end-to-end test was performed during activation.