Centos 6 / Ubuntu 12 - Changing Mac Address (Cloning VM)

If you are running a Linux system, and you decide to either:

  • Put your hard drive / ssd in another computer.
  • Clone your virtual machine and change the mac address so get new dhcp ip
  • Clone your hard drive and use in another machine
Then you will suffer from having a different mac address from what ubuntu had when it was installed. This will prevent your networking/internet from working and also cause your system to take ages to start up (gets stuck on waiting for network).

Solutions

Ubuntu Solution 1

Remove the file

/etc/udev/rules.d/70-persistent-net.rules
and restart the machine, resulting in it being automatically regenerated correctly.
sudo rm /etc/udev/rules.d/70-persistent-net.rules
sudo reboot

I have done this on a Virtualbox and my eth1 device (which still shows as eth1 in VB) was "converted" into an eth0 device, resulting in any static settings in
/etc/network/interfaces
not working. I had to update that file from eth1 to eth0.

Ubuntu Solution 2

If you know your new MAC address (from your NIC or artificially in virtualbox).
Simply edit the configuration file at:/etc/udev/rules.d/70-persistent-net.rules and update the bit after

ATTR(address)--
in order to edit your mac address. Make sure you choose the appropriate interface if there are several (wlan for wireless, eth0 or eth1 for your ethernet ports.

Centos 6

    Find out what the MAC address is by running:

    ifconfig -a
    Plug that MAC address into the relevant script inside the
    /etc/sysconfig/network-scripts/
    directory.
    E.g. if it stated eth1, then the script would be ifcfg-eth1.
    Restart your network
    service network restart

No comments:

Post a Comment