1# Using MACVTAP to Bridge onto Host Network 2 3Cloud Hypervisor supports using a MACVTAP device which is derived from a MACVLAN. Full details of configuring MACVLAN or MACVTAP is out of scope of this document. However the example below indicates how to bridge the guest directly onto the network the host is on. Due to the lack of hairpin mode it not usually possible to reach the guest directly from the host. 4 5```bash 6# The MAC address must be attached to the macvtap and be used inside the guest 7mac="c2:67:4f:53:29:cb" 8# Host network adapter to bridge the guest onto 9host_net="eno1" 10 11# Create the macvtap0 as a new virtual MAC associated with the host network 12sudo ip link add link "$host_net" name macvtap0 type macvtap 13sudo ip link set macvtap0 address "$mac" up 14sudo ip link show macvtap0 15 16# A new character device is created for this interface 17tapindex=$(< /sys/class/net/macvtap0/ifindex) 18tapdevice="/dev/tap$tapindex" 19 20# Ensure that we can access this device 21sudo chown "$UID.$UID" "$tapdevice" 22 23# Use --net fd=3 to point to fd 3 which the shell has opened to point to the /dev/tapN device 24target/debug/cloud-hypervisor \ 25 --kernel ~/src/linux/vmlinux \ 26 --disk path=~/workloads/focal.raw \ 27 --cpus boot=1 --memory size=512M \ 28 --cmdline "root=/dev/vda1 console=hvc0" \ 29 --net fd=3,mac=$mac 3<>$"$tapdevice" 30``` 31 32As the guest is now connected to the same L2 network as the host you can obtain an IP address based on your host network (potentially including via DHCP) 33