Posted: Sat Apr 05, 2014 20:05 Post subject: Changing MAC address through console
Hello, for reasons of vanity I tried to write a script that would cycle the wlan interface's MAC address every hour.
After a bit of trial and error (and google), I managed to change it with ifconfig.
Unfortunately, the router stops emitting its SSID and no devices may connect to it. After a few minutes, it reverts back to its old MAC address, starts emitting an SSID, and allows devices back in.
The router is a TP-LINK WR741ND v1, running on "DD-WRT v24-sp2 (02/19/14) std".
The wlan interface's name is ath0.
Here's the process I've used so far. It's not part of the script yet:
Code:
ifconfig ath0 down
ifconfig ath0 hw ether 4E:53:50:4F:4F:4A
nvram set wl0_hwaddr=4E:53:50:4F:4F:4A
nvram commit
ifconfig ath0 up
After rebooting the router, wl0_hwaddr is back to 4E:53:50:4F:4F:46.
I know that changing the router's MAC addresses is supported, since the one it currently has was changed through the web gui.
I'm probably missing a step somewhere. I'm suspecting that it has something to do with startservice/stopservice, but I have no idea what the service's name is.
Any help is appreciated!
(I'm sure this is the right forum; /proc/cpuinfo returns an atheros cpu)
Last edited by Melkyore on Sat Apr 05, 2014 20:12; edited 1 time in total
i thought it would be applied when you used ifconfig to apply the setting
on my router this appears to be what is done when i set it via the UI
you could save this script to your router's ram/usb disk and run it
Code:
/path/to/script A0:B1:C2:D3:E4:F5
or run
Code:
/path/to/script
to apply the default mac defined in the script
Code:
#!/bin/sh
if [ -z "$1" ];then
MAC="$1"
else
MAC="AA:BB:CC:DD:EE:FF"
fi
ifconfig vlan2 hw ether $MAC
nvram set def_whwaddr=$MAC
nvram set wan_hwaddr=$MAC
nvram commit
if you save that script don't forget to make it executable
The problem right now is, if I apply the change through ifconfig the router stops emitting a detectable wifi signal.
The router's wifi will work again if I reboot it.
EDIT: I figured out what I need, but do not know the command to do it.
If I use the gui interface to turn off the wifi radio, and then turn it back on, the new mac address will take hold and the wifi will work.
I need the method by which it manages to disable the radio and then re-enables it, but through the command line.
EDIT 2:
Okay, I think I need to kill the hostapd process and then start it again. I also need a way to change the BSSID in the ath0_hostap.conf file to cover all my bases.