Script to change Mac Address


I am using GL.Inet as a repeater and I need to change my Mac address periodically.

Trying to write a script to change Mac address but it doesn’t work. The only way works for me is go to Mac Clone > Random > Apply

Is there a script that does this? Tried two so far

NEWMAC=$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/') 
uci set wireless.sta.macaddr=${NEWMAC}  
uci commit network  

new_mac=$(dd if=/dev/random bs=1 count=3 2>/dev/null | hexdump -C | head -1 | cut -d' ' -f2- | awk '{ print "34:36:3b:"$1":"$2":"$3 }')
ifconfig $interface down
ifconfig $interface hw ether $new_mac
ifconfig $interface up

Which model are you using? Models are different.

When you say it does not work, what is the error information?

GL.iNet GL-AR750
Current Version 3.201

I am getting " uci: Entry not found" when I enter “uci commit wirless”

root@GL-AR750:~# NEWMAC=$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/') 
root@GL-AR750:~# echo "$NEWMAC"
root@GL-AR750:~# uci set wireless.sta.macaddr=${NEWMAC}
root@GL-AR750:~# uci commit wirless
uci: Entry not found
root@GL-AR750:~# uci commit network 
root@GL-AR750:~# wifi reload
root@GL-AR750:~# /etc/init.d/network reload

It is wireless, not wirless

1 Like