How to set the mac address from /etc/network/interfaces in Debian
   This is an update to a previous post regarding the change of mac address in Debian. In the previous tutorial I told you can change it by ifconfig from a root account. Now I’m going to teach you how to set an interface mac address using /etc/network/interfaces . This is a better way to set your mac address because the mac you set in /etc/network/interfaces will always load when the interfaces are loaded so you don’t have to worry about the mac after reboot for example. Let’s start by looking at my /etc/network/interfaces it looks like this:
#This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).# The loopback network interface
auto lo
iface lo inet loopback# The primary network interface
auto eth0
iface eth0 inet static
address 1.1.1.2
netmask 255.255.255.0
network 1.1.1.255
broadcast 1.1.1.255
gateway 1.1.1.1
dns-nameservers 1.1.1.1
dns-search .com
hwaddress ether 00:01:04:1b:2C:1F
Open this file in your favorite editor. I use nano. You can see that my ip address is 1.1.1.2 and my gateway is 1.1.1.1 instead of these in your file you will see your network settings. Now, under the last line of the interfaces file you have to add the following
hwaddress ether 00:01:04:1b:2C:1F
replacing 00:01:04:1b:2C:1F with the mac you want to assign to the interface where you are adding the line. Now save the file with ctrl+x then y to confirm and restart the network service with
/etc/init.d/networking restart
Now type ifconfig and there it is you should see the mac you entered earlier assigned to eth0 (if you choused eth0). You’re done the mac will now load every time the network load’s.

October 31st, 2007 at 1:31 pm
Some indentation on your /e/n/i would be nice…
November 1st, 2007 at 7:56 am
Hello Stuart what do you mean by indentation ? because i placed the code is placed into a special paragraph and its separated from the rest of the text, i think that is called indentation
June 11th, 2010 at 1:21 am
Hello
The way you describe is ok, and I hope it will works. I only need help with the saving the “interfaces” (replacing) it, coz it wont let me do that. I try with the nano too, tru root terminal and no success. It says :
“You do not have the permissions necessary to save the file. Please check that you typed the location correctly and try again.”
How can I save it, so I dont have to change the MAC address every time I reboot the PC. thx
August 24th, 2010 at 10:52 pm
The perfect thing for a persistent usb install… i didn’t know about that option, but now i do!
Thanks
February 8th, 2011 at 5:01 pm
[…] You could also set the MAC address in /etc/network/interfaces http://www.youritronics.com/how-to-s…ces-in-debian/ […]