mirror of
https://github.com/Fishwaldo/build.git
synced 2025-06-27 16:49:00 +00:00
[bugfix] Set fixed IP address from first randomly assigned one.
This commit is contained in:
parent
ca99f8d0b7
commit
345145f3b6
1 changed files with 9 additions and 2 deletions
|
@ -30,10 +30,17 @@ local random=$(shuf -i 0-3 -n 1)
|
|||
MACADDR=$(printf ${prefixes[$random]}':%02X:%02X:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
|
||||
}
|
||||
|
||||
|
||||
# set fixed IP address from first randomly assigned one. If nothing is deteceted, generate one.
|
||||
set_fixed_mac ()
|
||||
{
|
||||
get_random_mac
|
||||
uuid=$(nmcli -f UUID,DEVICE,TYPE connection show --active | grep ethernet | awk '{print $1}' | head -1)
|
||||
|
||||
local nmcli_query=$(nmcli -f UUID,DEVICE,TYPE connection show --active | grep ethernet | head -1)
|
||||
device=$(echo $nmcli_query | awk '{print $2}' )
|
||||
uuid=$(echo $nmcli_query | awk '{print $1}' )
|
||||
MACADDR=$(nmcli device show $device | grep -i hwaddr | awk '{print $2}')
|
||||
[[ -z $MACADDR ]] && get_random_mac
|
||||
|
||||
if [[ -n $uuid ]]; then
|
||||
nmcli connection modify $uuid ethernet.cloned-mac-address $MACADDR
|
||||
nmcli connection modify $uuid -ethernet.mac-address ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue