Use statically-generated mac addresses.
This commit is contained in:
@@ -38,6 +38,8 @@ function start_vm {
|
||||
bridge_name="bridge_${host_interface_name}"
|
||||
ip_range="$5"
|
||||
|
||||
mac_address=$(calculate_mac_address "$name")
|
||||
|
||||
assert_bridge "$host_interface_name" "$bridge_name" "$ip_range"
|
||||
bridge_link_name=$(detect_available_link "${bridge_name}")
|
||||
|
||||
@@ -60,7 +62,8 @@ function start_vm {
|
||||
-H \
|
||||
-s 0,hostbridge \
|
||||
-s "4,nvme,/dev/zvol/${zfs_path}/disk0" \
|
||||
-s "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name}" \
|
||||
-s "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}" \
|
||||
-s 3,ahci-cd,/vm/.iso/archlinux-2023.04.01-x86_64.iso \
|
||||
-s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080 \
|
||||
-s 30,xhci,tablet \
|
||||
-s 31,lpc -l com1,stdio \
|
||||
@@ -129,5 +132,11 @@ function ng_exists {
|
||||
ngctl status "${1}" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
function calculate_mac_address {
|
||||
name="$1"
|
||||
source=$(md5 -r -s "$name" | awk '{print $1}')
|
||||
echo "${source:0:2}:${source:2:2}:${source:4:2}:${source:6:2}:${source:8:2}:${source:10:2}"
|
||||
}
|
||||
|
||||
|
||||
main "${@}"
|
||||
|
||||
Reference in New Issue
Block a user