Changing Network Interface MAC Addresses in Linux
In some environments—such as data centers, virtualization platforms, or hardware replacement scenarios—you may need to permanently change a network interface MAC address at the firmware level.
This guide explains how to modify MAC addresses on Linux using Mellanox Firmware Tools (MFT).
🧩 System Environment #
The procedure described here was validated in the following environment:
- Operating System: Debian 12
- NIC Models: Mellanox ConnectX-4 / 5 / 6 / 7
- Firmware Tooling: Mellanox Firmware Tools (MFT)
- Version:
mft-4.26.1-3-x86_64-deb.tgz
- Version:
This method updates the MAC address in NIC firmware, not just at runtime.
🛠️ Installing Mellanox Firmware Tools (MFT) #
Extract the Installation Package #
tar zxvf mft-4.26.1-3-x86_64-deb.tgz
cd mft-4.26.1-3-x86_64-deb/
ls
Expected contents:
DEBS install.sh LICENSE.txt old-mft-uninstall.sh SDEBS uninstall.sh
Install Required Build Dependencies #
MFT requires kernel headers and build tools:
apt install gcc make dkms
Ensure that DKMS successfully builds kernel modules for your running kernel.
Install MFT #
Run the installer script:
./install.sh
After installation, start and verify the Mellanox Software Tools (MST) service:
mst start
mst status
Example output:
MST modules:
------------
MST PCI module is not loaded
MST PCI configuration module loaded
PCI Devices:
------------
/dev/mst/mt4119_pciconf0 - PCI configuration cycles access
The /dev/mst/* device paths will be required in later steps.
🔐 Flashing a New MAC Address #
Disable Firmware Write Protection #
Before modifying firmware parameters, disable flash write protection:
flint -d /dev/mst/mt511_pciconf0 -ocr hw set Flash0.WriteProtected=Disabled
Replace the device path with the one shown by
mst status.
Program the New MAC Address #
Use flint to flash the desired MAC address:
flint -d /dev/mst/mt511_pciconf0 --mac 0000709CD1C9B5E8 --ocr sg
Ensure the MAC address format is valid and unique within your network.
Reset NIC Firmware #
Apply the change by resetting the firmware:
mlxfwreset -d /dev/mst/mt511_pciconf0 r
🔄 Verification #
After the firmware reset:
- Reboot the system
- Verify the MAC address using standard tools:
ip link show
or
ethtool -P <interface>
The new MAC address should now be active and persistent across reboots.
⚠️ Important Notes #
- Always confirm the correct MST device path using
mst status. - Flashing incorrect values can render a NIC unusable.
- This procedure modifies firmware-level configuration and should be performed during maintenance windows.
By using Mellanox Firmware Tools, Linux administrators can safely and permanently update NIC MAC addresses—an essential capability for enterprise networking, hardware replacement, and large-scale deployments.