summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xothers/vm3/compute/create.sh6
-rw-r--r--others/vm3/default.xml13
2 files changed, 18 insertions, 1 deletions
diff --git a/others/vm3/compute/create.sh b/others/vm3/compute/create.sh
index 1a0411b..3588db4 100755
--- a/others/vm3/compute/create.sh
+++ b/others/vm3/compute/create.sh
@@ -91,10 +91,14 @@ fi
# Define the disk options based on OS type
if [ "$os" = "debian12" ]; then
disk_opts="--disk path=${new_vm},format=qcow2"
+ virt-customize -a ${new_vm} --run-command "rm -f /etc/machine-id && systemd-machine-id-setup"
else
disk_opts="--disk path=${new_vm},format=qcow2 --disk path=$seed_iso,device=cdrom"
fi
+generate_mac() {
+ printf "52:54:00:%02x:%02x:%02x\n" $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))
+}
# Use the conditional disk options in virt-install
sudo virt-install --name $vmname \
@@ -105,7 +109,7 @@ sudo virt-install --name $vmname \
--os-variant $os \
--virt-type kvm \
--graphics none \
- --network bridge=virbr0,model=virtio \
+ --network bridge=virbr0,model=virtio,mac=$(generate_mac) \
--print-xml > $xml || { sudo rm -rf $new_vm; exit 1; }
# if you want this in a new storage pool, move it to a new storage pool after initialisation
diff --git a/others/vm3/default.xml b/others/vm3/default.xml
new file mode 100644
index 0000000..bf71f7c
--- /dev/null
+++ b/others/vm3/default.xml
@@ -0,0 +1,13 @@
+<network>
+ <name>default</name>
+ <uuid>3d6341fb-fad2-49c1-b54a-41d2027f56cc</uuid>
+ <forward mode='nat'/>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <mac address='52:54:00:73:4c:22'/>
+ <ip address='192.168.124.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.124.2' end='192.168.124.254'/>
+ <option opt='61' value='ignore'/>
+ </dhcp>
+ </ip>
+</network>