Changing MAC address through console

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
Melkyore
DD-WRT Novice


Joined: 05 Apr 2014
Posts: 3

PostPosted: Sat Apr 05, 2014 20:05    Post subject: Changing MAC address through console Reply with quote
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
Sponsor
evilkitty
DD-WRT User


Joined: 12 Mar 2014
Posts: 167
Location: USA

PostPosted: Sat Apr 05, 2014 20:09    Post subject: Reply with quote
save it to the nvram
Code:
nvram set def_whwaddr=AA:BB:CC:DD:EE:FF;nvram set wan_hwaddr=AA:BB:CC:DD:EE:FF;nvram commit

_________________
Router: Buffalo WZR-300HP w/ DD-WRT build #28444
Melkyore
DD-WRT Novice


Joined: 05 Apr 2014
Posts: 3

PostPosted: Sat Apr 05, 2014 20:21    Post subject: Reply with quote
Aah, that worked. I rebooted the router, and the values I had edited were kept.

I take it there's no way to do this without rebooting?

(I don't believe there is a need to change the wan's hwaddress)
evilkitty
DD-WRT User


Joined: 12 Mar 2014
Posts: 167
Location: USA

PostPosted: Sat Apr 05, 2014 22:23    Post subject: Reply with quote
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
Code:
chmod +x /path/to/script

_________________
Router: Buffalo WZR-300HP w/ DD-WRT build #28444
Melkyore
DD-WRT Novice


Joined: 05 Apr 2014
Posts: 3

PostPosted: Sat Apr 05, 2014 22:36    Post subject: Reply with quote
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.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum