Proper random MAC handling. Set range for Allwinner and locally administered addresses for others.
This commit is contained in:
parent
acf84bac59
commit
b3d98ecbdb
@ -23,9 +23,15 @@ EOT
|
||||
chmod +x /etc/update-motd.d/90-warning
|
||||
} # show_motd_warning
|
||||
|
||||
get_random_mac ()
|
||||
{
|
||||
if [[ $LINUXFAMILY == sunxi ]]; then prefix="DC:44:6D"; else prefix="X2-00-00"; fi
|
||||
MACADDR=$(printf $prefix':%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
|
||||
}
|
||||
|
||||
set_fixed_mac ()
|
||||
{
|
||||
MACADDR=$(printf 'da:42:ea:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
|
||||
get_random_mac
|
||||
uuid=$(nmcli -f UUID,DEVICE,TYPE connection show --active | grep ethernet | awk '{print $1}' | head -1)
|
||||
if [[ -n $uuid ]]; then
|
||||
nmcli connection modify $uuid ethernet.cloned-mac-address $MACADDR
|
||||
@ -33,4 +39,5 @@ if [[ -n $uuid ]]; then
|
||||
nmcli connection up $uuid >/dev/null 2>&1
|
||||
return 0
|
||||
fi
|
||||
} # set fixed mac to the 1st active network adapter
|
||||
} # set fixed mac to the 1st active network adapter
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ case "$1" in
|
||||
fi
|
||||
|
||||
# randomize mac in armbianEnv.txt
|
||||
MACADDR=$(printf 'DC:44:6D:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
|
||||
get_random_mac
|
||||
[[ -f /boot/armbianEnv.txt ]] && sed -i "s/^ethaddr=.*/ethaddr=$MACADDR/" /boot/armbianEnv.txt
|
||||
|
||||
# hardware workarounds per family
|
||||
@ -77,9 +77,9 @@ case "$1" in
|
||||
;;
|
||||
"Orange Pi Zero"|"NanoPi Duo"|"Sunvell R69")
|
||||
# set XR819 WiFi address permanently based on a random address using Allwinner's MAC prefix
|
||||
MACADDR=$(printf 'DC:44:6D:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
|
||||
echo "options xradio_wlan macaddr=${MACADDR}" >/etc/modprobe.d/xradio_wlan.conf
|
||||
echo -e "\n### [firstrun] Use MAC address ${MACADDR} for Wi-Fi from now" >>${Log}
|
||||
get_random_mac
|
||||
echo "options xradio_wlan macaddr=${MACADDR}" >/etc/modprobe.d/xradio_wlan.conf
|
||||
echo -e "\n### [firstrun] Use MAC address ${MACADDR} for Wi-Fi from now" >>${Log}
|
||||
cd /etc/network/ && ln -sf interfaces.network-manager interfaces
|
||||
(modprobe -r xradio_wlan && sleep 1 && modprobe xradio_wlan) &
|
||||
;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user