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?
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:
DEVICE=eth0 TYPE=Ethernet BOOTPROTO=none ONBOOT=yes NM_CONTROLLED=no HWADDR=AA:BB:CC:DD:EE:FF IPADDR=10.2.3.4 NETMASK=255.255.255.0 GATEWAY=10.2.3.254 DNS1=220.127.116.11 DNS2=18.104.22.168 USERCTL=no
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.
Login in root and install macchanger with
apt-get install macchanger -y
Create a file in /etc/cron.daily/:
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.
Make the file executable with
chmod +x /etc/cron.daily/macchanger.sh
Create a crontab to execute your script with
crontab -eand 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!