# Create a bridge and add two ports $ sudo ip link add name atx-fabric0 type bridge $ sudo ip link set up dev atx-fabric0 $ sudo ip tuntap add atx-fabric0i1p1 user $USER group $USER $ sudo ip tuntap add atx-fabric0i2p1 user $USER group $USER # create two focal VM images from focal daily server $ qemu-img create -f qcow2 -b focal-server-cloudimg-amd64.img focal-net1.img 100G $ qemu-img create -f qcow2 -b focal-server-cloudimg-amd64.img focal-net2.img 100G # create cloud-init seed $ cat >user-data < meta-data $ cloud-localds seed.img user-data meta-data # Launch VM1 (need sudo for bridge access) BOOT=focal-net1.img SEED=seed.img sudo qemu-system-x86_64 -smp 2 -m 2048 --enable-kvm \ -global pc35.no_floppy=1 \ -name "${1}" \ -drive id=disk0,if=none,format=qcow2,file=${BOOT} \ -device virtio-blk-pci,drive=disk0,bootindex=0 \ -drive id=cdrom0,if=none,media=cdrom,file=$SEED \ -device virtio-blk-pci,drive=cdrom0,bootindex=1 \ -netdev user,id=net0,hostfwd=tcp::22222-:22 \ -device e1000,bootindex=2,netdev=net0,mac=52:54:00:a2:34:c0 \ -netdev tap,id=net1,ifname=atx-fabric0i1p1 \ -device virtio-net,bootindex=4,netdev=net1,mac=b8:38:61:bc:60:f5 \ -nographic \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -serial mon:stdio # Login and replace netplan config cat > 50-cloud-init-vm1.yaml << EOF network: version: 2 ethernets: ens5: match: macaddress: "52:54:00:a2:34:c0" accept-ra: false dhcp4: true dhcp6: false mtu: 1500 eth2-1: optional: true match: macaddress: b8:38:61:bc:60:f5 set-name: eth2-1 accept-ra: false dhcp4: false dhcp6: false mtu: 1500 addresses: - 6.1.6.1/24 - 2006:1:6::1/116 routes: - from: 6.1.6.1 scope: link to: 6.1.6.254 - from: 2006:1:6::1 scope: link to: 2006:1:6::254 - to: default via: 2006:1:6::254 metric: 32 - to: default via: 6.1.6.254 metric: 32 eth2-2: match: macaddress: b8:38:61:bc:60:f6 set-name: eth2-2 accept-ra: false dhcp4: false dhcp6: false mtu: 1500 EOF scp -P 22222 50-cloud-init-vm1.yaml ubuntu@localhost: ssh -P 22222 'sudo cp /home/ubuntu/50-cloud-init-vm1.yaml /etc/netplan/50-cloud-init.yaml' ssh -P 22222 'sudo netplan apply' # Launch VM2 (need sudo for bridge access) BOOT=focal-net2.img SEED=seed.img sudo qemu-system-x86_64 -smp 2 -m 1024 --enable-kvm \ -global pc35.no_floppy=1 \ -name "${1}" \ -drive id=disk0,if=none,format=qcow2,file=${BOOT} \ -device virtio-blk-pci,drive=disk0,bootindex=0 \ -drive id=cdrom0,if=none,media=cdrom,file=$SEED \ -device virtio-blk-pci,drive=cdrom0,bootindex=1 \ -netdev user,id=net0,hostfwd=tcp::22223-:22 \ -device e1000,bootindex=2,netdev=net0,mac=52:54:00:ef:88:a2 \ -netdev tap,id=net1,ifname=atx-fabric0i2p1 \ -device virtio-net,bootindex=4,netdev=net1,mac=b8:38:61:bc:60:f6 \ -nographic \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -serial mon:stdio # Login and replace netplan config cat > 50-cloud-init-vm2.yaml << EOF network: version: 2 ethernets: ens5: match: macaddress: "52:54:00:ef:88:a2" accept-ra: false dhcp4: true dhcp6: false mtu: 1500 eth2-1: match: macaddress: b8:38:61:bc:60:f5 set-name: eth2-1 accept-ra: false dhcp4: false dhcp6: false mtu: 1500 eth2-2: optional: true match: macaddress: b8:38:61:bc:60:f6 set-name: eth2-2 accept-ra: false dhcp4: false dhcp6: false mtu: 1500 addresses: - 6.1.6.1/24 - 2006:1:6::1/116 routes: - from: 6.1.6.1 scope: link to: 6.1.6.254 - from: 2006:1:6::1 scope: link to: 2006:1:6::254 - to: default via: 2006:1:6::254 metric: 32 - to: default via: 6.1.6.254 metric: 32 EOF scp -P 22222 50-cloud-init-vm1.yaml ubuntu@localhost: ssh -P 22222 'sudo cp /home/ubuntu/50-cloud-init-vm1.yaml /etc/netplan/50-cloud-init.yaml' ssh -P 22222 'sudo netplan apply'