@@ -225,15 +225,67 @@ func (vm *VM) cloneAndConfigure(ctx context.Context) error {
225
225
}
226
226
}
227
227
228
- // Randomize the VM's MAC-address when using bridged networking
229
- // to avoid collisions when cloning from an OCI image on multiple hosts
228
+ // Randomize VM's MAC-address, this is important when using shared (NAT) networking
229
+ // with full /var/db/dhcpd_leases file (e.g. 256 entries) having an expired entry
230
+ // for a MAC address used by some OCI image, for example:
230
231
//
231
- // See https://github.com/cirruslabs/orchard/issues/181 for more details.
232
- if vm .Resource .NetBridged != "" {
233
- _ , _ , err = tart .Tart (ctx , vm .logger , "set" , "--random-mac" , vm .id ())
234
- if err != nil {
235
- return err
236
- }
232
+ // {
233
+ // name=adminsVlMachine
234
+ // ip_address=192.168.64.2
235
+ // hw_address=1,11:11:11:11:11:11
236
+ // identifier=1,11:11:11:11:11:11
237
+ // lease=0x1234
238
+ //}
239
+ //
240
+ // The next VM to start with a MAC address 22:22:22:22:22:22 will assume that
241
+ // 192.168.64.2 is free (because its lease expired a long time ago) and will
242
+ // add a new entry using its MAC address and 192.168.64.2 to the
243
+ // /var/db/dhcpd_leases and won't delete the old entry:
244
+ //
245
+ // {
246
+ // name=adminsVlMachine
247
+ // ip_address=192.168.64.2
248
+ // hw_address=1,11:11:11:11:11:11
249
+ // identifier=1,11:11:11:11:11:11
250
+ // lease=0x1234
251
+ // }
252
+ // {
253
+ // name=adminsVlMachine
254
+ // ip_address=192.168.64.2
255
+ // hw_address=1,22:22:22:22:22:22
256
+ // identifier=1,22:22:22:22:22:22
257
+ // lease=0x67ade532
258
+ // }
259
+ //
260
+ // Afterward, when an OCI VM with MAC address 11:11:11:11:11:11 is cloned and run,
261
+ // it will re-use the 192.168.64.2 entry instead of creating a new one, even through
262
+ // its lease had already expired. The resulting /var/db/dhcpd_leases will look like this:
263
+ //
264
+ // {
265
+ // name=adminsVlMachine
266
+ // ip_address=192.168.64.2
267
+ // hw_address=1,11:11:11:11:11:11
268
+ // identifier=1,11:11:11:11:11:11
269
+ // lease=0x67ade5c6
270
+ // }
271
+ // {
272
+ // name=adminsVlMachine
273
+ // ip_address=192.168.64.2
274
+ // hw_address=1,22:22:22:22:22:22
275
+ // identifier=1,22:22:22:22:22:22
276
+ // lease=0x67ade532
277
+ // }
278
+ //
279
+ // As a result, you will see two VMs with different MAC address using an identical
280
+ // IP address 192.168.64.2.
281
+ //
282
+ // Another scenarion when this is important is when using bridged networking
283
+ // to avoid collisions when cloning from an OCI image on multiple hosts[1].
284
+ //
285
+ // [1]: https://github.com/cirruslabs/orchard/issues/181
286
+ _ , _ , err = tart .Tart (ctx , vm .logger , "set" , "--random-mac" , vm .id ())
287
+ if err != nil {
288
+ return err
237
289
}
238
290
239
291
if vm .Resource .RandomSerial {
0 commit comments