Once you have a virtual switch (and optionally virtual DCHP server/router) started up, it is time to start and connect your virtual machines to it.
Once you have a virtual switch running with the router/DHCP server option, there is no need to use “user mode” networking any more. As a result, you have to change the options when you start your VM. Find the following option:
and replace it with the following option:
The rest of the command to start up your virtual machine should remain the same. After you start the VM, make sure you can access the Internet.
If you have multiple VMs to connect to the virtual switch (after all, that is why you want to use a virtual switch!), you should keep in mind that the default MAC ID is the same for all the VMs! That won’t work!
As a result, you need to assign a different MAC ID to each NIC. This is fairly easy to do. For the command to start each VM, locate the following option (that specifies which VLAN connects to which NIC):
Then change it into the following (use a different ID for each VM/NIC!)
I’d just change the last (rightmost) number to 57 for the next VM/NIC, 58 for the one following that and etc.
Once you have started two or more VMs using these options, the VMs should be able to “see” each other. Acquire the IP address of each VM using the following command:
Then have the VMs to ping each other. By default, the ICMP packet type for pinging is not blocked in Debian, so the VMs should be able to ping each other.
If you use the -redir option to forward host ports to VM ports, make sure the VMs do not share the same host port. For example, if one VM forwards port 2222 to port 22, the next one should forward port 2223 to port 22. There is no need to change 22 because that’s the guest (VM) port number.