Files
Pulse/pkg/agents/host
rcourtman 5045360d7d Report each host's default gateway and DNS servers (#4607)
## What

The host agent reports each machine's IPv4 default gateways and DNS
servers, and the server carries them to the host model, the agent facet
of the resource (`agent.defaultGateways`, `agent.dnsServers`) and the
frontend type.

## Why

Pulse knew every address a machine holds and nothing about where it
sends traffic for other networks or where it resolves names. No router,
gateway or resolver could appear anywhere in the product, because
nothing collected one.

## Behaviour to know

- Gateways come from `/proc/net/route`: default routes that go through a
gateway, lowest metric first, each with its interface. Linux only, IPv4
only.
- DNS servers come from `/etc/resolv.conf`, in the file's order. When
that holds only loopback addresses and
`/run/systemd/resolve/resolv.conf` names servers, those are reported,
because the systemd-resolved stub says nothing about where names are
resolved. A host that runs its own resolver on loopback keeps the
loopback address.
- Two or three small local file reads per report. No command is run and
no permission or flag is needed.
- The server accepts only IP addresses and an interface name, stores
addresses in canonical form, and keeps at most eight of each.
- A report without the block (an older agent, or a platform with no
readable route table) leaves both lists missing. That is unknown, never
"no gateway".
- The legacy host row sent to the frontend state is unchanged. Nothing
reads the fields yet.

## Checked

- Unit tests: route-table and resolv.conf parsing (metric order,
duplicates, routes that name no next hop, comments, bounds), the
systemd-resolved stub and a real local resolver, the agent report,
ingest validation, the model clone, the adapter, wire shape, clone and
view, frontend types and the resource read.
- The parser inputs match real files read from an Unraid host
(`nameserver 192.168.0.1 # eth0:v4`), a Proxmox node on Tailscale DNS,
and an Ubuntu VM behind the systemd-resolved stub.
- A rig: Pulse and `pulse-agent` built from this branch on a real Ubuntu
24.04 machine. See the receipt for the values observed.

## Not in this PR

- Drawing it on the infrastructure map.
- IPv6 default routes, and gateways on macOS, Windows and FreeBSD.
- Gateway and DNS for a Proxmox node with no agent, which the PVE API
could supply.
- Mock data.
2026-11-18 15:27:18 +00:00
..