{"record":{"id":"788971632ba22650","repo":"lima-vm/lima","slug":"failed-to-apply-dns-configuration-w","errorCode":null,"errorMessage":"failed to apply DNS configuration: %w","messagePattern":"failed to apply DNS configuration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go","lineNumber":131,"sourceCode":"\t}\n\tif userData.Timezone != \"\" {\n\t\tif err = setTimezone(ctx, userData.Timezone); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to set timezone: %w\", err))\n\t\t}\n\t}\n\tfor _, u := range userData.Users {\n\t\tif err := createUser(ctx, &u); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to create user %#q: %w\", u.Name, err))\n\t\t}\n\t}\n\tfor _, entry := range userData.WriteFiles {\n\t\tif err := writeFiles(ctx, entry); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to write file for path %#q: %w\", entry.Path, err))\n\t\t}\n\t}\n\tif userData.ManageResolvConf && userData.ResolvConf != nil {\n\t\tif err = setResolvConf(ctx, userData.ResolvConf); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"failed to apply DNS configuration: %w\", err))\n\t\t}\n\t}\n\tif userData.CACerts != nil {\n\t\tlogrus.Warn(\"ca_certs is not implemented\")\n\t}\n\tif len(userData.BootCmd) > 0 {\n\t\tlogrus.Warn(\"bootcmd is not implemented\")\n\t}\n\treturn errors.Join(errs...)\n}\n\n// mountFSTabEntry mounts a filesystem based on the given fstab entry.\n// The format mimics Linux's convention.\n// The entries are not written to /etc/fstab.\nfunc mountFSTabEntry(m []string) error {\n\tif len(m) != 6 {\n\t\treturn fmt.Errorf(\"invalid fstab entry: expected 6 fields, got %d: %v\", len(m), m)\n\t}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go#L113-L149","documentation":"Raised by processUserData when `manage_resolv_conf: true` with a `resolv_conf` block is set, but the macOS `networksetup -setdnsservers Ethernet ...` command fails in setResolvConf. The command output is wrapped into the underlying error. Note the primary network interface is hardcoded to \"Ethernet\".","triggerScenarios":"The user-data sets manage_resolv_conf/resolv_conf and the networksetup command returns non-zero: the service named \"Ethernet\" does not exist on the guest, DNS server entries are malformed, or networksetup lacks privileges.","commonSituations":"A macOS guest whose primary network service is named differently (e.g. \"Wi-Fi\", \"USB 10/100/1000 LAN\"), which is common with custom or newer images; or invalid nameserver values in the resolv_conf block.","solutions":["Check the wrapped networksetup output in the error message.","Verify the network service list in the VM (`networksetup -listallnetworkservices`); the implementation hardcodes \"Ethernet\".","Remove `manage_resolv_conf` from user-data if DNS is already configured correctly by the image.","Use plain IP addresses for nameservers entries.","Rename or create an \"Ethernet\" network service in the guest as a workaround."],"exampleFix":"// before (user-data)\nmanage_resolv_conf: true\nresolv_conf:\n  nameservers: [\"dns.example.internal\"]\n// after\nmanage_resolv_conf: true\nresolv_conf:\n  nameservers: [\"10.0.2.3\"]","handlingStrategy":"fallback","validationCode":"func validateResolvConf(rc *cloudinittypes.ResolvConf) error {\n  if rc == nil { return nil }\n  for _, ns := range rc.Nameservers {\n    if net.ParseIP(ns) == nil { return fmt.Errorf(\"nameserver %q is not an IP\", ns) }\n  }\n  return nil\n}","typeGuard":"func isIPNameservers(rc *cloudinittypes.ResolvConf) bool {\n  if rc == nil { return true }\n  for _, ns := range rc.Nameservers { if net.ParseIP(ns) == nil { return false } }\n  return true\n}","tryCatchPattern":"if userData.ManageResolvConf && userData.ResolvConf != nil {\n  if err := setResolvConf(ctx, userData.ResolvConf); err != nil {\n    log.Warnf(\"DNS not applied; falling back to image defaults: %v\", err)\n  }\n}","preventionTips":["Use IP literals, not hostnames, for nameservers.","Confirm the guest has a network service named \"Ethernet\" (the implementation hardcodes it).","Skip manage_resolv_conf when the image already configures DNS.","Remember the primary network name is hardcoded - check `networksetup -listallnetworkservices` in the guest."],"tags":["macos","cloud-init","dns","networksetup"],"backgroundTag":"dns-configuration-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}