Setting permanent MAC address in Ubuntu 14.04

10,401

You can use an udev rule to automatically set the MAC address on your network interface

Create the file /etc/udev/rules.d/99-custom-mac.rules and paste into it:

ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="XX:XX:XX:XX:XX:XX", RUN+="/sbin/ip link set dev %k address YY:YY:YY:YY:YY:YY"

where XX:XX:XX:XX:XX:XX is the original MAC address of your interface (you can get it in the output of ip link) and YY:YY:YY:YY:YY:YY is the new MAC address you want to enforce.

To make the change effective you can run

sudo udevadm control --reload

but I doubt it works, so a reboot might be necessary.

Share:
10,401

Related videos on Youtube

user258821
Author by

user258821

Updated on September 18, 2022

Comments

  • user258821
    user258821 over 1 year

    Due to the unusual way my ISP set up Internet, I need to manually set up MAC address to go online. So far I've been using:

    sudo ifconfig eth0 down
    sudo ifconfig eth0 hw ether  xx:xx:xx:xx:xx:xx
    sudo ifconfig eth0 up
    

    However, I have to enter this command every time I start my computer. How to set MAC address permanently?

  • user258821
    user258821 almost 10 years
    I created a .sh file with these scripts in my documents and added it as a startup program in Startup Applications Manager. Didn't help, still had to enter the commands manually in terminal.
  • Warren Hill
    Warren Hill almost 9 years
    how does this make it permanent?