Set MAC address to default

mac address

Sometimes I need to spoof MAC address, I'm doing so with this command:

ip link set dev eth0 address XX:XX:XX:XX:XX:XX

Is there a way how to set MAC address back to default without reboot?

Best Answer

See also:

sudo ethtool -P eth0

So, to set the MAC address back to its default (assuming GNU grep here):

set_to_real() (
  for i do
    mac=$(ethtool -P "$i" | grep -iEom1 '([0-9a-f]{2}:){5}[0-9a-f]{2}') &&
      ip link set dev "$i" address "$mac"
  done
)
set_real eth0
Related Question