From c572066f87d0eda6e236373a451d15b24365b666 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 00:39:36 +0000 Subject: add networking Give the guest a virtio-net interface backed by the host tap device fctap0, with a static address (172.16.0.2/24, gateway 172.16.0.1) set up by systemd-networkd, and 9.9.9.9 as nameserver. host.nix is a NixOS module for the host that creates fctap0, owned by the given user, and NATs it: imports = [ (import ./host.nix "tv") ]; Firecracker refuses to start if fctap0 doesn't exist. --- host.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 host.nix (limited to 'host.nix') diff --git a/host.nix b/host.nix new file mode 100644 index 0000000..3368677 --- /dev/null +++ b/host.nix @@ -0,0 +1,15 @@ +# Host side of the guest's network: a tap device owned by the user running +# the VM, NATed to the outside world. +# usage (in the host's configuration.nix): imports = [ (import ./host.nix "tv") ]; +user: { + networking.interfaces.fctap0 = { + virtual = true; + virtualType = "tap"; + virtualOwner = user; + ipv4.addresses = [{ address = "172.16.0.1"; prefixLength = 24; }]; + }; + networking.nat = { + enable = true; + internalInterfaces = [ "fctap0" ]; + }; +} -- cgit v1.3.1