Score:0

Give static IP's to multiple QEMU Virtual Machines

cn flag

my networking knowledge on linux is pretty limited and I have been trying to assign static IP addresses to each of my VM's as they need to communicate with one another.

I have been reading some networking QEMU documentation regarding TUN/TAP interfaces, as well as configuring br0 with qemu-ifup and qemu-ifdown. However, I've just recovered from completely losing my wifi connection. So I have decided to see if I can get some pointers on what exactly to do.

Essentially the configuration needs to be such that 3 VM's are created from the host machine and are assigned static IP's so that they can communicate with one another as well as the host. Currently, all VM's share the same MAC and IP addresses.

I am starting the VM's all with essentially the same commands and I figure that the -net paramters need to be modified.

Example QEMU VM startup:

sudo ./qemu-system-x86_64 \
     -drive file=drive.img,format=raw \
    -boot d \
    -k en-us \
    -object can-bus,id=canbus0 \
    -object can-bus,id=canbus1 \
    -device mioe3680_pci,canbus0=canbus0,canbus1=canbus1 \
    -object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0,if=vcan0 \
    -object can-host-socketcan,id=canhost1,if=can1,canbus=canbus1,if=vcan1 \
    -m size=2048 \
    -nic user,hostfwd=tcp::6022-:22 \
    -netdev bridge,id=hn0,  \           
    -smp 4 \
    -enable-kvm &

I am able to ssh into this VM with ssh user@localhost -p 6022 which works. But in order for the software I am trying to write to work, these VM's need static IP addresses as there must be TCP communication done between each of them.

My host is running Ubuntu 20.04, and one of my VM's is running Ubuntu 16.04 Xenial, and the other Centos 7.

So essentially the configuration I would want is:

host = 192.168.1.80
vm1 = 192.168.1.2
vm2 = 192.168.1.22
vm3 = 192.168.1.3
guiverc avatar
cn flag
Please start with OS & release details (they provide clues as to your software stack). Ubuntu LTS releases also offer two software stacks so please be specific.
jabroni avatar
cn flag
@guiverc Apologies I forgot to add those in. Updated the post :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.