Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Support the /etc/resolver DNS resolution configuration hierarchy on OS X when cgo is disabled #12524

Closed
Rotonen opened this issue Sep 6, 2015 · 86 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin
Milestone

Comments

@Rotonen
Copy link

Rotonen commented Sep 6, 2015

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/resolver.5.html

OS X allows you to add TLD specific resolver configurations. Quite popular ones are /etc/resolver/vm for local virtual machines and /etc/resolver/dev for local development purposes.

https://golang.org/src/net/dnsclient_unix.go#L231

Go seems to be hardcoded to only take /etc/resolv.conf into account on Unix platforms.

@nodirt
Copy link
Contributor

nodirt commented Sep 6, 2015

I don't think Go-native DNS resolving mechanism is used on Mac.
https://golang.org/src/net/dnsclient_unix.go#L231 is not executed if I run

addrs, err := net.LookupHost("google.com")

on my Mac.

If I enable debugging (GODEBUG=netdns=2 go run test.go), the following is printed:

go package net: using cgo DNS resolver
go package net: hostLookupOrder(google.com) = cgo

which means that OS-native DNS resolving is used.

Can you supply an exact configuration file, Go code, actual and expected output?

@titanous
Copy link
Member

titanous commented Sep 6, 2015

@nodirt This is for a binary with cgo off.

@davecheney
Copy link
Contributor

If cgo is disabled then the pure go DNS resolver will be used. If you want
to use the Mac DNS resolver, plese build with cgo.

On Mon, 7 Sep 2015 07:47 Jonathan Rudenberg notifications@github.com
wrote:

@nodirt https://github.com/nodirt This is for a binary with cgo off.


Reply to this email directly or view it on GitHub
#12524 (comment).

@nodirt
Copy link
Contributor

nodirt commented Sep 6, 2015

Shouldn't be a problem since this is needed only on a dev machine.

On Sun, Sep 6, 2015 at 4:06 PM Dave Cheney notifications@github.com wrote:

If cgo is disabled then the pure go DNS resolver will be used. If you want
to use the Mac DNS resolver, plese build with cgo.

On Mon, 7 Sep 2015 07:47 Jonathan Rudenberg notifications@github.com
wrote:

@nodirt https://github.com/nodirt This is for a binary with cgo off.


Reply to this email directly or view it on GitHub
#12524 (comment).


Reply to this email directly or view it on GitHub
#12524 (comment).

@titanous
Copy link
Member

titanous commented Sep 6, 2015

In this specific case, @Rotonen was using the Flynn binary that we distribute as a compiled artifact, it is compiled without cgo to ease cross-compilation. Just because the user is a developer doesn't mean that they are a Go developer or want to compile the binary for themselves. The only question here is if this feature is out of scope for the pure-Go resolver.

@minux
Copy link
Member

minux commented Sep 7, 2015 via email

@ianlancetaylor ianlancetaylor changed the title Support the /etc/resolver DNS resolution configuration hierarchy on OS X net: Support the /etc/resolver DNS resolution configuration hierarchy on OS X Sep 8, 2015
@ianlancetaylor
Copy link
Contributor

I don't see anything wrong with supporting the OS X /etc/resolver directory. That said, my understanding is that the Go DNS resolver does not work well on most OS X machines. That is why it is disabled by default.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 8, 2015
@mterron
Copy link

mterron commented Jun 1, 2016

This would be great in all platforms anyway. Is there any disadvantage from supporting this behaviour? It seems that it'd neatly resolve the need to install and configure dnsmasq to provide the simple function of having different resolvers for different TLDs.

@jason-riddle

This comment was marked as spam.

@ghost

This comment was marked as spam.

@bradfitz
Copy link
Contributor

Any updates would be posted here. No updates have been posted here.

@bradfitz bradfitz added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 23, 2017
@bitglue
Copy link

bitglue commented Apr 20, 2018

See resolver(5). Just reading the files out of /etc/resolver/* will miss out on other mechanisms for configuring the same thing, for example configuration profiles or IKE attributes.

@flyinprogrammer
Copy link

Just stumbled upon this today while attempting to use coredns as a dns proxy for local development. It's a real bummer to discover how naive our support for os x is.

@bradfitz
Copy link
Contributor

We've generally assumed people use cgo on Darwin, so this bug has never been a priority.

I do admit that practically means that Darwin binaries need to be built on Darwin, which is difficult for people wanting to cross-compile for a dozen platforms as part of their release process.

Perhaps on Darwin without cgo we could just shell out to a program to do DNS resolution (e.g. host, dig, nslookup?). At least nslookup has an interactive mode that would permit re-using a child process for multiple lookups, if that proves necessary for performance.

@ianlancetaylor
Copy link
Contributor

Probably best to discuss further on a patch submission. Thanks.

@gopherbot
Copy link

Change https://go.dev/cl/448020 mentions this issue: net: adjust build tags for darwin libc calls

gopherbot pushed a commit that referenced this issue Nov 7, 2022
Support for direct libc calls was added in CL 446178 but the build
tags weren't quite activating it when cgo was not enabled. Adjust them
and add a new supporting file for darwin.

This should use the new direct libc calls with both CGO_ENABLED=0 and
CGO_ENABLED=1 when building for darwin.

Updates #12524

Change-Id: Ieee4b298dee13f389ed3a63c0a4a3a18c9180163
Reviewed-on: https://go-review.googlesource.com/c/go/+/448020
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dan Peterson <danp@danp.net>
Auto-Submit: Ian Lance Taylor <iant@google.com>
@AaronFriel
Copy link

@bradfitz I may reach out, thank you! I'm not sure if we're ready to take on maintaining a fork, but you've piqued my interest.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 14, 2022
@dmitshur dmitshur modified the milestones: Backlog, Go1.20 Nov 14, 2022
ashley-cui added a commit to ashley-cui/podman that referenced this issue Nov 30, 2022
Fix a regression caused by not setting CGO correctly in the makefile while building podman-remote on OSX. See golang/go#12524 for details.

Signed-off-by: Ashley Cui <acui@redhat.com>
ashley-cui added a commit to ashley-cui/podman that referenced this issue Nov 30, 2022
Fix a regression caused by not setting CGO correctly in the makefile while building podman-remote on OSX. See golang/go#12524 for details.

Signed-off-by: Ashley Cui <acui@redhat.com>
ashley-cui added a commit to ashley-cui/podman that referenced this issue Nov 30, 2022
Fix a regression caused by not setting CGO correctly in the makefile while building podman-remote on OSX. See golang/go#12524 for details.

Signed-off-by: Ashley Cui <acui@redhat.com>
ashley-cui added a commit to ashley-cui/podman that referenced this issue Nov 30, 2022
Fix a regression caused by not setting CGO correctly in the makefile while building podman-remote on OSX. See golang/go#12524 for details.

Signed-off-by: Ashley Cui <acui@redhat.com>
ashley-cui added a commit to ashley-cui/podman that referenced this issue Nov 30, 2022
Fix a regression caused by not setting CGO correctly in the makefile while building podman-remote on OSX. See golang/go#12524 for details.

Signed-off-by: Ashley Cui <acui@redhat.com>
@golang golang locked and limited conversation to collaborators Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin
Projects
None yet
Development

Successfully merging a pull request may close this issue.