Skip to content

Conversation

@pallotron
Copy link
Contributor

@pallotron pallotron commented Oct 11, 2025

This commit introduces a new --vmnet-network-uuid command-line option to allow setting the vmnet_network_identifier_key for vmnet.

This property is only applicable to a vmnet_interface in VMNET_HOST_MODE.

If this property is set, the vmnet_interface is added to an isolated network with the specified identifier.

No DHCP service is provided on this network.

This is useful for certain applications where the users need an isolated network and are running their own dhcp to assign IPs in such network.

See issue #139

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch from 9d431ca to 9750c51 Compare October 15, 2025 19:19
Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pallotron thanks! This Looks like an interesting feature but it is not clear what is the purpose of the new identifier.

@pallotron
Copy link
Contributor Author

@pallotron thanks! This Looks like an interesting feature but it is not clear what is the purpose of the new identifier.

Thanks for the feedback! You've raised a great point about the purpose of the new identifier. Let me clarify.

The primary goal of this change is to enable running a custom DHCP server on a vmnet network, which is essential for specialized setups like a PXE boot environment.

The Problem

I'm building a virtual lab to test our production PXE boot stack. This involves a "provisioner" VM (running dhcpd, tftp, etc.) and multiple "client" VMs that network-boot from it. For this to work, the client VMs and the provisioner need to be on an isolated network where my custom dhcpd can manage IP allocation.

The issue is that vmnet.framework runs its own DHCP server on VMNET_[HOST|SHARED]_MODE networks by default because it provides IP addresses to the VMs that your are booting.
This is ok for most of the use cases. However this default DHCP server conflicts with the custom one I need to run for the PXE environment, creating a race condition where either macOS or my dhcpd responds to DHCP requests first.

The Solution

While digging into the vmnet.framework headers, I found a solution provided by Apple. According to
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/vmnet.framework/Headers/vmnet.h:

    1 /*!
    2  * @constant vmnet_network_identifier_key
    3  * The identifier (uuid) to uniquely identify the network.
    4  *
    5  * This property is only applicable to a vmnet_interface in
    6  * VMNET_HOST_MODE.
    7  *
    8  * If this property is set, the vmnet_interface is added to
    9  * an isolated network with the specified identifier.
   10  *
   11  * No DHCP service is provided on this network.
   12  */
   13 extern const char * const
   14 vmnet_network_identifier_key API_AVAILABLE(macos(11.0)) API_UNAVAILABLE(ios, watchos, tvos);

By setting the vmnet_network_identifier_key, we can create an isolated VMNET_HOST_MODE network without the conflicting DHCP service. This allows the custom DHCP server in the provisioner VM to function correctly. This feature has been available since macOS 11.0.

This allows me to start multiple client VMs on the same socket_vmnet socket, they can take IP addresses from provisioner VM just fine, the provisioner VM also work as a router and can forward client VMs traffic to the internet.

It's also worth noting that a more explicit API is coming in the future. The same header file mentions:

   1 /*!
   2  * @function vmnet_network_configuration_disable_dhcp
   3  * Disables DHCP server on a network.
   4  */
   5 void
   6 vmnet_network_configuration_disable_dhcp(vmnet_network_configuration_ref config)
   7 API_AVAILABLE(macos(26.0)) API_UNAVAILABLE(ios, watchos, tvos);

This vmnet_network_configuration_disable_dhcp function will be the standard way to achieve this, but it's only available on macOS 26.0 (Tahoe). For now, using vmnet_network_identifier_key + VMNET_HOST_MODE is the correct approach.

I hope this clears things up! Let me know if you have any other questions.
I have seen your other comments and I will address them tomorrow.

@jandubois
Copy link
Member

This sounds interesting. I think it would be nice to also provide a template with DHCP, router, and maybe even firewall and proxy, to show users how they can set up isolated networks for testing.

@pallotron
Copy link
Contributor Author

This sounds interesting. I think it would be nice to also provide a template with DHCP, router, and maybe even firewall and proxy, to show users how they can set up isolated networks for testing.

Are you saying in this PR, I think it would be out of scope for this particular PR. But I agree with you it would be nice.
My project does exactly that. I will see if I can get approval to publish it.

@pallotron
Copy link
Contributor Author

sorry guys, I had a bicycle incident... I will get back at this and resolve all feedbacks once I can type on my laptop w/o pain :(

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch 2 times, most recently from f5abd62 to e463209 Compare November 6, 2025 23:22
Copy link
Contributor Author

@pallotron pallotron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am back! :)
This should be now satisfy all feedback I recieved.

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch 4 times, most recently from c18916a to 4642f9e Compare November 6, 2025 23:51
@pallotron pallotron changed the title feat: Allow specifying vmnet network UUID to disable DHCP (on vmnet.h… feat: Allow specifying vmnet network UUID to disable DHCP (when in Host mode) Nov 7, 2025
@pallotron
Copy link
Contributor Author

@nirs hey can you let me know if the PR looks good now?

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch 2 times, most recently from 280ae44 to b84a7e4 Compare November 17, 2025 21:55
@AkihiroSuda
Copy link
Member

Please squash the commits
https://lima-vm.io/docs/dev/git/#squashing-commits

…ost network only)

This commit introduces a new `--vmnet-network-uuid` command-line option to allow
setting the `vmnet_network_identifier_key` for vmnet.

This property is only applicable to a vmnet_interface in
VMNET_HOST_MODE.

If this property is set, the vmnet_interface is added to an isolated
network with the specified identifier.

No DHCP service is provided on this network.

This is useful for certain applications where the users need an isolated
network and are running their own dhcp to assign IPs in such network.

See issue [lima-vm#139](lima-vm#139)

Signed-off-by: Angelo Failla <[email protected]>
@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch from b84a7e4 to 63acef2 Compare November 18, 2025 08:25
@pallotron
Copy link
Contributor Author

Please squash the commits https://lima-vm.io/docs/dev/git/#squashing-commits

I've squashed the commits as requested. I keep forgetting this specific project rules. Could you now please focus the review on the logical content of the change? I'd appreciate your feedback on the functional aspects which you could have provided when you mentioned about squashing and the stupid space after TIP introduced by stupid vscode markdown plugin.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good

@AkihiroSuda AkihiroSuda added this to the v1.2.2 milestone Nov 18, 2025
@jandubois jandubois merged commit 7160c75 into lima-vm:master Nov 18, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants