Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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?

share|improve this question

3 Answers 3

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|improve this answer

you can make a shell script with this commands:

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

Save the file with .sh extension and make it startup program ("Add Script" and select your script file)

Tell me how it was ?

Sorry for my bad english.

share|improve this answer
    
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. –  user258821 May 19 '14 at 16:38

Copy all the matter in the terminal


sudo ifconfig eth0 down && sudo ifconfig eth0 hw ether 00:4a:82:d5:e4:c6 && sudo ifconfig eth0 up

share|improve this answer
    
how does this make it permanent? –  Warren Hill Jul 21 at 9:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.