4

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
  • 219
  • 1
  • 2
  • 8

3 Answers3

2

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.

solsTiCe
  • 9,231
0

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.

midway
  • 9
  • 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
-3

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