Skip to content

Conversation

pallotron
Copy link

@pallotron pallotron commented Oct 8, 2025

What

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.

Why

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

Testing

Printed new --help

❯ make
cc -O3 -Wall -Wextra -pedantic -DVERSION=\"a7cc880.m\" -c cli.c -o cli.o
cc -O3 -Wall -Wextra -pedantic -DVERSION=\"a7cc880.m\" -o socket_vmnet  -framework vmnet cli.o main.o


❯ sudo ./socket_vmnet --help
Usage: ./socket_vmnet [OPTION]... SOCKET
vmnet.framework support for rootless QEMU.
socket_vmnet does not require QEMU to run as the root user, but socket_vmnet itself has to run as the root, in most cases.

--socket-group=GROUP                socket group name (default: "staff")
--vmnet-mode=(host|shared|bridged)  vmnet mode (default: "shared")
--vmnet-interface=INTERFACE         interface used for --vmnet=bridged, e.g., "en0"
--vmnet-gateway=IP                  gateway used for --vmnet=(host|shared), e.g., "192.168.105.1" (default: decided by macOS)
                                    the next IP (e.g., "192.168.105.2") is used as the first DHCP address
--vmnet-dhcp-end=IP                 end of the DHCP range (default: XXX.XXX.XXX.254)
                                    requires --vmnet-gateway to be specified
--vmnet-mask=MASK                   subnet mask (default: "255.255.255.0")
                                    requires --vmnet-gateway to be specified
--vmnet-interface-id=UUID           vmnet interface ID (default: random)
--vmnet-network-identifier=UUID     vmnet network identifier (UUID string, "random", or "")
                                    When vmnet mode is "host" and --vmnet-gateway is not set, the internal DHCP will be disabled.
                                    (default: "random")
--vmnet-nat66-prefix=PREFIX::       The IPv6 prefix to use with shared mode.
                                    The prefix must be a ULA i.e. start with fd00::/8.
                                    (default: random)
-p, --pidfile=PIDFILE               save pid to PIDFILE
-h, --help                          display this help and exit
-v, --version                       display version information and exit

version: a7cc880.m

Ran locally in host mode w/p network UUID provided -> DHCP enabled, backward compatible

❯ sudo ./socket_vmnet "/opt/homebrew/var/run/socket_vmnet" --vmnet-mode=host
INFO | Initializing vmnet.framework (mode 1000)
INFO | * vmnet_write_max_packets: 256
INFO | * vmnet_read_max_packets: 256
INFO | * vmnet_subnet_mask: 255.255.255.0
INFO | * vmnet_mtu: 1500
INFO | * vmnet_end_address: 192.168.111.254
INFO | * vmnet_start_address: 192.168.111.1
INFO | * vmnet_interface_id: 493B7D05-7098-462E-A535-9A09E9F23015
INFO | * vmnet_max_packet_size: 1514
INFO | * vmnet_mac_address: be:03:14:a1:76:2f

Ran locally in shared mode -> DHCP enabled, backward compatible

❯ sudo ./socket_vmnet "/opt/homebrew/var/run/socket_vmnet" --vmnet-gateway=192.168.111.1
INFO | Initializing vmnet.framework (mode 1001)
INFO | * vmnet_write_max_packets: 256
INFO | * vmnet_read_max_packets: 256
INFO | * vmnet_subnet_mask: 255.255.255.0
INFO | * vmnet_mtu: 1500
INFO | * vmnet_end_address: 192.168.111.254
INFO | * vmnet_start_address: 192.168.111.1
INFO | * vmnet_interface_id: 7C36E6A4-9462-41C1-9102-32052F371566
INFO | * vmnet_max_packet_size: 1514
INFO | * vmnet_nat66_prefix: fd44:1114:5237:b1c3::
INFO | * vmnet_mac_address: c6:fd:21:f7:7d:52

Ran local in host mode + random network identifier: no dhcp, new behavior

❯ sudo ./socket_vmnet "/opt/homebrew/var/run/socket_vmnet" --vmnet-mode=host --vmnet-network-identifier=random
INFO | Initializing vmnet.framework (mode 1000)
INFO | Using network identifier "BBE66D8F-61C8-4393-82F8-7FAE5FE9706D" and no vmnet gateway -> NO DHCP will be enabled on this vmnet
INFO | * vmnet_write_max_packets: 256
INFO | * vmnet_read_max_packets: 256
INFO | * vmnet_subnet_mask: 0.0.0.0
INFO | * vmnet_mtu: 1500
INFO | * vmnet_end_address: 255.255.255.254
INFO | * vmnet_start_address: 0.0.0.0
INFO | * vmnet_interface_id: 98B26815-84E6-4064-98B5-EB9D21A91082
INFO | * vmnet_max_packet_size: 1514
INFO | * vmnet_mac_address: e6:ce:e1:2a:75:af

@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 Oct 8, 2025
@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch 6 times, most recently from c49d5b0 to 9de6fa5 Compare October 8, 2025 11:01
@pallotron
Copy link
Author

let me know if you want to create a correspondent io.github.lima-vm.socket_vmnet.host_dhcp.plist in launchd/ and relative modications to the Makefile.

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch 7 times, most recently from df1f00b to f912515 Compare October 9, 2025 08:03
@pallotron
Copy link
Author

