Skip to main content

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

guest_ip
str
required
IP address assigned to the guest VM.
gateway_ip
str
default:"172.16.0.1"
Gateway IP address (host side of the TAP device).
netmask
str
default:"255.255.255.0"
Network mask for the guest network.
tap_device
str
required
Name of the TAP network device (e.g., “smol0”, “smol1”).
guest_mac
str
required
MAC address for the guest network interface.
ssh_host_port
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:
  1. TAP Device: A virtual network interface on the host (e.g., smol0)
  2. Guest IP: Private IP address in the 172.16.0.0/16 range by default
  3. Gateway IP: Host-side IP of the TAP device (default: 172.16.0.1)
  4. NAT: Network Address Translation configured via nftables for internet access
  5. Port Forwarding: Optional TCP port forwarding for SSH access

Default IP Range

By default, SmolVM assigns guest IPs from 172.16.0.0/16:
  • Gateway: 172.16.0.1
  • Guest VMs: 172.16.0.2, 172.16.0.3, etc.

SSH Port Forwarding

When ssh_host_port is set, you can access the guest via localhost:
This is useful when:
  • 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:
To change network settings, create a new NetworkConfig instance.
  • VMConfig - VM configuration including network settings
  • VMInfo - Runtime VM information including network state
  • SmolVM - High-level VM API that uses NetworkConfig internally
Last modified on May 5, 2026