KVM virtual machine copy
To finish the KVM series (part 1 and part 2), this last part will show what has to be done to have another virtual machine up&running. This assumes you're using some of the newer Linux distros with udev enabled. The example is for Debian, I guess it's very similar on others.
Let's assume you have your first VM all setup, with IDS running and everything configured the way you wanted. Then you want to setup another one, almost identical (to play with HDR for example), with only minimum necessary config changes, both on OS and in IDS.
Can't be easier: just shut down your VM to save a stable state and copy the image.
When starting the copied VM for the first time, start it with the same MAC address as the original (make sure the original VM is NOT started).
When it boots, go to
/etc/udev/rules.d/z25_persistent_net.rules
and change the MAC address for the eth0 there. Put some new value which you'll be using for the new VM (for example, just increment the MAC address).
Then shutdown the new VM and change the MAC with which you're starting it to the one you just set in udev rules. Now the Ethernet layer is changed, let's reconfigure the IP layer.
In your new VM:
- delete /etc/hostname file
- edit /etc/hosts to only provide localhost entries
- edit /etc/network/interfaces to configure Ethernet interface via DHCP
On the host OS:
- reconfigure /etc/dnsmasq.conf to provide IPs/hostnames to specified MAC addresses
dhcp-host=52:54:00:12:34:58,kvmifx1,10.111.111.4,12h - restart dnsmasq
We now have a fully functional new "server" to work with, with all necessary network configuration in place. Of course, you still have to reconfigure IDS to use new instance name if you plan to use it in conjunction with the original VM/instance, but that's easy enough.
Hopefully this was interesting to someone who needs to do a lot of sandbox testing.
Any feedback appreciated.





