Rate this page

Change the MAC address of an Ethernet interface

Tested on

Debian (Etch, Lenny, Squeeze)
Ubuntu (Lucid, Maverick, Natty)


To change the MAC address of an Ethernet interface


It is rarely necessary to change the MAC address of an Ethernet interface because for most purposes any unique address will suffice. (Unlike IP addresses, there is no requirement for the addressing scheme to reflect the topology of the network.) However there are circumstances which require the use of a specific address, or alternatively, a randomly-chosen address. These include:

The ability to change the MAC address of an interface is dependent on support being provided by the relevant device driver. Most drivers do this, but there are some which do not.


Suppose that you wish to configure the interface eth0 to use the MAC address 02:5d:6c:e8:8d:b2. The assigned IP address of the interface is

Method (non-persistent)

If the MAC address of an interface is capable of being changed then this can be done using the ifconfig command:

ifconfig eth0 hw ether 02:5d:6c:e8:8d:b2

The new address will not persist beyond a reboot.

If you are inventing a new MAC address for an interface (as opposed to mimicing an existing one) then be aware that two of the bits in the address have special meanings:

For a locally administered unicast address these bits should be set to zero and one respectively. It follows that the first byte of the address should end with 2, 6, A or E when expressed in hexadecimal.


Check the configured MAC address

You can verify that the interface has been configured with the intended MAC address using the ifconfig command:

ifconfig eth0

The MAC address is labelled HWaddr in the output from this command:

eth0      Link encap:Ethernet  HWaddr 02:5d:6c:e8:8d:b2
          inet addr:  Bcast:  Mask:
          RX packets:9659 errors:0 dropped:0 overruns:0 frame:0
          TX packets:309 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2783810 (2.6 MiB)  TX bytes:25318 (24.7 KiB)

Inspect inbound and outbound traffic

You can verify that the interface is using the intended MAC address by generating some inbound and outbound network traffic then inspecting the resulting Ethernet headers. The traffic can be inspected using tcpdump:

tcpdump -i eth0 -e -n "icmp and host"

The options used here are:

The filter restricts the output to ICMP traffic addressed to or from the local machine.

While tcpdump is running, generate some ICMP traffic using the ping command. Assuming that there is a machine that responds to ping at


The output from tcpdump should show the new MAC address as the link layer source address for echo requests, and as the destination address for echo replies:

16:28:08.574438 02:5d:6c:e8:8d:b2 > 02:a2:e3:40:d7:29, ethertype IPv4 (0x0800), length 98: > ICMP echo request, id 2919, seq 1, length 64
16:28:08.574591 02:a2:e3:40:d7:29 > 02:5d:6c:e8:8d:b2, ethertype IPv4 (0x0800), length 98: > ICMP echo reply, id 2919, seq 1, length 64


Operation not supported

The error:

SIOCSIFHWADDR: Operation not supported

indicates that the hardware address for the specified interface cannot be changed. This could be because the interface does not have a hardware address, or because the ability to change the address has not been implemented by the relevant device driver.

Cannot assign requested address

The error:

SIOCSIFHWADDR: Cannot assign requested address

probably indicates that the requested MAC address is not a unicast address. (To qualify as a unicast address the first byte must be even.)

Device or resource busy

The error:

SIOCSIFHWADDR: Device or resource busy - you may need to down the interface

probably indicates that the relevant device driver does not allow the MAC address to be changed while the interface is up.

Tags: ethernet