-
-
Save aknik/4ae7859bdbdea4f60b96d5b6ed714d87 to your computer and use it in GitHub Desktop.
pub openwrt connection with random mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uci set wireless.radio1.country='US' | |
uci set wireless.radio1.txpower='30' | |
uci set wireless.radio1.htmode='HT40' | |
uci set wireless.radio1.channel='auto' | |
uci set wireless.@wifi-iface[1]=wifi-iface | |
uci set wireless.@wifi-iface[1].ssid='.........' | |
uci set wireless.@wifi-iface[1].encryption='psk2+ccmp' | |
uci set wireless.@wifi-iface[1].device='radio1' | |
uci set wireless.@wifi-iface[1].mode='sta' | |
uci set wireless.@wifi-iface[1].key='..................' | |
uci set wireless.@wifi-iface[1].network='lan wwanUSB' | |
ifdown wwanUSB | |
OLDMAC=$(uci get network.wwanUSB.macaddr) | |
echo ${OLDMAC} | |
while true; do | |
NEWMAC=$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/') | |
foo=$((0x${NEWMAC:0:2})) | |
# Comprueba que el primer byte de la MAC sea par, si no lo es repite hasta que lo sea | |
if [ $((foo%2)) -eq 0 ]; | |
then | |
echo "par"; | |
break | |
else | |
echo "impar"; | |
fi | |
done | |
echo ${NEWMAC} | |
uci set wireless.@wifi-iface[1].macaddr=${NEWMAC} | |
uci set network.wwanUSB.macaddr=${NEWMAC} | |
uci commit wireless | |
ifup wwanUSB | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment