Setting MAC Addresses on Debian and Ubuntu


I recently had a problem with having duplicate MAC addresses on my network for a couple of machines that I was using in a Linux KVM cluster. Flashing the firmware on the motherboards seem to have reset the MAC address to a default (thanks ASUS) that was the same on each board.

Changing the MAC address back seems like quite a hard job and looking around on the internet it seems that many people are doing this the hard way with shell scripts and so forth. Instead its easy enough to do this using the scripts that are already setting up the network for Debian (and I am sure this will work for Ubuntu just as well).

Edit /etc/network/interfaces like so:

[cc lang=“bash”]

auto eth0

iface eth0 inet manual

pre-up ifconfig $IFACE hw ether 00:01:02:03:04:05

pre-up ifconfig $IFACE up

pre-down ifconfig $IFACE down


What this is doing is manually controlling the startup and shutdown of the eth0 interface. I am using bridging on my KVM boxes, so I don’t actually have to set up the IP address (albeit DHCP or manual IP configuration), but that aside the interesting parts are what happens in pre-up. Firstly I set the hardware address to a new address (and please change it from the example above – thats not the actual one I used either), then we tell it to bring the interface up.

We also use pre-down to tell it what happens when stopping the network service.

Probably better than messing around with Shell scripts.

comments powered by Disqus