Posts

Showing posts from January, 2024

Connecting a Cloud Hypervisor guest to the internet using NAT

Cloud Hypervisor is a Virtual Machine Monitor (VMM) for modern cloud workloads. Recently, I found myself in the need of a simple way to connect a Cloud Hypervisor guest to the internet. Unfortunately, no such method has been documented in the in-tree documentation . So, I set out experimenting with iptables and NAT (network address translation). After playing around with the iptables rules required to set this up I finally arrived at a simple setup that worked. For this to work, Cloud Hypervisor needs to be started with the --net argument like so: cloud-hypervisor \ --kernel ./vmlinux.bin \ --cmdline "console=ttyS0 root=/dev/vda1 rw" \ --disk path=/home/cloud/focal-server-cloudimg-amd64.raw path=/home/cloud/ubuntu-cloudinit.img \ --cpus boot=8 \ --memory size=0 \ --memory-zone id=mem0,size=4G,host_numa_node=0 \ --net "tap=,mac=12:34:56:78:90:ab,ip=192.168.249.1,mask=255.255.255.0" \ --serial tty \ ...