@@ -12,7 +12,6 @@ Unlike `vde_vmnet`, `socket_vmnet` does not depend on VDE.
12
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
13
13
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
14
14
15
-
16
15
- [ Install] ( #install )
17
16
- [ From Homebrew] ( #from-homebrew )
18
17
- [ From MacPorts] ( #from-macports )
@@ -47,6 +46,7 @@ brew install socket_vmnet
47
46
```
48
47
49
48
The binaries will be installed onto the following paths:
49
+
50
50
- ` ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet `
51
51
- ` ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet_client `
52
52
@@ -55,13 +55,13 @@ The `${HOMEBREW_PREFIX}` path defaults to `/opt/homebrew` on ARM, `/usr/local` o
55
55
The ` ${HOMEBREW_PREFIX}/opt/socket_vmnet ` directory is usually symlinked to ` ../Cellar/socket_vmnet/${VERSION} ` .
56
56
57
57
Run the following command to start the daemon:
58
+
58
59
``` bash
59
60
mkdir -p ${HOMEBREW_PREFIX} /var/run
60
61
sudo ${HOMEBREW_PREFIX} /opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 ${HOMEBREW_PREFIX} /var/run/socket_vmnet
61
62
```
62
63
63
- > ** Warning**
64
- >
64
+ > [ !WARNING]
65
65
> Typically, the ` socket_vmnet ` binary in the ` ${HOMEBREW_PREFIX} ` can be replaced by any user in the ` admin ` group.
66
66
67
67
<details >
@@ -70,8 +70,8 @@ sudo ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.16
70
70
71
71
<p >
72
72
73
-
74
73
To install the launchd service:
74
+
75
75
``` bash
76
76
brew tap homebrew/services
77
77
# sudo is necessary for the next line
@@ -82,14 +82,15 @@ The launchd unit file will be installed as `/Library/LaunchDaemons/homebrew.mxcl
82
82
83
83
Default configuration:
84
84
85
- Config | Value
86
- --------| --------------------------------------------------
87
- Socket | ` ${HOMEBREW_PREFIX}/var/run/socket_vmnet `
88
- Stdout | ` ${HOMEBREW_PREFIX}/var/log/socket_vmnet/stdout `
89
- Stderr | ` ${HOMEBREW_PREFIX}/var/log/socket_vmnet/stderr `
90
- Gateway | 192.168.105.1
85
+ | Config | Value |
86
+ | ------- | ------------------------------------------------ |
87
+ | Socket | ` ${HOMEBREW_PREFIX}/var/run/socket_vmnet ` |
88
+ | Stdout | ` ${HOMEBREW_PREFIX}/var/log/socket_vmnet/stdout ` |
89
+ | Stderr | ` ${HOMEBREW_PREFIX}/var/log/socket_vmnet/stderr ` |
90
+ | Gateway | 192.168.105.1 |
91
91
92
92
To uninstall the launchd service:
93
+
93
94
``` bash
94
95
sudo ${HOMEBREW_PREFIX} /bin/brew services stop socket_vmnet
95
96
```
@@ -105,10 +106,12 @@ sudo port install socket_vmnet
105
106
```
106
107
107
108
The binaries will be installed onto the following paths:
109
+
108
110
- ` /opt/local/bin/socket_vmnet `
109
111
- ` /opt/local/bin/socket_vmnet_client `
110
112
111
113
Run the following command to start the daemon manually:
114
+
112
115
``` bash
113
116
sudo /opt/local/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_vmnet
114
117
```
@@ -120,6 +123,7 @@ sudo /opt/local/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_
120
123
<p >
121
124
122
125
To install the launchd service:
126
+
123
127
``` bash
124
128
sudo port load socket_vmnet
125
129
```
@@ -129,13 +133,14 @@ The launchd unit file will be installed as
129
133
130
134
Default configuration:
131
135
132
- Config | Value
133
- --------| ------------------------------------------------
134
- Socket | ` /var/run/socket_vmnet `
135
- Stdout | ` /var/log/socket_vmnet.log `
136
- Gateway | 192.168.105.1
136
+ | Config | Value |
137
+ | ------- | --------------------------- |
138
+ | Socket | ` /var/run/socket_vmnet ` |
139
+ | Stdout | ` /var/log/socket_vmnet.log ` |
140
+ | Gateway | 192.168.105.1 |
137
141
138
142
To uninstall the launchd service:
143
+
139
144
``` bash
140
145
sudo port unload socket_vmnet
141
146
```
@@ -151,19 +156,21 @@ sudo port unload socket_vmnet
151
156
<p >
152
157
153
158
``` bash
154
- sudo make PREFIX=/opt/socket_vmnet install.bin
159
+ sudo make install.bin
155
160
```
156
161
157
- The ` PREFIX ` dir below does not necessarily need to be ` /opt/socket_vmnet ` , however, it is highly recommended
158
- to set the prefix to a directory that can be only written by the root.
162
+ This installs binaries using ` PREFIX=/opt/socket_vmnet ` :
159
163
160
- Note that ` /usr/local/bin ` is sometimes chowned for a non-admin user, so ` /usr/local ` is * not* an appropriate prefix.
161
-
162
- The binaries will be installed onto the following paths:
163
164
- ` /opt/socket_vmnet/bin/socket_vmnet `
164
165
- ` /opt/socket_vmnet/bin/socket_vmnet_client `
165
166
167
+ You can customize the install location using the ` PREFIX ` environment variable,
168
+ however, it is highly recommended to set the prefix to a directory that can be
169
+ only written by the root. Note that ` /usr/local/bin ` is sometimes chowned for a
170
+ non-admin user, so ` /usr/local ` is _ not_ an appropriate prefix.
171
+
166
172
Run the following command to start the daemon:
173
+
167
174
``` bash
168
175
sudo /opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_vmnet
169
176
```
@@ -174,27 +181,27 @@ sudo /opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/s
174
181
175
182
<p >
176
183
177
-
178
184
To install the launchd service:
185
+
179
186
``` bash
180
- sudo make PREFIX=/opt/socket_vmnet install.launchd
187
+ sudo make install.launchd
181
188
```
182
189
183
190
The launchd unit file will be installed as ` /Library/LaunchDaemons/io.github.lima-vm.socket_vmnet.plist ` .
184
191
185
192
Default configuration:
186
193
187
- Config | Value
188
- --------|--------------------------------------------------
189
- Socket | ` /var/run/socket_vmnet `
190
- Stdout | ` /var/log/socket_vmnet/stdout `
191
- Stderr | ` /var/log/socket_vmnet/stderr `
192
- Gateway | 192.168.105.1
193
-
194
+ | Config | Value |
195
+ | ------- | ------------------------------ |
196
+ | Socket | ` /var/run/socket_vmnet ` |
197
+ | Stdout | ` /var/log/socket_vmnet/stdout ` |
198
+ | Stderr | ` /var/log/socket_vmnet/stderr ` |
199
+ | Gateway | 192.168.105.1 |
194
200
195
201
To uninstall the launchd service:
202
+
196
203
``` bash
197
- sudo make PREFIX=/opt/socket_vmnet uninstall.launchd
204
+ sudo make uninstall.launchd
198
205
```
199
206
200
207
</p >
@@ -208,6 +215,7 @@ sudo make PREFIX=/opt/socket_vmnet uninstall.launchd
208
215
## Usage
209
216
210
217
### QEMU
218
+
211
219
Make sure that the ` socket_vmnet ` daemon is running, and execute QEMU via ` socket_vmnet_client ` as follows:
212
220
213
221
``` console
@@ -236,7 +244,9 @@ $ limactl start --name=default template://vmnet
236
244
See also https://github.com/lima-vm/lima/blob/master/docs/network.md
237
245
238
246
## Advanced usage
247
+
239
248
### Multi VM
249
+
240
250
Multiple VMs can be connected to a single ` socket_vmnet ` instance.
241
251
242
252
Make sure to specify unique MAC addresses to VMs: ` -device virtio-net-pci,netdev=net0,mac=de:ad:be:ef:00:01 ` .
@@ -249,6 +259,7 @@ You do not need to configure (and you can't, currently) the MAC address of `sock
249
259
See [ ` ./launchd/io.github.lima-vm.socket_vmnet.bridged.en0.plist ` ] ( ./launchd/io.github.lima-vm.socket_vmnet.bridged.en0.plist ) .
250
260
251
261
Install:
262
+
252
263
``` bash
253
264
BRIDGED=en0
254
265
sed -e " s@/opt@${HOMEBREW_PREFIX} /opt@g; s@/var@${HOMEBREW_PREFIX} /var@g; s@en0@${BRIDGED} @g" ./launchd/io.github.lima-vm.socket_vmnet.bridged.en0.plist \
@@ -261,6 +272,7 @@ sudo launchctl kickstart -kp system/io.github.lima-vm.socket_vmnet.bridged.${BRI
261
272
Use ` ${HOMEBREW_PREFIX}/var/run/socket_vmnet.bridged.en0 ` as the socket.
262
273
263
274
Uninstall:
275
+
264
276
``` bash
265
277
BRIDGED=en0
266
278
sudo launchctl bootout system /Library/LaunchDaemons/io.github.lima-vm.socket_vmnet.bridged.${BRIDGED} .plist
@@ -294,13 +306,15 @@ See [`./etc_sudoers.d/socket_vmnet`](./etc_sudoers.d/socket_vmnet) to allow runn
294
306
Unlike ` vde_vmnet ` , ` socket_vmnet ` does not depend on VDE.
295
307
296
308
### How is socket_vmnet related to QEMU-builtin vmnet support?
309
+
297
310
QEMU 7.1 added [ the built-in support for vmnet] ( https://github.com/qemu/qemu/blob/v7.1.0/qapi/net.json#L626-L631 ) .
298
311
299
312
However, QEMU-builtin vmnet requires running the entire QEMU process as root.
300
313
301
314
On the other hand, ` socket_vmnet ` does not require the entire QEMU process to run as root, though ` socket_vmnet ` has to run as root.
302
315
303
316
### How to use static IP addresses?
317
+
304
318
When ` --vmnet-gateway=IP ` is set to "192.168.105.1", the whole subnet (192.168.105.2-192.168.105.254) is used as the DHCP range.
305
319
306
320
To use static IP addresses, limit the DHCP range with ` --vmnet-dhcp-end=IP ` .
@@ -309,11 +323,13 @@ For example, `--vmnet-gateway=192.168.105.1 --vmnet-dhcp-end=192.168.105.100` al
309
323
as non-DHCP static addresses.
310
324
311
325
### How to reserve DHCP addresses?
326
+
312
327
- Decide a unique MAC address for the VM, e.g. ` de:ad:be:ef:00:01 ` .
313
328
314
329
- Decide a reserved IP address, e.g., "192.168.105.100"
315
330
316
331
- Create ` /etc/bootptab ` like this. Make sure not to drop the "%%" header.
332
+
317
333
```
318
334
# bootptab
319
335
%%
@@ -322,6 +338,7 @@ tmp-vm01 1 de:ad:be:ef:00:01 192.168.105.100
322
338
```
323
339
324
340
- Reload the DHCP daemon.
341
+
325
342
```
326
343
sudo /bin/launchctl kickstart -kp system/com.apple.bootpd
327
344
```
@@ -332,18 +349,23 @@ NOTE: don't confuse MAC addresses of VMs with the MAC address of `socket_vmnet`
332
349
You do not need to configure (and you can't, currently) the MAC address of ` socket_vmnet ` itself.
333
350
334
351
### IP address is not assigned
352
+
335
353
Try the following commands:
354
+
336
355
``` console
356
+ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove /usr/libexec/bootpd
337
357
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/libexec/bootpd
338
358
/usr/libexec/ApplicationFirewall/socketfilterfw --unblock /usr/libexec/bootpd
339
359
```
340
360
341
361
## Links
362
+
342
363
- https://developer.apple.com/documentation/vmnet
343
364
- https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_vm_networking
344
365
- [ ` file:///Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/vmnet.framework/Versions/Current/Headers/vmnet.h ` ] ( file:///Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/vmnet.framework/Versions/Current/Headers/vmnet.h )
345
366
346
367
## Troubleshooting
347
- - Set environment variable ` DEBUG=1 `
348
- - See ` ${HOMEBREW_PREFIX}/var/log/socket_vmnet/{stdout,stderr} ` (when using launchd).
349
- The path was previously ` ${HOMEBREW_PREFIX}/var/run/socket_vmnet.{stdout,stderr} ` until March 2023.
368
+
369
+ - To enable verbose debug logs, set the environment variable ` DEBUG=1 ` .
370
+ - When using launchd, logs are written to ` /var/log/socket_vmnet/stderr ` .
371
+ ` /var/log/socket_vmnet/stdout ` is not used and expected to be empty.
0 commit comments