Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ documents for different readers.
can't run an agent (firewall, switch, UPS, iLO). One agent config, deployed
identically everywhere. [How](docs/architecture.md#observability-data-flow)
- **Dashboards and alerting as code.** 8 provisioned dashboards, 156 panels, and
199 alert rules — 173 metric-based in Prometheus, 26 log-based in Loki — sharing
201 alert rules — 173 metric-based in Prometheus, 28 log-based in Loki — sharing
one Alertmanager routing tree. No dashboard exists only in a database.
- **Secrets encrypted in-repo with SOPS + age.** Per-device credentials,
decrypted at deploy time into gitignored paths, with `git log` showing which
Expand Down Expand Up @@ -209,7 +209,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology
│ ├── observability/ # the estate's stack on prometheus — ten services
│ │ ├── prometheus/ # config, file_sd targets, 173 alert rules
│ │ ├── alertmanager/ # routing and inhibition
│ │ ├── loki/ # single-binary config + 26 LogQL rules
│ │ ├── loki/ # single-binary config + 28 LogQL rules
│ │ ├── alloy/ # the agent config directory, shipped to every host
│ │ ├── snmp-exporter/ # generator.yaml is the source of truth
│ │ └── grafana/ # provisioning + 8 dashboards
Expand Down
16 changes: 10 additions & 6 deletions docs/adr/0127-relay-neos-log-through-morpheus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0127: Relay `neo`'s log through `morpheus`

**Status:** Proposed · 2026-11
**Status:** Accepted · 2026-11

## Context

Expand Down Expand Up @@ -86,9 +86,11 @@ the cases pass.
`syslog.alloy` refuses the message's own hostname, because before #844 any
sender could write `host="morpheus"` with it. That reasoning still holds for
what senders write. Here the hostname is written by `morpheus`'s syslog-ng,
not by the sender: `flags(no-hostname)` on both sources means syslog-ng never
reads a hostname out of an incoming line, and only the rewrite on the `neo`
path sets one. To get `host="neo"` onto a line, a forger would have to deliver
not by the sender. The `neo` source takes `flags(no-hostname)`, so it never
reads one from an incoming line, and a rewrite sets `neo`. pfSense's own
source is generated by the package and cannot take that flag, so its log path
gets a rewrite of its own that sets `morpheus`. Each path writes its own name,
and only the `neo` path can write `neo`. To get `host="neo"` onto a line, a forger would have to deliver
it over the pinned TLS connection, which only `morpheus` holds.

### Why the UDP hop is acceptable
Expand Down Expand Up @@ -147,8 +149,10 @@ segment the firewall does not stand between. This hop is different:
- **Alerting becomes possible, and is a separate change.** The applying PR
should add two Loki rules:
- an `account` login from anywhere but the switch LAN and desktop-02;
- an absence rule on `host="neo"`. Home Assistant's API logins give the
stream a steady heartbeat, so silence means the path is broken.
- an absence rule on `host="neo"`. Home Assistant's API logins were
expected to give the stream a heartbeat, but on 2026-11-23 they came once
in four hours. So `neo` logs a line every five minutes from a scheduler
entry, and silence means the path is broken.

`scripts/check_syslog_senders.sh` gains cases proving that:
- a line from `10.0.99.1` with hostname `neo` gets `host="neo"`;
Expand Down
6 changes: 4 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ default deny. IoT, media and guest are
terminal — traffic goes out, nothing comes back in. One path the diagram cannot
draw: the switch is plumbing here, not a segment, but its management address
sits on the untagged LAN (`10.7.7.0/24`). Since 2026-09-02 that interface
blocks every VLAN and passes only DNS, NTP and the internet
([#229](https://github.com/Gerrrt/HomeLab/issues/229)), and since 2026-09-06
blocks every VLAN and passes only DNS, NTP, the switch's syslog to the
firewall itself, and the internet
([#229](https://github.com/Gerrrt/HomeLab/issues/229),
[ADR-0127](adr/0127-relay-neos-log-through-morpheus.md)), and since 2026-09-06
Winterfell reaches it only through named passes
([ADR-0025](adr/0025-close-the-switch-lan-to-winterfell.md)). IPv6 is the
residual: the stock *Default allow LAN IPv6 to any* rule is still there.
Expand Down
23 changes: 23 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-23

- **`neo`'s log leaves the switch
([ADR-0127](adr/0127-relay-neos-log-through-morpheus.md), accepted).**
The core switch kept its log in RAM, 1,000 lines deep. It now sends
`info`, `warning`, `error` and `critical` over UDP to syslog-ng on
`morpheus`'s switch-LAN address, which relays them over the existing pinned
TLS connection as `host="neo"`. One new pass on `igc0`, *Allow Neo syslog to
Firewall*, to `10.7.7.1:5514` and nothing else. Lines on that path get a fixed
`app="routeros"` in Alloy, and the firewall's Loki rules now require
`host="morpheus"`, so neither guard alone lets a `neo` line raise or silence
a firewall alert. Two new rules, `SwitchLoginFromUnexpectedSource` and
`SwitchLogsStopped`, take the Loki count to 28. Three findings on the way:
- The ADR assumed both syslog-ng sources on `morpheus` set
`flags(no-hostname)`. The live one is generated by the package and cannot,
and `ship-firewall-logs.md` §3 described a `network()` source that was
never what ran. pfSense's path now gets a rewrite that sets `morpheus`
instead, and §3 describes what is on the box.
- Home Assistant's API session logged in once in four hours, so it was no
heartbeat for an absence rule. `neo` now logs one line every five minutes
from a scheduler entry, `log-heartbeat`.
- `ether4`, `mjolnir`'s card, had 48,057 link-downs in 16 days of uptime,
about one every seven seconds by the afternoon: 987 of the 1,000 lines in
the buffer. Nothing saw it, because nothing read the switch's log. Not
fixed here.
- **`prometheus` will take SSH keys only, and stays without a host firewall
([ADR-0128](adr/0128-give-prometheus-a-key-only-sshd-and-no-host-firewall.md)).**
The root-only reads that finished the 2026-11-13 audit were taken today.
Expand Down
4 changes: 3 additions & 1 deletion docs/firewall-claims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ interfaces:

# The switch management LAN. Default deny since 2026-09-02 (#229) outbound and
# 2026-09-06 inbound (ADR-0025); ADR-0013 read it before either and describes
# the wider state.
# the wider state. Its passes to the gateway's own address (DNS, NTP, and
# neo's syslog to 10.7.7.1:5514/udp since ADR-0127) reach no segment, so they
# are not claims this file makes.
#
# The inet6 row is the residual ADR-0025 and network.md's [^lan] footnote both
# record: this interface still carries pfSense's stock *Default allow LAN IPv6
Expand Down
12 changes: 11 additions & 1 deletion docs/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ above CasaBonita, which the spectrum does not. Reasoning in
LAN to any* until 2026-09-02, when six logged blocks — one per VLAN — were
placed above an egress rule renamed *Allow internet*, leaving DNS and NTP to
the gateway as the only passes above them
([#229](https://github.com/Gerrrt/HomeLab/issues/229)). Inbound, nothing on
([#229](https://github.com/Gerrrt/HomeLab/issues/229)). A third joined
them on 2026-11-23: `neo`'s syslog to the gateway's own `10.7.7.1:5514/udp`
([ADR-0127](adr/0127-relay-neos-log-through-morpheus.md)). Inbound, nothing on
Winterfell can reach it since 2026-09-06: `Gerrrt/Lemmiwinks#177` added a
logged block from `10.0.99.0/24`, leaving SNMP as the one pass above that.
One residual, in both directions: the stock *Default allow LAN IPv6 to any*
Expand Down Expand Up @@ -182,6 +184,14 @@ truth for what a box actually does.
switch by MAC after a reset, as
[`swap-the-switch.md`](runbooks/swap-the-switch.md) does.
- NTP comes from `10.7.7.1`. The default `admin` user is disabled.
- The log leaves the switch. Topics `info`, `warning`, `error` and
`critical` go to syslog-ng on `10.7.7.1:5514` over UDP, from
`10.7.7.2`, and morpheus relays them to Loki as `host="neo"`. A
scheduler entry, `log-heartbeat`, logs a line every five minutes so that
silence means the path broke. The `memory` rules stay.
[ADR-0127](adr/0127-relay-neos-log-through-morpheus.md) records why, and
[`ship-firewall-logs.md`](runbooks/ship-firewall-logs.md) §10 is the
procedure.
- DHCP disabled.
- **`morpheus` pins thirteen reservations in its ARP table, on every
segment but Skids and Degens.** Each is a Kea reservation with *Create a
Expand Down
10 changes: 9 additions & 1 deletion docs/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ separates a quiet stream from a stopped one.

## Alerting

199 rules in total: 173 metric-based in `prometheus/rules/`, and 26 log-based in
201 rules in total: 173 metric-based in `prometheus/rules/`, and 28 log-based in
`loki/rules/`.

### Log-based (Loki ruler)
Expand All @@ -363,6 +363,14 @@ covers SSH brute force, SSH accepted from outside VLAN 50/99, repeated sudo
failures, user/group creation, kernel OOM kills, read-only remounts and disk I/O
errors.

**`SwitchLoginFromUnexpectedSource`** and **`SwitchLogsStopped`** read `neo`'s
log, which morpheus relays to the same syslog listener as its own
([ADR-0127](adr/0127-relay-neos-log-through-morpheus.md)). The first fires on a
login to the core switch from anywhere but the switch LAN, desktop-02, or Home
Assistant's read-only API user. The second fires when 30 minutes pass without a
line, and the switch logs a heartbeat every five minutes so that silence means
the path is broken.

**`SystemdUnitFailed`** reads the same systemd verdict as `UnitOomKilled`
below, for any result but `oom-kill`, from PID 1's own stream. It fires when a
system unit fails at least twice in 48 hours. A single failure is not enough,
Expand Down
23 changes: 23 additions & 0 deletions docs/runbooks/respond-to-a-security-alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ An SSH login was **accepted** from outside VLAN 50 and VLAN 99.
[TerminalSegmentReachedInternalNetwork](#terminalsegmentreachedinternalnetwork)
explains how to read it from the firewall.

## SwitchLoginFromUnexpectedSource

Someone logged in to `neo`, the core switch, from a source other than the
three it expects: the switch LAN, desktop-02 (`10.0.50.90`), or Home
Assistant's read-only `homeassistant` user from `trinity` over the API.
The alert's labels name the user, the source address and the service.

```logql
{host="neo"} |= " logged in from "
```

- **Was it you?** SSH jumped through morpheus arrives as `10.7.7.1` and does
not fire. A login straight from `prometheus` or another Winterfell host does,
because no pass for it is supposed to exist.
- **If it was not you, end the session first.** From the switch LAN or WinBox
by MAC, `/user active print` shows it, and `/user active request-logout`
with its number ends it. Then change that user's password or key, and read
`/log print where topics~"system"` around the login for any change made.
- **Then find the path.** A source outside the switch LAN reached the switch
through a pass on morpheus, or through the switch's own management list
being wider than the firewall. `network.md`'s LAN notes name every pass
that should exist. Anything else on the switch LAN interface is the fault.

## TerminalSegmentReachedInternalNetwork

pfSense **passed** a packet from VLAN 10, 20 or 40 toward VLAN 30, 50 or 99,
Expand Down
18 changes: 18 additions & 0 deletions docs/runbooks/restore-the-firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,24 @@ ssh root@10.0.99.1 'pfctl -sr | grep -c "<Tunnel_Peers>"'
# makes every rule using it match nothing, which reads as "no leaks".
```

```bash
# 7. Are both log streams back? The syslog-ng package and its objects come back
# with config.xml, including neo's source and the switch-LAN pass
# (ADR-0127), but the TLS files it relays with do not: they sit outside
# config.xml. Copy them back first, as ship-firewall-logs.md §3 step 2
# says, then restart the service from Status → Services.
ssh admin@10.0.99.1 'ls /usr/local/etc/syslog-ng/tls/; sockstat -4l | grep syslog-ng'
# expect ca.pem, morpheus-key.pem and morpheus.pem, and listeners on
# 127.0.0.1:5140 (pfSense's own log) and 10.7.7.1:5514 (neo's)

# On prometheus, a few minutes later:
curl -sG http://localhost:3100/loki/api/v1/query \
--data-urlencode 'query=sum by (host) (count_over_time({source="network"}[10m]))' \
| jq -r '.data.result[] | "\(.metric.host)\t\(.value[1])"'
# expect a count for both morpheus and neo. Missing both: the TLS files or
# syslog-ng. Missing only neo: the pass on igc0 or the s_neo source.
```

> [!NOTE]
> Step 4 matters more than it looks. A restore that brings back connectivity but
> not the rule set leaves the house on a flat network that *appears* to work
Expand Down
Loading