Just lab
Debian >=12
Rust >=1.74 nightly
Dockerapt install cmake
apt install gcc
apt install clangThe first step on the host is to create a tap device:
ip tuntap add tap0 mode tapThen you have a few options for routing traffic out of the tap device, through your host's network interface. One option is NAT, set up like this:
ip addr add 172.16.0.1/24 dev tap0
ip link set tap0 up
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i tap0 -o eth0 -j ACCEPTFirecracker requires the KVM Linux kernel module.
The presence of the KVM module can be checked with:
lsmod | grep kvmAn example output where it is enabled:
INTEL
kvm_intel 348160 0
kvm 970752 1 kvm_intel
irqbypass 16384 1 kvmAMD
kvm_amd 155648 0
ccp 118784 1 kvm_amd
kvm 1142784 1 kvm_amd
irqbypass 16384 1 kvm# build kernel and rootfs
chmod +x ./script/build_image.sh
./script/build_image.sh kernel
./script/build_image.sh rootfs# run
cargo run