Posted by Steve on Thu 22 Feb 2007 at 16:47
MAC addresses are often taken for granted, things that nobody thinks about. However there are times when you do need to worry about them. Here we'll demonstrate how to view and change the MAC address of your Debian system.
Recently I had to deal with a machine which was having a strange networking problem:
It took a while to figure out what was going wrong, but eventually we discovered that the machine was acquiring a different MAC address each time it booted. This explained the symptoms:
The following messages in the system logs show the problem explicitly, once we knew to look there:
0000:00:07.0: Invalid Mac address detected: b1:8e:66:ea:0f:00 Please complain to your hardware vendor. Switching to a random MAC. eth0: forcedeth.c: subsystem: 01458:e000 bound to 0000:00:07.0
Thankfully the solution to this problem was very simple - just allocate a static MAC address to the machine, so when it reboots it doesn't generate a random one of its own.
Find your MAC addressSet your MAC addressTo view the MAC address of your machine you can use the ifconfig command. To see all interfaces run:
skx@mine:~$ ifconfig eth0 Link encap:Ethernet HWaddr 00:17:31:56:BC:2D inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0 .. .. lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 .. ..Here the MAC address is displayed after HWaddr, so the MAC address of this system is "00:17:31:56:BC:2D".
If you just want the MAC address of an interface you could run something similar to this:
skx@mine:~$ ifconfig eth0 | grep HWaddr | awk '{print $5}' 00:17:31:56:BC:2D
If you wish to explicitly set your MAC address upon a Debian system you can do so by adding an entry to your /etc/network/interfaces file.
Beneath each interface you wish to setup add "hwaddress ether xx:xxx..". For example:
auto eth0 static iface eth0 inet static address 1.2.3.4 gateway ... broadcast ... hwaddress ether 02:01:02:03:04:08
This article can be found online at the Debian Administration website at the following bookmarkable URL:
This article is copyright 2007 Steve - please ask for permission to republish or translate.