Change MAC address of network interface in Linux

Well, thankfully this is rather trivial task for Linux and you can change MAC address of your network adapter using a few CLI/console commands. Honestly speaking it is impossible to literally change MAC address as it’s loaded into firmware but you can configure Linux so it will transform old MAC to the new one the fly.

The commands are are below but before typing them let’s consider why one might need this. One of the simplest examples is here: you acquire IP address, gateway, DNS entries via DHCP server which is set up to give out your IP settings to your MAC address only so if you change [possibly broken] network adapter you will need to ask sysadmin to change DHCP server’s settings… If this looks familiar to you, just type the following commands with sudo prefix or under superuser/root:

ifconfig eth0 down
ifconfig eth0 hw ether 00:19:7e:53:8c:a3
ifconfig eth0 up

eth0 – is hardware name of your network interface, you can use ip link to see all available interfaces identified by your system.
00:19:7e:53:8c:a3 is new MAC address you’d like to apply to the NIC.

These commands should be added into startup scripts if you require them to appear after Linux system reboots. This works on any distribution like Fedora, Ubuntu, Debian, RedHat, Suse whatever.

SHARE:
nv-author-image

Stefan Durand

My name is Stefan, I'm the admin of LinuxScrew. I am a full-time Linux/Unix sysadmin, a hobby Python programmer, and a part-time blogger. I post useful guides, tips, and tutorials on common Linux and Programming issues. Feel free to reach out in the comment section.

1 thought on “Change MAC address of network interface in Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *