I use random MAC for SSID and want to use similar MAC with only last 1 or 2 characters different.
Also how to reset the Random MAC via command ?
I use random MAC for SSID and want to use similar MAC with only last 1 or 2 characters different.
Also how to reset the Random MAC via command ?
search is a k00l feature ...
I believe this solution by @pavelgl in another post could be modified to allow you to have fixed partial octets for the first part of the MACs, then use variables to randomize the remaining octets for your wireless interfaces. Example: AA:BB:11:22:xx;xx
You could incorporate it into startup script, then use cron to schedule a nightly reboot so it changes daily. ( a scheduled /sbin/reboot )
I want to use random MAC but the random MAC used should have first 10 characters same.
@frollic @JustAnotherEndUser
So generate the 1st 10 chars only once ?
The rest +1, +2, +n, depending on what you need...
Here is another possible option based on a similar solution by @bigsmile
You could modify that solution to look like this:
#!/bin/sh
random_mac(){ printf "%02x" $(( 0x$(hexdump -n6 -ve '/1 "%02X"' /dev/urandom) & 0xFF )) | sed 's/../:&/g;s/^://';}
uci set network.wan.macaddr 11:22:33:44:55:$(random_mac)
uci commit
With the modification shown above, the 11.22.33.44.55: are fixed ( substitute those numbers with whatever base MAC you want) and the $(random_mac) is the variable of the random two characters for the last octet.
The random characters are generated from the printf "%02x"
The "2x" part is telling it the number of characters to generate.
You may want to consider making more than one octet random though. I would recommend having the first 3 octets fixed, and the last 3 random. That would look like this:
#!/bin/sh
random_mac(){ printf "%06x" $(( 0x$(hexdump -n6 -ve '/1 "%02X"' /dev/urandom) & 0xFFFFFF )) | sed 's/../:&/g;s/^://';}
uci set network.wan.macaddr 11:22:33:$(random_mac)
uci commit