From 2e15b1219fc64ecd6256fd9567066712d8deb1e2 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Fri, 19 Aug 2022 21:15:36 +0100 Subject: [PATCH] Allow persist MAC addresses for bridged interfaces. Fixes #287 --- README.md | 10 +++++++++- docs/quickemu_conf.1.md | 14 ++++++++++++-- quickemu | 10 +++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 798b281..b44f342 100644 --- a/README.md +++ b/README.md @@ -631,10 +631,18 @@ additional line to your virtual machine configuration: # Bridged networking Connect your virtual machine to a preconfigured network bridge. Add an -additional line to your virtual machine configuration +additional line to your virtual machine configuration: - `network="br0"` +If you want to have a persistent MAC address for your bridged network interface +in the gust VM you can add `macaddr` to the virtual machine configuration. QEMU +requires that the MAC address is in the range: **52:54:00:AB:00:00 - 52:54:00:AB:FF:FF** + +So you can generate your own MAC addresses with: + +- `macaddr="52:54:00:AB:51:AE"` + # USB redirection Quickemu supports USB redirection via SPICE pass-through and host diff --git a/docs/quickemu_conf.1.md b/docs/quickemu_conf.1.md index 84ce1ad..45feee7 100644 --- a/docs/quickemu_conf.1.md +++ b/docs/quickemu_conf.1.md @@ -26,7 +26,6 @@ These are the options and defaults for the \.conf file ``` bash # Lowercase variables are used in the VM config file only boot="efi" -bridge="" cpu_cores="" disk_img="" disk_size="" @@ -35,7 +34,9 @@ floppy="" guest_os="linux" img="" iso="" +macaddr="" macos_release="" +network="" port_forwards=() preallocation="off" ram="" @@ -77,6 +78,7 @@ disk_img="windows-11/disk.qcow2" iso="windows-11/Win11_EnglishInternational_x64.iso" fixed_iso="windows-11/virtio-win.iso" tpm="on" +secureboot="on" ``` - `guest_os="windows"` instructs `quickemu` to optimise for Windows. @@ -202,10 +204,18 @@ additional line to your virtual machine configuration: # Bridged networking Connect your virtual machine to a preconfigured network bridge. Add an -additional line to your virtual machine configuration +additional line to your virtual machine configuration: - `network="br0"` +If you want to have a persistent MAC address for your bridged network interface +in the gust VM you can add `macaddr` to the virtual machine configuration. QEMU +requires that the MAC address is in the range: **52:54:00:AB:00:00 - 52:54:00:AB:FF:FF** + +So you can generate your own MAC addresses with: + +- `macaddr="52:54:00:AB:51:AE"` + # USB redirection Quickemu supports USB redirection via SPICE pass-through and host diff --git a/quickemu b/quickemu index aa91577..e096602 100755 --- a/quickemu +++ b/quickemu @@ -1008,8 +1008,15 @@ function vm_boot() { elif [ -n "${network}" ]; then # Enable bridge mode networking echo " - Network: Bridged (${network})" + + # If a persistent MAC address is provided, use it. + local MAC="" + if [ -n "${macaddr}" ]; then + MAC=",mac=${macaddr}" + fi + # shellcheck disable=SC2054,SC2206 - args+=(-nic bridge,br=${network},model=virtio-net-pci) + args+=(-nic bridge,br=${network},model=virtio-net-pci${MAC}) else echo " - Network: User (${NET_DEVICE})" # shellcheck disable=SC2054,SC2206 @@ -1418,6 +1425,7 @@ floppy="" guest_os="linux" img="" iso="" +macaddr="" macos_release="" network="" port_forwards=()