Host Network Commands
3 minute read
Every Linux node gets two NICs: one reaches the Internet through QEMU’s built-in NAT, and one sits on a fixed /24 where the host and the other nodes reach it at the address your inventory names (why two NICs). These commands manage the host side of that second network, socket_vmnet on macOS and the barn0 bridge on Linux. barn setup and the first interactive barn up install it for you (host preparation); use these commands to check, repair, reconfigure, or remove it.
One network serves all Linux guests on the host; native Mac VMs have their own. install and uninstall print a privileged plan first and, on a terminal, ask before applying it. Without a terminal, or with --json or --yaml, they only print the plan; --yes applies it without asking, though sudo may still want a password.
barn network also answers to n and net. Every command accepts the global options; Available in shows availability from the 1.1.0 baseline onward (version baseline).
barn network status
Show the backend, installed CIDR, ownership, health, and the preflight findings that lifecycle commands check before changing anything. It is read-only. --cidr checks against an expected subnet; without it, status inspects the installed one. For partial or invalid results, see troubleshooting.
On Linux, 1.5.0 checks KVM access, bridge prerequisites and the configured private network. Run barn doctor for the full QEMU capability check.
Aliases: st.
| Option | Meaning / default | Available in |
|---|---|---|
-c, --cidr string | Optional expected private /24; otherwise inspect the installed subnet | 1.1.0 |
barn network install
Install or repair the backend for --cidr: socket_vmnet on macOS in host or shared vmnet mode, or barn0 through the active Linux network manager, which accepts only host. An existing network must match the chosen subnet and mode, so check status before changing either.
On a fresh Mac, run barn setup instead. A first install needs a pinned socket_vmnet archive and a new vmnet interface UUID, which setup supplies; without both --archive and --interface-id, network install exits 3 with reason network_absent and suggests barn setup. Both flags are macOS-only.
Aliases: i.
| Option | Meaning / default | Available in |
|---|---|---|
-a, --archive string | macOS: pinned socket_vmnet archive | 1.1.0 |
-c, --cidr string | network: an RFC1918 IPv4 /24 (default “10.10.10.0/24”) | 1.1.0 |
-i, --interface-id string | macOS: persistent vmnet UUID | 1.1.0 |
-m, --mode string | macOS vmnet mode: host or shared (default “host”) | 1.1.0 |
-y, --yes | apply the displayed privileged plan without confirmation (sudo may still ask for a password) | 1.1.0 |
macOS Internet Sharing
Install and repair work while Internet Sharing is on, as long as its vmnet preferences set neither a custom subnet address nor a mask. If the preview cannot read those preferences, it says so, and Barn checks them after you approve, before writing network files or restarting socket_vmnet. A subnet that conflicts with a live interface, route, or node address blocks the plan at preview. Preferences that turn out unreadable, conflicting, or only half set stop the operation before the host changes.
barn network uninstall
Remove Barn-owned network configuration and restore the host settings recorded at install. Stop the Linux nodes first; uninstall refuses while any node is running. The terminal question, Remove the Barn network? [y/N], defaults to no. VM disks and native Mac VM networks stay in place.
Aliases: u.
| Option | Meaning / default | Available in |
|---|---|---|
-y, --yes | apply the displayed privileged plan without confirmation (sudo may still ask for a password) | 1.1.0 |
Implementation
The 1.5.0 status checks are in cmd/barn/command_network.go and internal/doctor/network.go.