How Hatch Networking Works
Hatch creates a virtualized network infrastructure for your VMs:Bridge Network
A Linux bridge (default:
fcbridge) connects all VM TAP devices. The bridge is configured with a CIDR range (e.g., 192.168.241.1/24).TAP Devices
Each VM gets a dedicated TAP device (e.g.,
fctap-vm-abc12) attached to the bridge, providing layer-2 connectivity.DHCP Server
A dnsmasq instance runs on the bridge, assigning IPs to VMs via DHCP. MAC-to-IP reservations ensure consistent addressing.
Enabling Networking on VMs
Networking is enabled by default. When you create a VM, Hatch automatically:- IP allocation from the bridge CIDR pool
- Random MAC address generation
- TAP device creation and bridge attachment
- DHCP reservation for the VM
- SSH port forwarding (e.g., host:2200 → guest:22)
Custom IP Assignment
You can assign a static IP within the bridge CIDR range:Custom MAC Address
For advanced scenarios (e.g., license keys tied to MAC), specify a static MAC:Use the locally administered MAC prefix
02:fc: to avoid conflicts with physical hardware.Cloud-Init Network Configuration
Hatch automatically injects cloud-init data during VM creation. For custom network settings inside the guest:DNS and Internet Access
VMs automatically get DNS resolution and internet access through the host’s network:DHCP provides DNS servers
The dnsmasq DHCP server advertises DNS servers to VMs (typically the bridge gateway IP).
Bridge is masqueraded
The host enables IP forwarding and NAT (masquerade) for the bridge network, allowing VMs to reach the internet.
Configuring Custom DNS
To use specific DNS servers in your VMs, configure cloud-init:Disabling Networking
For isolated compute workloads that don’t need network access:guest_iporguest_macfields- TAP device or bridge attachment
- DHCP reservation
- SSH port forwarding
- Internet access
Network Information Fields
When networking is enabled, the VM object includes:| Field | Example | Description |
|---|---|---|
guest_ip | 192.168.241.10 | VM’s IP address on the bridge network |
guest_mac | 02:fc:00:00:00:01 | VM’s MAC address |
tap_name | fctap-vm-abc12 | Host TAP device name |
ssh_port | 2200 | Host port forwarded to VM port 22 |
enable_network | true | Whether networking is enabled |
SSH Access
Hatch automatically sets up SSH port forwarding for networked VMs:SSH port forwarding is restricted to the CIDR configured in
HATCH_SSH_ALLOWED_CIDR. By default, this allows connections from anywhere (0.0.0.0/0).Troubleshooting Network Issues
VM has no IP address
Symptoms:guest_ip is empty or null in API response
Possible causes:
- Networking is disabled (
enable_network: false) - IP allocation pool is exhausted
- DHCP server failed to start
Cannot SSH into VM
Symptoms: Connection refused or timeout when connecting to SSH port Possible causes:- VM is not in
runningstate - Firewall blocking SSH port
- iptables rule not created
- SSH daemon not running in guest
VM has no internet access
Symptoms: VM can ping bridge gateway but not external IPs Possible causes:- IP forwarding disabled on host
- Missing NAT/masquerade rule
- Host firewall blocking forwarded traffic
DHCP not assigning IP to VM
Symptoms: VM starts but doesn’t receive IP via DHCP Possible causes:- dnsmasq not running
- MAC/IP reservation missing
- DHCP lease file corrupted
Network Configuration Environment Variables
These variables control Hatch’s network behavior:| Variable | Default | Description |
|---|---|---|
HATCH_BRIDGE_NAME | fcbridge | Name of the Linux bridge |
HATCH_BRIDGE_CIDR | 192.168.241.1/24 | Bridge network CIDR |
HATCH_SSH_ALLOWED_CIDR | 0.0.0.0/0 | CIDR allowed to SSH into VMs |
HATCH_SSH_PORT_MIN | 2200 | Minimum SSH forwarding port |
HATCH_SSH_PORT_MAX | 2299 | Maximum SSH forwarding port |
Next Steps
Creating VMs
Learn how to create VMs with custom configurations
Reverse Proxy
Expose VM services via subdomain routing
Snapshots
Save and restore VM network state
Idle Management
Understand SSH session detection for idle monitoring