Here is new and tested solution, works fine, is permanent, the new mac address is retained after reboot as well:
add a special script file to
/etc/network/if-pre-up.d/
here is the contents of my script file "change-mac-address":
--------------------------- this line is not included inside the file, just indicates where the contents of the file begins ---------------------
#!/bin/sh
if [ "$IFACE" = "eth0" ]; then
/sbin/ifconfig eth0 hw ether 00:03:45:67:89:AF
fi
exit 0
------------------ likewise, indicates the end of the file, not inside the file -------------------------
Do not forget to make this file executable
chmod a+x change-mac-address
The new mac address (in this example: 00:03:45:67:89:AF) will take effect after rebooting, and subsequent rebooting or network restarting with remote will not revert the mac address back to the original one.
IMPORTANT: the file name with this script CANNOT have extension .sh, i.e,
if the file is named change-mac-address.sh - then it will not work!!!
All the files in that directory are run as scripts at a proper time if they have execution rights, as long as their names do not end with .sh !!!