UTM icon indicating copy to clipboard operation
UTM copied to clipboard

sticky DHCP

Open nick-b-1 opened this issue 2 years ago • 4 comments

I notice my 192.168.64.x address changes every few days or weeks on the default networking in my MacOS UTM setup. It would be nice if these address were more sticky in that the served DHCP address wouldn't change over time unless there was a reason for it (lots of devices).

nick-b-1 avatar May 02 '23 17:05 nick-b-1

Try using "Emulated VLAN' instead of 'Shared network'. The host always has 10.0.2.2 and guest 10.0.2.15 as seen from the guest. This works for me with both Linux and Windows guests.

freebrowser1 avatar Jun 04 '23 12:06 freebrowser1

I'm only seeing "Shared Network" and "Bridged" in my network settings.

nick-b-1 avatar Jun 06 '23 05:06 nick-b-1

I also see only shared and bridged, but even bridged is not working, which would allow me to setup it at my physical network dhcp level.

jairov4 avatar Sep 10 '24 17:09 jairov4

Same here, for some reason the DHCP range is changed once in a while and I have to reconfigure my local setup to use the new address. This is the workaround I'm testing right now, executing the same on every boot, but I wonder how "stable" this is, or if macOS decides to change Shared_Net_Address at any time:

$ sw_vers --productVersion; uname -m; utmctl version
15.7.1
arm64
4.7.4

$ sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.vmnet.plist Shared_Net_Address
192.168.67.1

$ sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.vmnet.plist Shared_Net_Address 192.168.66.1
$ sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.vmnet.plist Shared_Net_Address
192.168.66.1

Starting the VM again and it receives a DHCP lease from 192.168.66.0/24. 🎉

Edit: maybe I have to do something about /var/db/dhcpd_leases, as the old (and unwanted) address is still mentioned here:

$ grep -B1 -A4 -e 192.168.67.2 -e 192.168.66.3 /var/db/dhcpd_leases 
        name=foobar
        ip_address=192.168.66.3
        hw_address=ff,49:6c:4c:6f:0:1:0:1:2f:67:7f:4c:6a:79:49:6c:4c:6f
        identifier=ff,49:6c:4c:6f:0:1:0:1:2f:67:7f:4c:6a:79:49:6c:4c:6f
        lease=0x68dfdf88
}
--
        name=foobar
        ip_address=192.168.67.2
        hw_address=ff,49:6c:4c:6f:0:1:0:1:2f:67:7f:4c:6a:79:49:6c:4c:6f
        identifier=ff,49:6c:4c:6f:0:1:0:1:2f:67:7f:4c:6a:79:49:6c:4c:6f
        lease=0x68dfdc03
}

ckujau avatar Oct 03 '25 13:10 ckujau