internet_settings when a sandbox should run with no outbound access, or should only reach a short list of IPv4 destinations. SmolVM enforces the policy on both Firecracker and QEMU, validates it before allocating any resources, and preserves it across the sandbox’s lifetime.
Choose a mode
Copy-paste a policy declaration:
internet_settings={"mode": "off"} or {"mode": "restricted", "allowed_cidrs": [...]} on SmolVM(...), SmolVM.from_image(...), or VMConfig(...).
Platform coverage
These controls apply to Linux guests. Windows and macOS guests are not included. SmolVM never switches a QEMU sandbox to TAP automatically; opt in with
network="tap" on SmolVM.from_image or qemu_network="tap" on VMConfig.
Turn outbound access off
QEMU can block outbound access on both macOS and Linux while keeping local application access and shared folders available:slirp uses QEMU’s built-in restriction and disables IPv6. Launch-time port forwards continue to work.
On Linux, Firecracker also supports off mode when commands and files use the direct vsock connection:
off mode blocks all guest-initiated IP traffic, including DNS and connections to your machine. Command output and explicit file downloads still leave the sandbox through the direct vsock connection.
Allow specific IPv4 destinations
Userestricted with the addresses or network ranges the task needs. This mode requires Firecracker on Linux with comm_channel="vsock", or explicit QEMU TAP networking on Linux.
With a prepared BootImage named image:
203.0.113.10 with your application’s destination. /32 allows one address; a range such as 10.20.0.0/24 allows multiple addresses. Bare IPv4 addresses are accepted too. Overlapping ranges are combined.
For direct VMConfig construction, use backend="qemu", qemu_network="tap", and the same internet_settings. See Network configuration for the required Linux TAP setup.
Only listed destinations can receive new outbound connections, on any port or protocol. IPv6 and sandbox-initiated connections to your machine are blocked. Sandbox and link-local ranges (including the common cloud metadata address 169.254.169.254) cannot be allowed. DNS is not added automatically, so either connect by IP address or explicitly include the resolver’s address; allowing a resolver permits other traffic to that same address too.
In off and restricted TAP modes, the sandbox can reply to IPv4 TCP connections initiated by your machine. This keeps applications, SSH, and shared-folder setup usable without allowing new outbound connections.
Validate before allocating resources
SmolVM validates a policy before it prepares images, boots the VM, or reserves host resources. Invalid settings raisesmolvm.ValidationError from public SmolVM methods, and Pydantic’s ValidationError from direct InternetSettings or VMConfig construction:
- Unknown fields (for example, misspelling
modecannot silently enable internet access). - Unsupported options such as
allowed_portsor non-wildcardallowed_http_methods. restrictedwithout anyallowed_cidrs, orallowed_cidrswithoutmode="restricted".- IPv6, sandbox, and link-local ranges.
- Combining
modewithallowed_domains. - Unsupported backend, OS, or network combinations (for example, QEMU
restrictedon macOS, oroff/restrictedwith bridged networking).
Interactions with other features
- Shared folders and exposed ports. Firecracker
offandrestricteddo not support shared folders or exposed ports; omitmounts,port_forwards, andworkspace_mounts. QEMU keeps both available:slirpretains configured launch-timeport_forwardsacross restart and snapshot restore, and TAP applications use their guest IP orexpose_local()instead. - SSH command channel. Firecracker
offandrestrictedrequirecomm_channel="vsock". SSH cannot reach a sandbox with no outbound path back to your machine. - Bridged networking. Bridge mode ignores private-network policy;
internet_settingsother thanopenis rejected. - Legacy
allowed_domains. Existing callers can still passallowed_domainson Firecracker private networking or QEMU TAP. SmolVM resolves each name to IPv4 addresses at setup and allows traffic to those addresses on any port. Do not combineallowed_domainswithmode; HTTP-method restrictions are rejected.
Reach an application inside the sandbox
Network restrictions do not prevent your machine from reaching an application inside a QEMU sandbox. Have the application listen on0.0.0.0, then expose it:
slirp or localhost forwarding on TAP. They do not require SSH or a guest agent when the application listens on the guest network address. An application bound only to the guest’s 127.0.0.1 needs guest_loopback=True, which routes through guest SSH.
Dynamic exposures keep their existing lifetime, so recreate them after pause, stop, or restore.
Policy lifetime
The policy is saved with the sandbox and stays unchanged acrossstart, network repair, restart, and supported snapshot restore. Reconnecting to a sandbox by vm_id also inherits the saved policy.
Policy changes apply only to newly created sandboxes. Existing sandboxes keep their prior policy; to change a running sandbox, create a new one with the desired internet_settings.
After upgrading SmolVM, running sandboxes keep their current network rules until SmolVM repairs their networking or they restart. Restart them to apply the updated baseline isolation.
Snapshots and imported disks
A disk imported as a new image receives the policy from its new VM configuration; the disk does not carry a network policy by itself. QEMU shared folders continue to work withoff and restricted. Their normal setup requirements still apply. QEMU snapshots require an isolated qcow2 disk and do not support shared folders.
If custom create and restore workflows share an inventory, pass the same state manager:
Allow domains at startup
You can also allow domains on Firecracker private networking or QEMU TAP. This Linux Firecracker example keeps the command connection available throughvsock:
allowed_domains with mode. HTTP-method restrictions are not supported.
