I'm trying to learn different networking modes of qemu.
In user network mode, qemu will create a virtual DNS and associate IP addresses to VMs using DHCP.
The problem is that all VM that I create have same IP of
10.0.2.15 so I thought maybe they are on separate network hubs. I tried to create a VM with the same net id or changing MAC, but it doesn't change the result.
Here are the commands I used to create the VMs:
kvm -m 3G -cdrom ubuntu-22.04-desktop-amd64.iso -netdev user,id=network0 -device e1000,netdev=network0,mac=52:54:00:12:34:77 -name "kvm1"
kvm -m 3G -cdrom ubuntu-22.04-desktop-amd64.iso -netdev user,id=network0 -device e1000,netdev=network0 -name "kvm2"
With JdeHaan's advice I tried to learn what virsh does when creating a VM using Bridge mode. First, I created a bridge on the Host and created the VM using virsh with that bridge. With this method, you should enter the VM and set the IP for the interface manually. Unfortunately, the VM creation command from
ps output is confusing and you can not find where the bridge is! Something like this:
qemu-system-x86_64 *** -netdev tap,fd=38,id=hostnet0,vhost=on,vhostfd=40 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:a8:7b:3b,bus=pci.1,addr=0x0