Comments On Sat, Jun 28, 2025 at 12:49 PM Nick <atod101...@gmail.com> wrote:
> Does anyone have a document on how to accomplish this? > > I understand one method is using socket_vmnet, however this appears to > utilize MacOS's DHCP server in assigning addresses. I would like to use my > own DHCP server to assign addresses based on MAC address. > > I'm assuming the other configuration require will utilize either tuntap > (Monterey) or tunnelblick (Ventura+)? /etc/pf.conf must be edited? > > I found a possible solution for MacOS, which follows. I think there's another solution, which is to invoke qemu as root with appropriate options, appreciate any guidance on that. I found a debug work around solution to this problem. There are two solutions to running your own DHCP server so you can provide DHCP options to QEMU VMs. I use socket_vmnet to create a network bridge for the HostOnly network. Here is my working debug configs. One is to use ISC DHCP server on the Mac, disabling MacOS DHCP server in scripts. The other is to use the Mac supplied DHCP server and edit some config files. It would be nice if socket_vmnet had an option to disable the DHCP server (I tried limiting the IP range to nothing, but it still assigns an IP and the Mac DHCP server starts). When I finish testing I'll put a write up of this somewhere. USE ISC DHCP SERVER: Install sudo port install socket_vmnet sudo port install isc-dhcp Configure ISC DHCP server Start ISC DHCP server Launch socket_vmnet sudo socket_vmnet --vmnet-interface=bridge100 --vmnet-gateway=192.168.57.1 --vmnet-dhcp-end=192.168.57.1 /var/run/socket_vmnet Stop DHCP server on MacOS sudo launchctl unload -F /System/Library/LaunchDaemons/bootps.plist Now start the VM socket_vmnet_client /var/run/socket_vmnet qemu-system-x86_64 -accel hvf -device virtio-net-pci,netdev=net0,mac=52:54:00:12:34:56 -netdev socket,id=net0,fd=3 -m 8000 -drive file=debian_12-1_s0-disk1.qcow2 MAC SUPPLIED BOOTP/DHCPD: The other option is to use the MacOS supplied DHCP server with options: Install socket_vmnet Configure MacOS DHCP server cd /etc sudo cp bootpd.plist bootpd.plist.socket_vmnet 3. Edit bootpd.plist in <subnets><array><dict> section add following: <!-- Debian Includes These --> <!-- Auto-Config --> <key>dhcp_option_116</key> <string>1</string> <!-- Broadcast Address --> <key>dhcp_option_28</key> <string>192.168.57.255</string> At the bottom change: <key>use_server_config_for_dhcp_options</key> <false/> At the bottom change: <key>use_server_config_for_dhcp_options</key> <false/> Edit /etc/bootptab $ sudo cat bootptab # bootptab %% # hostname hwtype hwaddr ipaddr bootfile deb12-0 1 52:54:00:12:34:56 192.168.57.2 Start socket_vmnet per ISC config above Stop the MacOS DHCP server sudo cp bootpd.plist.socket_vmnet bootpd.plist && sudo launchctl unload -F /System/Library/LaunchDaemons/bootps.plist && sudo launchctl load -F /System/Library/LaunchDaemons/bootps.plist Launch the VM via QEMU per above ISC config steps If you're going to do NAT over the same interface you need to edit /etc/pf.conf for NAT over the same interface that is on the hostonly network. I'm still working on this but here's a debug version. /etc/pf.conf # # com.apple anchor point # icmp_types = "echoreq" #priv_nets = "{ 127.0.0.0/8, 192.168.57.0/24, 10.0.0.0/8 }"; set block-policy drop set loginterface en1 set skip on lo0 scrub in all scrub-anchor "com.apple/*" nat-anchor "com.apple/*" rdr-anchor "com.apple/*" nat on en1 from bridge100:network to any -> (en1) pass in quick on bridge100 inet from 192.168.0.0/24 to 192.168.0.10 pass out quick on en1 proto udp all keep state pass out quick on en1 proto tcp all modulate state flags S/SA pass in quick on bridge100 inet from 192.168.0.0/24 to 192.168.57.1 pass in quick on bridge100 inet from 192.168.0.0/24 to any keep state pass in quick log on 192.168.57.1 all pass in all pass out all dummynet-anchor "com.apple/*" anchor "com.apple/*" load anchor "com.apple" from "/etc/pf.anchors/com.apple" Load it: $ sudo pfctl -n -f /etc/pf.conf