Networking and data plane
ArcBox provides guest connectivity by joining a VM network device to a host-side network path. The data plane is the part of that path that moves and transforms packets. It supplies guest addressing, routing, DNS, host proxy access, port exposure, and platform-specific links without requiring each guest to understand the host network.
Connectivity model
ArcBox separates the guest link from the host's external network. A guest sends frames through a virtual NIC, and ArcBox either processes those frames itself or connects them to a host network service. This boundary lets the same guest-facing services support macOS virtualization, Linux TAP networks, and container access.
flowchart LR
G[Guest VM and virtual NIC] --> L[Guest link]
L --> D[ArcBox data plane]
D --> E[Host sockets and platform network]
D --> C[Container network]
D --> H[Host services]
H --> D
D --> G
The normal shared network gives the guest outbound access through the host. Host-only networking limits traffic to the host and its guests. Bridged networking places the guest on an existing layer-2 network. Networking can also be disabled when a VM must have no network link.
| Network shape | Guest reach | Main use |
|---|---|---|
| NAT or shared | External networks through the host | Default VM connectivity |
| Host-only | Host and related private guests | Isolated development networks |
| Bridged | The selected host network | Direct network presence |
| None | No network | Offline or restricted VMs |
For a broader view of guest links and packet services, see Virtual networking and packet services.
Guest addressing
Guest addressing comes from the network that owns the link. On the shared VM path, DHCP gives the guest an address, gateway, and DNS server. On the Linux sandbox path, a per-VM TAP link reserves an address from a pool and gives the guest a stable link identity when the sandbox is activated.
The sandbox path can present a fixed guest address while the host uses a pool address for that sandbox. This separates the guest identity from the address that host routing and exposure use. Older snapshots can retain the pool address instead, so the host must know which link form is active.
References: virt/…/lib.rs• L67-109 virt/…/nat.rs• L16-45 virt/…/guest_network.rs• L75-108 virt/…/lib.rs• L327-388
Platform links
The macOS VM path uses a virtual device attachment that carries Ethernet frames to a host-side data plane. The VZ and HV backends use the same high-level packet services, while their device boundaries differ. If the custom file-handle path cannot start under VZ, ArcBox falls back to Apple's shared NAT so the VM can still have basic external access.
The HV path also supports a second network device for layer-3 access to the container network. With vmnet, that device reaches a host bridge through a relay. Without vmnet, the platform's managed NAT attachment supplies the bridge and ArcBox discovers it through the host network state.
References: virt/…/darwin.rs• L79-150 virt/…/darwin.rs• L292-420 virt/…/network.rs• L14-24 virt/…/network.rs• L237-243
Packet services
The packet services turn guest frames into useful network actions. They answer local link setup requests, forward eligible traffic through host sockets, and return replies as guest frames. The packet path treats reliable stream traffic differently from recoverable datagrams so that congestion does not silently break a TCP flow.
Packet processing
The macOS data plane classifies guest traffic before it chooses a service. ARP is answered locally. DHCP configures the guest. DNS is handled by the local resolver path. UDP and ICMP use host-side proxy paths, while TCP uses a bridge that establishes and moves stream data through host sockets.
The host-to-guest side returns frames through a bounded delivery path. Stream frames are preserved when the guest side is full, which applies backpressure to the host socket. Datagram replies may be discarded at a bounded queue limit because their protocols can recover or retry.
References: virt/…/mod.rs• L1-22 virt/…/mod.rs• L52-92 virt/…/guest_tx.rs• L1-18 virt/…/guest_tx.rs• L151-235
Address translation
NAT lets a guest use a private address while external services see the host-side network identity. ArcBox tracks active translated flows so reply packets return to the correct guest. The same goal is expressed in the Linux sandbox network as per-TAP translation between the pool address and the fixed guest address.
On Linux, the NAT network creates or attaches a bridge for the guest subnet. It enables forwarding and applies masquerade and bridge-to-external forwarding policy. Each VM or container endpoint receives a TAP link and an address from the configured pool. On macOS, the custom packet path performs the guest-facing translation and sends external traffic through host sockets. These are different platform paths with the same product behavior: private guests can reach outside networks without becoming directly reachable from them.
References: virt/…/nat.rs• L16-45 virt/…/nat.rs• L212-220 virt/…/nat.rs• L255-320 virt/…/nat.rs• L360-425 virt/…/nat.rs• L19-40 virt/…/lib.rs• L78-149
Host port exposure
Port exposure creates a host listener that sends traffic to a guest or sandbox service. TCP connections are copied in both directions. UDP uses the host sender address to return replies to the client, so each rule connects one host endpoint to one guest endpoint.
The guest agent also exposes selected guest-local services over vsock. The host can therefore reach the Docker API and Kubernetes API without placing those services on the guest's IP network. This is a service proxy boundary rather than a general packet route.
References: virt/…/port_forward.rs• L17-26 virt/…/port_forward.rs• L67-79 virt/…/port_forward.rs• L256-386 guest/…/proxy.rs• L1-18
See Host network integration for the host-side route and service boundaries that make exposed networks reachable.
Name resolution
ArcBox uses layered DNS so local VM and container names stay private while normal names still use the host's upstream DNS. The guest asks its gateway for names that it does not own. The gateway then resolves ArcBox names locally or forwards external queries upstream.
Guest DNS
The guest DNS server checks the container registry first and the sandbox registry second. It accepts both a registered name and its arcbox.local form. A known IPv4 name returns an address record. A known name without an IPv6 address returns an empty answer for an AAAA query.
If an A or AAAA query targets an unknown arcbox.local name, the guest returns NXDOMAIN instead of sending the internal name outside. Other query types and external names go to the gateway at 10.0.2.1:53. The reply must match the query transaction before the guest accepts it.
References: guest/…/dns_server.rs• L1-27 guest/…/dns_server.rs• L195-281
Host DNS
The daemon listens on a host-local UDP port and shares its local host table with the VMM-side resolver. A registered name resolves immediately from that table. An unknown name in the configured local domain returns NXDOMAIN, which prevents internal names from leaking to upstream DNS. Other names use the detected system resolver or the configured upstream servers, with response caching.
Container names can have more than one local alias. Compose metadata adds a service-and-project name as well as the flat container name. This lets clients use a service-level name without removing the direct container name.
References: app/…/dns_service.rs• L1-5 app/…/dns_service.rs• L53-110 virt/…/dns.rs• L247-287 virt/…/dns.rs• L301-368 guest/…/dns.rs• L37-59
Local discovery
mDNS extends local name access beyond clients that use the ArcBox DNS service. The responder listens on the link-local multicast group and answers A queries for known arcbox.local names. It announces new records when a VM or container becomes available and sends a zero-TTL goodbye when it stops.
The mDNS responder reads the same local host mappings as the unicast resolver. A name therefore has one source of truth even when a client changes from a direct DNS query to local multicast discovery.
References: virt/…/mdns.rs• L1-27 virt/…/mdns.rs• L132-145 virt/…/mdns.rs• L181-207 virt/…/mdns.rs• L279-343
Routing and integration
Guest egress and host ingress use different decisions. Guest egress follows the guest gateway and the selected NAT or bridge path. Host ingress needs a route to the container pool and a target that matches the active sandbox translation. ArcBox keeps these decisions coordinated across VM restarts and platform changes.
Container routes
The daemon maintains a route from the host to the container address pool through the bridge attached to the Linux VM. It finds the bridge from the VM's network identity, asks the helper to apply the route, and retries while the bridge or helper becomes ready.
If the preferred route is already owned by another service, ArcBox uses two more-specific routes as a sticky fallback. It does not replace routes that belong to another service. A custom pool that overlaps an external route is rejected instead of stealing traffic.
References: app/…/route_reconciler.rs• L104-177 app/…/route_reconciler.rs• L192-240 app/…/route_reconciler.rs• L373-406 app/…/route_reconciler.rs• L408-494
Sandbox ingress
Host ingress targets the address that the active TAP path can deliver. A directly translated or legacy TAP can receive traffic sent to its pool address. A filter-based invariant TAP needs the fixed guest address plus a mark that selects the TAP's routing table.
This distinction matters because the guest may always see the fixed invariant address while the host still routes by the pool address. The network adapter reports the correct ingress form to the service that builds port-forward rules.
References: virt/…/guest_network.rs• L167-186 virt/…/lib.rs• L132-149 virt/…/lib.rs• L630-643
Lifecycle state
Network state follows the VM lifecycle. Startup reserves guest addresses and prepares the network before services report readiness. VM restarts re-establish host routes and adopted sandbox links. Shutdown cancels packet relays, releases platform attachments, and removes routes or listeners owned by the current lifecycle.
The sandbox network uses durable cleanup state when a released address may still have host forwarding attached. It withholds that address until the host confirms cleanup, which prevents a new guest from receiving traffic intended for an old one.
References: app/…/services.rs• L65-88 app/…/services.rs• L163-172 virt/…/lib.rs• L345-376 virt/…/guest_network.rs• L194-253
Change checklist
When these files or sections are changed, remember to consider these:
- A change to the guest subnet, gateway, or DHCP range must stay aligned with guest DNS forwarding, NAT policy, host routes, and any fixed gateway values used by the VM path.
- A change to the local DNS domain or alias rules must stay aligned across the daemon resolver, guest resolver, mDNS announcements, and host resolver installation.
- A change to a VM network attachment or backend must preserve both the guest frame path and the host-to-guest reply path. Check the fallback behavior when the preferred platform service is unavailable.
- A change to the container CIDR must update route ownership checks and the target used for host ingress. Overlap checks must continue to protect routes owned by other services.
- A change to a port or proxy endpoint must keep the host listener, guest vsock listener, and service-local destination in agreement.
- A change to packet delivery or queue limits must preserve reliable TCP delivery while keeping bounded behavior for DNS, ARP, DHCP, UDP, and ICMP replies.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| DHCP or gateway setup does not reach the guest | The guest has no usable route or cannot reach DNS | The network path supplies DHCP with the gateway and DNS address used by the packet data plane |
| The custom macOS file-handle attachment cannot start | The VM loses ArcBox's custom packet services unless fallback is selected | VZ falls back to Apple's shared NAT attachment |
| The Linux NAT bridge, forwarding, or masquerade setup fails | Guest egress or endpoint attachment fails | NAT setup reports the failed network operation before the network becomes ready |
| The host container route is missing or points to the wrong bridge | Host-to-container traffic fails even when guest egress works | Route reconciliation checks bridge ownership and repairs the route after VM start and recovery |
| The preferred container route overlaps an external route | ArcBox could capture traffic for another network | The reconciler uses a split fallback or returns a route conflict; it does not replace external routes |
| A local name is not registered | Queries in the configured local domain return NXDOMAIN | The host and guest resolvers treat the local domain as authoritative |
| An upstream DNS server fails or returns an invalid reply | External lookups return SERVFAIL or move to the next upstream | Forwarding uses timeouts, connected sockets, transaction-ID checks, and upstream retry order |
| A host port is already in use | The guest service is not reachable through that published port | Port-forward startup fails the rule bind instead of claiming a different endpoint silently |
| A released sandbox still has host forwarding state | A new sandbox could receive old traffic | Durable quarantine keeps the address out of the pool until cleanup is finalized |
Key files
| File | Why to read it |
|---|---|
| virt/…/lib.rs | Defines the top-level network modes, manager lifecycle, address allocation, and shared DNS boundary. |
| virt/…/nat.rs | Defines the shared NAT settings and the Linux bridge, endpoint, forwarding, and address-allocation model. |
| virt/…/mod.rs | Shows how guest Ethernet frames are classified into ARP, DHCP, DNS, TCP, UDP, and ICMP services. |
| virt/…/dns.rs | Explains the shared local-name and upstream DNS behavior used on the host and in the VMM. |
| guest/…/dns_server.rs | Shows the guest lookup order and the gateway boundary for external DNS. |
| virt/…/darwin.rs | Shows how the VZ VM selects its custom network path, fallback NAT, and second routing NIC. |
| virt/…/network.rs | Shows how the HV backend connects the guest NIC, packet services, and vmnet bridge path. |
| virt/…/lib.rs | Describes the Linux sandbox pool, TAP links, invariant guest identity, and host ingress choices. |
| app/…/route_reconciler.rs | Describes host route ownership, conflict handling, bridge discovery, and repair after VM lifecycle changes. |
| virt/…/port_forward.rs | Defines the host-to-guest TCP and UDP exposure model. |