How can I permanently change the mac address on a Linux 3.3.8 device without macchanger?
I'm trying to permanently modify my MAC address on a device running Linux 3.3.8 I cannot get macchanger to install either.
When I try it with
ifconfig eth0 hw ether [MAC_ADDRESS]
I get
ifconfig: SIOCSIFHWADDR: Device or resource busy
I have ssh'd into the device. The device is on wifi and ethernet. I've connected through wifi and trying to change the ethernet's mac address. I've tried
ifconfig eth0 down
ifconfig etho hw NEW_MAC
get the error: ifconfig: SIOCSIFHWADDR: Device or resource busy
ifconfig eth0 up
ifconfig shows the mac address was updated. However the GUI elements still show the old mac address. Also, the changes are lost after restart.
> uname -a
> Linux (none) 3.3.8-4.2-g8c1f1dd #1 SMP Thu Jun 27 11:30:45 UTC 2019 mips GNU/Linux
The MAC address should be changed before the system brings up the network interface.
Bring down the interface to test: ip link set dev eth0 down
, change the MAC address, then ip link set dev eth0 up
. Verify that the change was carried out, for example by typing ip link
.
You did not specify your flavor of Linux. Assuming you have a Debian-like system,
to make the change permanent you can add a line in /etc/network/interfaces
.
Locate your eth0 stanza and use the hwaddress
directive eg:
iface eth0 inet dhcp
hwaddress ether xxxxxxxxx
where xxxxxxxxx represents your chosen address. If you prefer a random address then you can use macchanger
and add a line in that same /etc/network/interfaces
file:
iface eth0 inet dhcp
pre-up macchanger -r eth0
If your network interface is managed by Network Manager, then you can randomize the MAC address for all interfaces or on a per-connection basis. have a look here for example or here. You can use the nmcli
utility (or nmtui
).