fix(network): wire default route + bridge DNS for isolated containers
When isolateContainers=true, claude (and all egress) broke in every container: agents came up with an IP but no way off the bridge subnet. Two container-side gaps, both confirmed against nixpkgs nixos-containers.nix: 1. No default route. hive-priv wrote HOST_ADDRESS= empty in the nspawn conf. nixos-container's container-side setup only installs `ip route add default via $HOST_ADDRESS` when HOST_ADDRESS is non-empty, so the container had an address but no gateway -> nothing off-subnet (incl. api.anthropic.com) was reachable. Fix: write HOST_ADDRESS=<bridge-ip>. In bridge mode the host-side address/route setup is skipped, so this only affects the container's default route. 2. No usable resolver. nixos-container copies the host's /etc/resolv.conf into the container at every start; the host resolver (e.g. 127.0.0.53) is unreachable from a private netns and isn't authoritative for the hive's own zones. Fix: hive-priv drops a marker carrying the gateway IP only when isolated, and a new harness-base oneshot (hyperhive-isolated-dns) rewrites resolv.conf to point at the bridge dnsmasq. Inert in shared-netns mode (no marker), so the shared container toplevel does the right thing in both modes. The gateway IP is the address part of HIVE_NETWORK_SUBNET (the bridge IP verbatim, honouring a non-.1 operator override), via a new validated bridge_gateway_ip() helper with unit tests. Unblocks defaulting isolation on.
This commit is contained in:
parent
8db8bd610f
commit
d993ad2c47
4 changed files with 177 additions and 4 deletions
|
|
@ -105,6 +105,15 @@ pub struct NetworkIsolation {
|
|||
pub agent_ip: String,
|
||||
/// Host bridge interface name (e.g. `hive0`).
|
||||
pub bridge: String,
|
||||
/// Bridge gateway IP (the host-side bridge address, e.g. `10.42.0.1`).
|
||||
/// Written as `HOST_ADDRESS=` in the nspawn conf so nixos-container's
|
||||
/// container-side setup installs a default route (`default via <gw>`):
|
||||
/// without it the container comes up with an address but no route off
|
||||
/// the bridge subnet — no internet, no `api.anthropic.com`. The same IP
|
||||
/// runs the hive dnsmasq resolver, so it's also written into the
|
||||
/// container's `/etc/resolv.conf` (see the isolated-DNS oneshot in
|
||||
/// `harness-base.nix`, gated on the marker hive-priv drops).
|
||||
pub gateway_ip: String,
|
||||
}
|
||||
|
||||
/// A request to the privileged helper.
|
||||
|
|
|
|||
Loading…
Reference in a new issue