Linux How to change hardware MAC address of an interface
The mac address is also referred to as physical address and it is used in Ethernet network via ARP and DHCP to map a layer 3 IPv4 address.
Change interface mac address in Linux
To change the mac address of an interface in Linux, the interface needs to be brought down first, otherwise a "device or resource busy" error will occur. This can be done if logged in via ssh to an interface not serving the ssh traffic (otherwise reachability will be lost) or if connected through a console port.
Code:
root@server:~# ip a l eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:3e:3a:0a:1a brd ff:ff:ff:ff:ff:ff
inet6 fe80::216:3eff:fe3a:a1a/64 scope link
valid_lft forever preferred_lft forever
root@server:~# ifconfig eth0 hw ether '00:16:3e:3a:0a:1b'
SIOCSIFHWADDR: Device or resource busy - you may need to down the interface
root@server:~# ifconfig eth0 down
root@server:~# ifconfig eth0 hw ether '00:16:3e:3a:0a:1b'
root@server:~# ifconfig eth0 up
root@server:~# ip a l eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:3e:3a:0a:1b brd ff:ff:ff:ff:ff:ff
inet6 fe80::216:3eff:fe3a:a1b/64 scope link
valid_lft forever preferred_lft forever