I have few computers each with same ethernet MAC address. I want to change ethernet MAC address on each computer as soon as network card is detected so I do not have any conflicts in the network. My system is using nonstandard linux with systemd. Is it possible to configure MAC address using systemd and standard linux commands?

  • 1
    Configure a static IP of your own in /etc/network/interface!
    – Thushi
    Jun 6, 2017 at 9:33
  • @Thushi I was talking about mac address. IP address is taken from dhcp. Jun 6, 2017 at 9:56
  • @Trismegistos, probably easiest to tie it to the distro's interface configuration scripts, and there might already be a system for doing that. Unless you really definitely want to do it manually, of course.
    – ilkkachu
    Jun 6, 2017 at 11:20
  • @Trismegistos: Ok, If that's the case please do mention it clearly in your question, one will think of IP address when you just mention ethernet address. Check adding udev rules.
    – Thushi
    Jun 6, 2017 at 13:01
  • 1
    @Thushi ethernet address is MAC it never been IP. IP protocol is hardware agnostic. Those are different OSI layers. Jun 6, 2017 at 14:46

2 Answers 2


Use the config line HWADDR=AA:BB:CC:DD:EE:FF in the machine's /etc/sysconfig/network-scripts/ifcfg-eth0 config file, as such:

  • I meant MAC address not IP address. IP address is taken from DHCP and for that I need unique MAC address. Moreover there is not /etc/sysconfig on my computer. Linux distribution device runs is not standard one. I wanted to use systemd for that because it configures devices. Jun 6, 2017 at 9:57
  • 1
    This is for RHEL. Which Linux distro are you using?
    – dr_
    Jun 6, 2017 at 10:44

I'm using Parrot Home (Debian based distro) and after checking some sugestions I made a script to do it in every boot for eth0 and wlan0.

  1. Login in root and install macchanger with apt-get install macchanger -y

  2. Create a file in /etc/cron.daily/: vim /etc/cron.daily/macchanger.sh

  3. Check the name of your network adapters with ip a (in the most of cases it's eth0 and wlan0, for Ethernet and Wi-Fi respectively) and put the follow code in the file: #!/bin/bash sudo ifconfig eth0 down; sudo ifconfig wlan0 down; sudo macchanger -r eth0; sudo macchanger -r wlan0; sudo ifconfig eth0 up; sudo ifconfig wlan0 up

    Exit vim by pressing ESC, write wq and pressing ENTER.

  4. Make the file executable with chmod +x /etc/cron.daily/macchanger.sh

  5. Create a crontab to execute your script with crontab -e and create a new final line with: @reboot sh /etc/cron.daily/macchanger.sh

These five steps created a automatic mac changer in linux in ever system startup!

  • A sudo command run under cron will fail unless you have configured it (sudo) to be passwordless. It’s better to use sudo to put the command into root’s crontab. Jun 26, 2019 at 3:26
  • Thank you brother!
    – PySnowden
    Jun 30, 2019 at 23:45
  • This only works after the network has already been initialized (hence why you start with ifconfig eth0 down) so I don't think this is the best solution. Mar 22, 2021 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .