diff --git a/template/Prepare-LinuxBuild2404.ps1 b/template/Prepare-LinuxBuild2404.ps1 index 599dc0c..c37c480 100644 --- a/template/Prepare-LinuxBuild2404.ps1 +++ b/template/Prepare-LinuxBuild2404.ps1 @@ -374,6 +374,20 @@ if ($failures.Count -gt 0) { } Write-Host "[Prepare] All post-setup checks passed." -ForegroundColor Green +# ── Step 7b — Clear machine-id (DHCP uniqueness for clones) ────────────────── +# Each clone boots with an empty machine-id; systemd generates a fresh one from +# /dev/urandom on first boot. Without this, all clones share the same DHCP +# client-id and receive the same IP from VMware DHCP — causing IP collisions. +Write-Host "[Prepare] Step 7b — Clearing machine-id for DHCP uniqueness..." +Invoke-SshCommand -IP $VMIPAddress -User $CloudUser -KeyPath $SshKeyPath ` + -Command 'sudo truncate -s 0 /etc/machine-id && sudo rm -f /var/lib/dbus/machine-id' +Assert-Step 'MachineId' '/etc/machine-id is empty' { + $size = (Invoke-SshCommand -IP $VMIPAddress -User $CloudUser -KeyPath $SshKeyPath ` + -Command 'stat -c %s /etc/machine-id' -PassThru).Trim() + $size -eq '0' +} +Write-Host "[Prepare] machine-id cleared — each clone will generate a unique ID on first boot." -ForegroundColor Green + # ── Step 8 — Shutdown + snapshot ───────────────────────────────────────────── if ($TakeSnapshot -or $VMXPath -ne '') { Write-Host "[Prepare] Step 8 — Sending graceful shutdown to guest..." @@ -435,4 +449,4 @@ if ($TakeSnapshot -or $VMXPath -ne '') { } else { Write-Host " Snapshot: not taken — run manually then use -SnapshotName '$SnapshotName'" } - +