Cloning Bridged VMs : VirtualBox Vs. KVM

Home » CentOS » Cloning Bridged VMs : VirtualBox Vs. KVM
CentOS 5 Comments

Hi,

(tl;dr : how can I clone a KVM-based bridged virtual machine and force a duplicate MAC address ?)

Up until recently I’ve been using VirtualBox on my workstation to test various local setups. Usually I would setup a basic CentOS installation, and whenever I
wanted to fiddle around, I would just clone that system and play around with it. So whenever I shot myself in the foot on that VM, I would simply erase it and start over again with a new clone. Think of it as a disposable VM.

All my VMs under VirtualBox used bridged mode, so they were in the same network. And in my local proxy server, I have Dnsmasq that assigns static IP
addresses and meaningful hostnames to these VMs. Here’s what the corresponding lines in dnsmasq.conf look like:

dhcp-host=08:00:27:00:00:01,suse-lp151,192.168.2.10
dhcp-host=08:00:27:00:00:02,suse-lp152,192.168.2.11
dhcp-host=08:00:27:00:00:03,ce7-server,192.168.2.12
dhcp-host=08:00:27:00:00:04,ce8-server,192.168.2.13
dhcp-host=08:00:27:00:00:05,ol7-server,192.168.2.14
dhcp-host=08:00:27:00:00:06,ol8-server,192.168.2.15
dhcp-host=08:00:27:00:00:07,rh7-server,192.168.2.16
dhcp-host=08:00:27:00:00:08,rh8-server,192.168.2.17

Over the last two weeks, I decided to migrate from VirtualBox to KVM even for local configurations and virtualized desktop configurations. So far, everything works nice… except one problem I can’t seem to solve (yet).

I’m using KVM in bridged mode, over a br0 bridge on my workstation. Like with VirtualBox, all my KVM virtual machines are part of my local 192.168.2.0/24
network.

Unfortunately there is no way to simply make a perfect clone of a virtual machine using virt-manager. It insists on assigning my cloned VM a different MAC address. And whenever I want to manually create a NIC with the same MAC
address as the original, Virtual Machine Manager tells me I can’t do that. Same player shoot again.

Now I know that is normally a good thing. You don’t want MAC address conflicts in your network. But here’s the thing: I don’t intend to fire up both copies at once. As with VirtualBox, I only intend to use one VM at a time, for testing purposes. Now how can I “explain” this to Virtual Machine Manager without having to jump through burning loops ?

Cheers,

Niki


Microlinux – Solutions informatiques durables
7, place de l’église – 30730 Montpezat Site : https://www.microlinux.fr Blog : https://blog.microlinux.fr Mail : info@microlinux.fr Tél. : 04 66 63 10 32
Mob. : 06 51 80 12 12

5 thoughts on - Cloning Bridged VMs : VirtualBox Vs. KVM

  • this appears to have 8 different mac addresses and then assigned 8
    individual IP addresses – that would appear desireable and correct.

    Why do you want the same mac? what are you trying to achieve?

    Feel like I’m missing something

  • Both virt-manager and virt-clone prevent you from doing this. However, you can change the created random MAC using virsh edit on the cloned domain.

    Terveisin,
    <(*) Jyrki Tikka

  • That’s exactly what I mean. Just look up the original MAC address and use it in the interface section of the XML definition


    <(*) Jyrki

  • Le 26/03/2021 à 22:49, Jyrki Tikka a écrit :

    I just found a simple solution : removing the NIC interface before cloning the VM. Then manually adding it on the clone.

    Takes just 30 seconds longer to clone than with VirtualBox, but works fine.

    Sometimes you have to imagine complex things before doing something very simple.

    Thanks to everybody for your input,

    Niki


    Microlinux – Solutions informatiques durables
    7, place de l’église – 30730 Montpezat Site : https://www.microlinux.fr Blog : https://blog.microlinux.fr Mail : info@microlinux.fr Tél. : 04 66 63 10 32
    Mob. : 06 51 80 12 12