Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
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 <stuck with regexp> 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 !!!! –  rihatum Oct 27 '10 at 13:28
    
The regexp basically means that you can have any 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 –  Iain 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 :-) –  rihatum 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. –  Iain 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: serverfault.com/questions/40712/… –  Gerald Combs Oct 27 '10 at 15:36

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"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.