Link B (rpi wg-remote <-> linode wg0) depends on a permanent UPnP mapping
UDP 9999 -> 192.168.1.125:9999 for its inbound path, and the 15-minute
rosenpass-upnp.timer only logged to the journal when it could not re-assert
it. Two gaps closed:
* RosenpassPskRotationStalled gains absent(rosenpass_psk_rotation_age_seconds
{node="rpi", interface="wg-remote"}). Without it a dead metrics timer or
script on the Pi silently dropped the Link B series while the rule kept
reading healthy. No siriussec/wg-remote arm: that interface does not exist
there.
* rosenpass-upnp.sh now stamps its result to /run/rosenpass-upnp.present (1/0)
and rosenpass-metrics.sh reads that file into rosenpass_upnp_mapping_present
{node="rpi"} plus rosenpass_upnp_last_check_timestamp_seconds. The 60 s
metrics timer never calls upnpc (that would poll the IGD 1440x/day); a host
without the state file (siriussec) emits neither series. New
RosenpassUpnpMappingLost alert fires on value 0, on a state file older than
30 minutes (stopped timer / hung IGD, so a stale 1 cannot read healthy), or
on a missing series.
37 lines
1.5 KiB
Shell
Executable file
37 lines
1.5 KiB
Shell
Executable file
#!/bin/bash
|
|
# rosenpass-upnp.sh - re-assert the permanent UPnP mapping that gives the
|
|
# Linode a way back to Rosenpass on the Pi (UDP 9999 -> 192.168.1.125:9999).
|
|
#
|
|
# The home router's admin panel is inaccessible, so this mapping is the ONLY
|
|
# inbound path for the Rosenpass exchange on Link B (rpi wg-remote <->
|
|
# linode wg0). It is runtime state: a router reboot, a factory reset or a UPnP
|
|
# daemon hiccup drops it, and the failure is silent - the link keeps its last
|
|
# PSK and simply stops being post-quantum. Hence this timer.
|
|
#
|
|
# Idempotent: re-adding an identical permanent-lease mapping is a no-op, so it
|
|
# is safe to run on a schedule. Never prints key material (it handles none).
|
|
set -uo pipefail
|
|
|
|
LAN_IP=192.168.1.125
|
|
PORT=9999
|
|
DESC=rosenpass-pq
|
|
# Result of this run, read by rosenpass-metrics.sh (60 s textfile collector) so
|
|
# the mapping is observable without polling the IGD from that timer. /run is
|
|
# tmpfs: on a reboot the file is gone and the metric is absent until this unit
|
|
# runs again (OnBootSec=2min), which the alert treats as "unknown", not "lost".
|
|
STATE=/run/rosenpass-upnp.present
|
|
|
|
set_present() {
|
|
printf '%s\n' "$1" > "$STATE.tmp" && mv "$STATE.tmp" "$STATE"
|
|
}
|
|
|
|
out=$(upnpc -e "$DESC" -a "$LAN_IP" "$PORT" "$PORT" UDP 0 2>&1) || true
|
|
|
|
# upnpc prints the mapping as " 0 UDP 9999->192.168.1.125:9999 'rosenpass-pq'"
|
|
if ! upnpc -l 2>/dev/null | grep -q "${PORT}->${LAN_IP}:${PORT}"; then
|
|
set_present 0
|
|
logger -t rosenpass-upnp "mapping missing after re-assert: ${out}"
|
|
exit 1
|
|
fi
|
|
|
|
set_present 1
|