7

Exported Virtual Box VM (CentOS 5.5 with Guest Additions Installed) - Success
Imported CentOS VM Successfully on another Windows Machine via Windows Batch

Problem :
VM After Import retains the same Mac Address and gets the same IP as it was exported from, is there a way one can either change / flush the IP & MAC while exporting or after Importing ?

a VBoxManage command may be? Which I can put in a batch file after import ?

Will be grateful for your assistance on this Kind Regards

Mutahir
  • 2,347
  • 2
  • 32
  • 42

2 Answers2

7

You can change the macaddress of a machine with

vboxmanage modifyvm VMName --macaddressN macaddress

where N is the interface number and macaddress matches the regexp [0-9A-Fa-f][02468ACEace][0-9A-Fa-f]{10}

eg

vboxmanage modifyvm VMName --macaddress1 000027D15bE8

Did you set a static IP address on your base VM ?

EDIT

Based on the discussion below I think you will be better off using

vboxmanage modifyvm VMName --macaddressN auto

Which will set a new mac address once. The machine will then retain that new mac address.

user9517
  • 114,104
  • 20
  • 206
  • 289
  • Hi Iain, Thank you so much for your prompt response like always !! No, I didn't set a Static IP So in your example, I would basically first copy the existing mac address of the VM and then use the command : `vboxmanage modifyvm CENTOS --macaddress0 ` Do I just use the regular expression you have used as an e.g. above or do I need to generate a new regexp ? no knowledge of regexp :-) Thanks again !!!! – Mutahir Oct 27 '10 at 13:28
  • The regexp basically means that you can have any [mac address](http://en.wikipedia.org/wiki/MAC_address) that you like however the 2nd number has to be one of `02468ACEace`. I don't know why this restriction has been put in place. so `000027D15bE8` would be valid whereas `010027D15bE8` – user9517 Oct 27 '10 at 13:37
  • Hi Iain, so I will batch the following command up after the import which will modify the mac address : `vboxmanage modifyvm CentOS --macaddress0 [0-9A-Fa-f][02468ACEace][0-9A-Fa-f]{10}` and this command will basically force the vm to get a new mac address via the regular expression ? Sorry for being dumb - no good in reg exp or programming :-) – Mutahir Oct 27 '10 at 13:48
  • No - you would have to have the batch file generate mac addresses. I've edited my original response with some new information. – user9517 Oct 27 '10 at 14:15
  • As the Wikipedia article shows, the least two significant bits in the first byte designate whether the address is universal or local (i.e. "official" or "something you made up") and unicast or multicast, respectively. This answer provides a little more detail: http://serverfault.com/questions/40712/what-range-of-mac-addresses-can-i-safely-use-for-my-virtual-machines/40720#40720 – Gerald Combs Oct 27 '10 at 15:36
1

Here is a simple sample script that I created. It may be useful as an example of what you can do.

A little side not there are only 8 network interfaces available for configuration

#!/bin/bash

# this script changes the network set up $cable a virtual box vim
vmname="floating"
nic=1
hostinterface="eth0"
cable="off"

#vboxmanage showvminfo "floating" | grep NIC
# usefull to see your vms configuration

((nic=1))
echo "network interface $nic"
vboxmanage modifyvm $vmname --nic$nic bridged --nictype$nic "82540EM" --cableconnected$nic $cable --bridgeadapter$nic $hostinterface --macaddress$nic 08002713F6EA

((nic=2))
echo "network interface $nic"
vboxmanage modifyvm $vmname --nic$nic bridged --nictype$nic "82540EM" --cableconnected$nic $cable --bridgeadapter$nic $hostinterface --macaddress$nic 08002713F6EB

vboxmanage showvminfo $vmname | grep NIC
#vboxmanage startvm "$vmname"

nelaaro
  • 584
  • 4
  • 9
  • 25