3 Ways to change the MAC address in Linux and Unix

There are 3 ways (that I know of) to temporary change the Hardware address (MAC address) in Linux and Unix systems.

Watch Free Movies

The MAC address can be temporary changed with ifconfig, iproute2 or the macchanger tool, in Debian, Ubuntu, Linux Mint or other Debian based distros.

How to temporary change the MAC address with ifconfig:

When you change the MAC address for an interface, you need to have the network interface disabled (down) and than to set the new MAC.

You can do both this things with the command:

sudo ifconfig interface_name down hw ether AA:BB:CC:DD:EE:FF && ifconfig eth0 up

$ sudo ifconfig eth0 down hw ether AA:BB:CC:DD:EE:FF && ifconfig eth0 up

This sets down the eth0 interface, changes the mac to AA:BB:CC:DD:EE:FF and turns the interface back down.

Or, do it in the old fashioned way:

$ sudo ifconfig eth0 down
$ sudo ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF
$ sudo ifconfig eth0 up

Read more about the ifconfig command here.

How to temporary change the MAC address with iproute2:

The iproute2 command also needs the network interface down, before the MAC change to apply. The first command sets the eth0 interface down, the second changes the MAC to AA:BB:CC:DD:EE:FF on eth0 and the third turns back on the network interface.

$ ip link set down dev eth0
$ ip link set dev eth0 address AA:BB:CC:DD:EE:FF
$ ip link set up dev eth0

The third tool for changing the MAC address in Debian based distros is macchanger.

Install it first: sudo apt-get install macchanger

Like the other two tools, you have to set the network interface down first, set the new MAC address (AA:BB:CC:DD:EE:FF) in our case and turn the interface back on:

$ sudo ifconfig eth0 down
$ sudo macchager -m AA:BB:CC:DD:EE:FF eth0
sudo ifconfig eth0 up

You can find all the MAC adress related articles here.

Scroll to Top