@AkihiroSuda hey can you guys let me know what you think of this when you get a chance? :)

@AkihiroSuda
Copy link
Member

Thanks, but please sign the commit for DCO
https://github.com/apps/dco

(run git commit -a -s --amend, and make sure that the Signed-off-by: NAME <EMAIL> line with your real name is included in the commit message)

@AkihiroSuda AkihiroSuda added this to the v1.2.2 milestone Oct 10, 2025
Copy link
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.

thanks for the comments, and sorry about the signature mishap.
I was using my corporate laptop and the setup there is a bit messy. Will fix.

@pallotron
Copy link
Author

Thanks, but please sign the commit for DCO https://github.com/apps/dco

(run git commit -a -s --amend, and make sure that the Signed-off-by: NAME <EMAIL> line with your real name is included in the commit message)

I think my commits are all good yet but I dunno why DCO is failing now :(

image

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch from c843af1 to f7bdb95 Compare October 10, 2025 09:44
@pallotron
Copy link
Author

my last commit has the sign-off but I dunno why DCO is failing... :(
do I need to squash all commits?

commit f7bdb95a66ed3093ac5893e41a373a357bb945fc (HEAD -> feature/no_dhcp_issue_139, origin/feature/no_dhcp_issue_139)
Good "git" signature for pallotron@gmail.com with ED25519 key SHA256:bCGybCKH6mAgRuXgyjQSoTKIlRJOyIxRny1Gmg/3MmI
Author: Angelo Failla <pallotron@gmail.com>
Date:   Fri Oct 10 10:26:15 2025 +0100

    fix comment as per review

    Signed-off-by: Angelo Failla <pallotron@gmail.com>

commit f912515d2d431d939f5a77afcf073cdfd99ef4ec
Good "git" signature for pallotron@gmail.com with ED25519 key SHA256:bCGybCKH6mAgRuXgyjQSoTKIlRJOyIxRny1Gmg/3MmI
Author: Angelo Failla <pallotron@gmail.com>
Date:   Thu Oct 9 08:27:13 2025 +0100

    Better logic + esplicitely printing when DHCP is going to be disabled

commit 20d8ee1e7aac111c6329f90bfa876ffe26488769
Good "git" signature for pallotron@gmail.com with ED25519 key SHA256:bCGybCKH6mAgRuXgyjQSoTKIlRJOyIxRny1Gmg/3MmI
Author: Angelo Failla <pallotron@gmail.com>
Date:   Wed Oct 8 16:22:03 2025 +0100

    README.md: add some explanation

@AkihiroSuda
Copy link
Member

squash

Yes, please
https://lima-vm.io/docs/dev/git/#squashing-commits

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch from f7bdb95 to 534d141 Compare October 10, 2025 09:50
@pallotron
Copy link
Author

ok I fixed DCO, squashes all commits and made sure there is sign off.

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.

Looks like a breaking change

#140 (comment)

@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch 3 times, most recently from af97ba6 to 69b6d58 Compare October 11, 2025 07:44
…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 (pallotron) Failla <pallotron@gmail.com>
@pallotron pallotron force-pushed the feature/no_dhcp_issue_139 branch from 69b6d58 to 1d3ead9 Compare October 11, 2025 08:04
- [IP address is not assigned](#ip-address-is-not-assigned)
- [Links](#links)
- [Troubleshooting](#troubleshooting)
- [socket_vmnet: vmnet.framework support for rootless and VDE-less QEMU](#socket_vmnet-vmnetframework-support-for-rootless-and-vde-less-qemu)
Copy link
Member

Choose a reason for hiding this comment

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

?


> [!TIP]
> `sudo make install` is also available in addition to `sudo make install.bin`.
> [!TIP] > `sudo make install` is also available in addition to `sudo make install.bin`.
Copy link
Member

Choose a reason for hiding this comment

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

?

- Create a host network where all VMs have static IPs.
- Run a custom DHCP server on one VM to assign IPs to others on the same network.

To disable the MacOS DHCP you must use `--vmnet-mode=host` and provide a `--vmnet-network-idenfitier` UUID.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To disable the MacOS DHCP you must use `--vmnet-mode=host` and provide a `--vmnet-network-idenfitier` UUID.
To disable the macOS DHCP you must use `--vmnet-mode=host` and provide a `--vmnet-network-idenfitier` UUID.

"or \"\")\n"
" When vmnet mode is \"host\" and --vmnet-gateway is "
"not set, the internal DHCP will be disabled.\n"
" (default: \"random\")\n");
Copy link
Member

Choose a reason for hiding this comment

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

default should be an empty string

@pallotron pallotron closed this Oct 11, 2025
@pallotron pallotron deleted the feature/no_dhcp_issue_139 branch October 11, 2025 08:16
@pallotron pallotron restored the feature/no_dhcp_issue_139 branch October 11, 2025 08:17
@pallotron
Copy link
Author

made a mess with jj started a clean PR in #141

@AkihiroSuda AkihiroSuda removed this from the v1.2.2 milestone Oct 11, 2025
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.

Feature Request: Support for disabling DHCP on vmnet-host networks

2 participants