Overview
NetworkConfig is a Pydantic model that defines the network configuration for a microVM. It specifies the guest IP, gateway, TAP device, MAC address, and optional SSH port forwarding.
This model is immutable (frozen) and is typically created automatically by SmolVM when starting a VM.
Attributes
str
required
IP address assigned to the guest VM.
str
default:"172.16.0.1"
Gateway IP address (host side of the TAP device).
str
default:"255.255.255.0"
Network mask for the guest network.
str
required
Name of the TAP network device (e.g., “smol0”, “smol1”).
str
required
MAC address for the guest network interface.
int | None
default:"None"
Optional host TCP port forwarded to guest SSH port 22.When set, you can SSH to the guest using
ssh -p <ssh_host_port> root@localhost.Usage
Creating a NetworkConfig
Accessing Network Info from a VM
Using with the High-Level API
Network Architecture
SmolVM uses the following networking setup:- TAP Device: A virtual network interface on the host (e.g.,
smol0) - Guest IP: Private IP address in the
172.16.0.0/16range by default - Gateway IP: Host-side IP of the TAP device (default:
172.16.0.1) - NAT: Network Address Translation configured via nftables for internet access
- Port Forwarding: Optional TCP port forwarding for SSH access
Default IP Range
By default, SmolVM assigns guest IPs from172.16.0.0/16:
- Gateway:
172.16.0.1 - Guest VMs:
172.16.0.2,172.16.0.3, etc.
SSH Port Forwarding
Whenssh_host_port is set, you can access the guest via localhost:
- The guest IP is not directly routable
- You want to expose SSH on a predictable port
- You’re running behind a firewall
Example: Custom Network Configuration
Immutability
NetworkConfig is a frozen Pydantic model, meaning it cannot be modified after creation:
NetworkConfig instance.
