3 Changing how the VMs are started
First, we need to make sure the VMs do not use the same MAC (hardware) addresses. Let us assume the original command is
as follows:
qemu -hda hd1.qcow2 -m 256 -cdrom binary.iso -net nic,vlan=0 -net user,vlan=0,hostname=emu -boot d -L .\Bios
You need to change it as follows:
- Add one more interface. This is the interface that we will use to let the VMs talk to each other.
- Specify the hardware address of each interface.
The new command should look like the following for one of the VMs:
qemu -hda hd1.qcow2 -m 256 -net nic,vlan=0,macaddr=52:55:00:12:34:56 -net user,vlan=0,hostname=emu -net nic,vlan=1,macaddr=52:55:00:12:34:57 -net socket,vlan=1,mcast=224.0.0.1:10000 -boot d -L .\Bios
Here is an explanation of the changes:
- ,macaddr=52:55:00:12:34:56
This part is addd to specify the MAC address of the original interface. Although this step is not really needed
(because the user mode interfaces do not see each other), it is just a good precaution. The default MAC address
starts with 52:54:00. To make things easy, you should choose a different prefix for each VM.
- -net nic,vlan=1,macaddr=52:55:00:12:34:57
This adds a second interface. If you did not specify a hardware device type for the first interface, do not specify
one here. Note that the MAC address is different from that of the first interface.
- -net socket,vlan=1,mcast=224.0.0.1:10000
This is the magic that makes it work. This line designates that the second interface be bound to the multicast
interface 224.0.0.1 port 10000. 224.0.0.1 is the multicast equivalence of 127.0.0.1 of unicast. You can
choose a port different from 10000, but make sure all VMs of the same virtual network use the same port
number!
When it is said and done, you should have a command to start the second VM somewhat similar to the
following:
qemu -hda hd2.qcow2 -m 256 -net nic,vlan=0,macaddr=52:56:00:12:34:56 -net user,vlan=0,hostname=emu -net nic,vlan=1,macaddr=52:56:00:12:34:57 -net socket,vlan=1,mcast=224.0.0.1:10000 -boot d -L .\Bios