From 9edda48c7263f2f02d289267be2ae750a6909214 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 6 Oct 2019 18:06:15 -0400 Subject: for nested kvm, increment the MAC address --- conf/dnsmasq.conf | 5 +++++ src/qemu.sh | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/conf/dnsmasq.conf b/conf/dnsmasq.conf index 7200efc..5ab9008 100644 --- a/conf/dnsmasq.conf +++ b/conf/dnsmasq.conf @@ -4,6 +4,11 @@ dhcp-range=192.168.10.10,192.168.10.253,255.255.255.0,1h enable-tftp dhcp-host=52:54:00:12:34:56,samizdoot-vm,192.168.10.82 +dhcp-host=52:54:00:12:34:57,samizdote-vm,192.168.10.83 +dhcp-host=52:54:00:12:34:58,samizdeet-vm,192.168.10.84 +dhcp-host=52:54:00:12:34:59,samizdite-vm,192.168.10.85 +dhcp-host=52:54:00:12:34:5A,samizdate-vm,192.168.10.86 + #dhcp-host=f0:de:f1:5a:ac:e8,samizdoot-irl,192.168.10.82 pxe-service=x86PC, "Samizdat", pxelinux diff --git a/src/qemu.sh b/src/qemu.sh index 2ae982d..130b688 100755 --- a/src/qemu.sh +++ b/src/qemu.sh @@ -30,7 +30,20 @@ kcmdline_CDROM='boot=samizdat components quiet splash' kcmdline_CDROM_NET="${kcmdline_CDROM} nbdroot=,${nbd_filename}, nbddev=/dev/nbd0 ip=dhcp" kcmdline_NET="${kcmdline_CDROM_NET} netkeys" -MAC='52-54-00-12-34-56' +find_mac() +{ + start_mac=$1 + for mac in $(ip link show | grep link/ether | (read _ mac _; echo $mac | tr : -)); do + if [ "${mac%??}" = "${start_mac%??}" ]; then + prefix=${mac%??} + suffix=$(printf %x $(( 0x${mac##*-} + 1 ))) + MAC=${prefix}${suffix} + return + fi + done + MAC=$start_mac +} +find_mac 52-54-00-12-34-56 kcmdline_BOOTIF="BOOTIF=01-$MAC" -- cgit v1.2.3