Overview
NetworkConfig is a Pydantic model that defines network settings for a SmolVM microVM, including IP addresses, gateway configuration, and SSH port forwarding.
Class Definition
Fields
IP address assigned to the guest VM.Example:
"172.16.0.2"Gateway IP address (host side of the TAP device).This is the IP address that the guest uses as its default gateway to route traffic to the host.
Network mask for the guest network.Defines the subnet size for the VM’s private network.
Name of the TAP network device.Example:
"tap0", "smolvm-tap1"MAC address for the guest network interface.Must be a valid MAC address in the standard format.Example:
"AA:FC:00:00:00:01"Optional host TCP port forwarded to guest SSH (port 22).When set, allows SSH access to the guest VM via
localhost:<ssh_host_port> on the host machine.Example: 2222Usage Example
Accessing from VMInfo
Network configuration is typically accessed through a VM’s runtime information:Properties
- Immutable:
NetworkConfigis frozen (Pydanticmodel_config = {"frozen": True}), meaning fields cannot be modified after instantiation. - Type-validated: All fields are validated by Pydantic according to their type annotations.