16. Proxy redirect and IPv6 (macOS)
16. Proxy redirect and IPv6 (macOS)¶
Added while planning Plan 2, after probes with container 1.7.1 showed that
a job network's host address (the .1 on its bridgeNNN interface) exists
only while a VM on that network runs. The proxy can't listen there before
the job's VM boots, so the job's first connection could race it. Gavin
chose to have pf redirect each job network's <gateway>:3128 to one
proxy listening on loopback. The same probes showed that every job network
also gets IPv6 (a ULA prefix, and an fe80:: address on the Mac's bridge),
which #14's anchor didn't cover.
Predictions¶
Written before running.
| Check | No anchor | Anchor, IPv4 rules only | Anchor with IPv6 block |
|---|---|---|---|
https://example.com through <gateway>:3128, proxy on 127.0.0.1:3128 only |
fails (nothing listens on the gateway) | 200; the proxy logs the VM's own address as the client | 200 |
Direct TCP to a canary on [::] at the gateway, the Mac's LAN and tailnet addresses |
connects (#14's gap) | blocked | blocked |
Direct TCP to the canary at the Mac's fe80:: address on the bridge |
connects | connects (the IPv6 gap) | blocked |
| Direct TCP 1.1.1.1:443 | blocked | blocked | blocked |
| A VM killed by its memory limit (#10's writer) | container logs --boot holds an OOM line |
Setup (2026-11-23)¶
- The MacBook as in #9–#14,
container1.7.1. spike/macos_pf_rdr.sh v4|full|off: anchorcom.apple/allmyramover the pool 192.168.128.0/18 with a table of its 64 gateways;rdr passof TCP from the pool to a gateway port 3128 to127.0.0.1:3128;fulladdsblock drop in quick on bridge inet6 all(thebridgeinterface group).spike/macos_rdr_check.py: networkallmyram-rdr-check(192.168.150.0/24,--internal),spike/egress_proxy.pyon127.0.0.1:3128, a dual-stack canary listener on[::], and a probe VM (--no-dns) that finds the Mac's link-local address by pingingff02::1%eth0and readingip -6 neigh.
Raw results¶
spike/macos_rdr_check.py, three host addresses (two LAN, one tailnet),
canary on [::]:
| Check | No anchor | Anchor v4 |
Anchor full (on bridge) |
|---|---|---|---|
https://example.com through <gateway>:3128 |
connection refused | 200 | 200 |
| Proxy's logged client | — | 192.168.150.2 (the VM) |
192.168.150.2 |
| Direct TCP 1.1.1.1:443 | timed out | timed out | timed out |
| Canary at gateway, 2 LAN addresses, tailnet address | connected (all 4) | timed out (all 4) | timed out |
Canary at the Mac's fe80::5c9b:a6ff:fe77:b864%eth0 |
connected | connected | connected |
- The probe found the Mac's link-local address with
ping -6 -c 2 -W 1 ff02::1%eth0andip -6 neigh show dev eth0. The canary logged the VM's link-local address as the source: VM and Mac talk link-local to link-local, so a VM's IPv6 subnet (--subnet-v6) never appears in this traffic. on bridgeparses but matches nothing: macOS puts vmnet bridges (bridge100, …) in no interface group. Namingbridge100–bridge199would match, but would also cut IPv6 between the Mac and every other apple/container VM on it, which Gavin ruled out: allmyram must not affect anything else running on the machine. Not loaded.- apple/container 1.7.1 can't make a network without IPv6.
network create --optionis parsed and then ignored by the vmnet plugin, which sets only the IPv4 subnet and the IPv6 prefix (Sources/Plugins/NetworkVmnet/ReservedVmnetNetwork.swift). vmnet hasvmnet_network_configuration_disable_nat66and…_disable_router_advertisement, which apple/container doesn't call, and nothing that removes the host'sfe80::address. --kernel-arg ipv6.disable=1turns IPv6 off in the job's VM, and root in the VM can't turn it back on. The guest kernel (6.18.56) hasCONFIG_IPV6=y,CONFIG_MODULESunset and no kexec. There are nonet.ipv6sysctls, andsocket(AF_INET6)fails withEAFNOSUPPORT.localhostresolves to127.0.0.1only, and binding it works.-
OOM: #10's writer (512 MiB under
--memory 256M) exits 137, andcontainer logs --bootholdsMemory cgroup out of memory: Killed process 127 (python3). -
With
ipv6.disable=1, a root job still has raw sockets: anAF_PACKETsocket oneth0receives the Mac's IPv6 traffic fromfe80::5c9b:a6ff:fe77:b864, continuous UDP that looks like mDNS announcements, port not checked. A hand-built ICMPv6 echo toff02::1got no reply, but the probe was crude (no proof the frame was well formed), so this doesn't show the path closed: a user-space IPv6 stack overAF_PACKETneeds nothing from the guest kernel's IPv6.--cap-drop CAP_NET_RAWmakes the raw socket fail withEPERM. --network noneboots a VM with onlylo(127.0.0.1and::1) and no path anywhere.--publish-socket <mac path>:<vm path>works into such a VM: a process on the Mac connected to a Unix socket a process in the VM listened on (the Mac-side path must fit a Unix socket's ~104 bytes).
What we learned¶
- One proxy on loopback, reached through
rdr, works, and the proxy sees each VM's own address, so run IDs map as on Linux. - The IPv4 anchor scoped to the job pool closes #14's gap for IPv4 without touching anything else on the Mac.
- IPv6 is a second path to the Mac's own services, and apple/container
gives no way to close it for our VMs alone from the host. The only host
rule that works covers every apple/container VM on the Mac, which Gavin
ruled out: allmyram must not affect anything else running on the machine.
Guest-side settings (
ipv6.disable=1, droppingCAP_NET_RAW) are enforced by the job's own kernel, against a job that is root in it. - A VM with no network is isolated by construction, but reaching the proxy, services and other containers would then mean forwarding each port over sockets. Gavin: allmyram is to support Docker Compose jobs more or less in full, so a job's containers need a real network between them.
- A Mac runner can report
OOMKilledfrom the boot log.
What it changes¶
- One
apple/containerVM per container is not a workable macOS backend: it can't give a job's containers a shared network without also giving them a path to the Mac's own services. The next candidate is the one the spec rejected, Lima running containerd and gVisor, which reuses the Linux backend; the spec rejected it for a long-lived VM building up state and its standing memory. Gavin: the way to keep the memory goal is to start and stop the Lima VM quickly, so it holds memory only while there is work. Experiment 17 measures that.