> For the complete documentation index, see [llms.txt](https://docs.layeronecloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layeronecloud.com/pve-microvm/networking.md).

# Networking & Storage Sharing

Source project: `pve-microvm` (migrated from `docs/networking.md`). Run commands from the code checkout and directory specified below, not from this documentation repository.

## Network model (v0.3.8+) <a href="#network-model-v038" id="network-model-v038"></a>

Microvms use **systemd-networkd** directly — no cloud-init required.

* **DHCP by default**: `20-microvm-dhcp.network` matches all ethernet interfaces by `Type=ether` — no MAC dependency, survives cloning.
* **Static IP**: write `/etc/microvm-static-net`:

  ```bash
  echo "ADDRESS=10.0.0.5/24 GATEWAY=10.0.0.1 DNS=1.1.1.1" > /etc/microvm-static-net
  reboot
  ```
* **No cloud-init drive** (scsi1) needed.
* **No MAC matching** — works with any interface name (`eth0`, `enp0s5`, etc.)

## Network interfaces <a href="#network-interfaces" id="network-interfaces"></a>

Uses `virtio-net-pci-non-transitional` with PCIe.

```bash
qm set 900 --net0 virtio,bridge=vmbr0              # Single NIC
qm set 900 --net0 virtio,bridge=vmbr0,tag=100       # VLAN
```

DHCP is configured via cloud-init and systemd-networkd (or dhclient fallback).

## Sharing host directories <a href="#sharing-host-directories" id="sharing-host-directories"></a>

### virtiofs (high performance, needs daemon) <a href="#virtiofs-high-performance-needs-daemon" id="virtiofs-high-performance-needs-daemon"></a>

```bash
# Host: start sharing before VM boot
pve-microvm-share 900 /path/to/workspace

# Start the VM, then inside guest:
mount -t virtiofs shared /mnt/shared

# Stop sharing:
pve-microvm-share 900 --stop
```

### 9p (simpler, no daemon) <a href="#id-9p-simpler-no-daemon" id="id-9p-simpler-no-daemon"></a>

```bash
# Host: configure before VM boot
pve-microvm-9p 900 /srv/data mytag

# Start VM, then inside guest:
mount -t 9p mytag /mnt/data -o trans=virtio,version=9p2000.L

# Management:
pve-microvm-9p 900 --list
pve-microvm-9p 900 --remove mytag
pve-microvm-9p 900 --clear
```

### Comparison <a href="#comparison" id="comparison"></a>

|             | virtiofs             | 9p                   |
| ----------- | -------------------- | -------------------- |
| Daemon      | virtiofsd required   | None (QEMU built-in) |
| Performance | Better for large I/O | Good for most uses   |
| Setup       | More complex         | Simpler              |
| Hot-add     | No (before boot)     | No (before boot)     |

## SSH agent forwarding (vsock) <a href="#ssh-agent-forwarding-vsock" id="ssh-agent-forwarding-vsock"></a>

Forward host SSH keys into the guest without exposing them:

```bash
# Host:
pve-microvm-ssh-agent 900

# Guest:
export SSH_AUTH_SOCK=/tmp/ssh-agent.sock
socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork VSOCK-CONNECT:2:2222 &
ssh-add -l              # lists host keys
git clone git@github.com:org/repo.git
```

## vsock communication <a href="#vsock-communication" id="vsock-communication"></a>

Each microvm gets a vsock CID (VMID + 1000). Host and guest communicate without networking:

```bash
# Host → Guest:
socat - VSOCK-CONNECT:<cid>:<port>

# Guest → Host (CID 2 = host):
socat - VSOCK-CONNECT:2:<port>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.layeronecloud.com/pve-microvm/networking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
