Skip to content

Commit

Permalink
No default nameservers for internal resolver
Browse files Browse the repository at this point in the history
Don't fall-back to Google's DNS servers in a network that has an
internal resolver.

Now the default bridge uses the internal resolver, the only reason a
network started by the daemon should end up without any upstream
servers is if the host's resolv.conf doesn't list any.  In this case,
the '--dns' option can be used to explicitly configure nameservers
for a container if necessary.

(Note that buildkit's containers do not have an internal resolver, so
they will still set up Google's nameservers if the host has no
resolvers that can be used in the container's namespace.)

Signed-off-by: Rob Murray <[email protected]>
  • Loading branch information
robmry committed Jun 5, 2024
1 parent 18f4f77 commit d365702
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 34 deletions.
10 changes: 0 additions & 10 deletions libnetwork/internal/resolvconf/resolvconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,6 @@ func (rc *ResolvConf) TransformForIntNS(
}
rc.nameServers = newNSs

// If there are no external nameservers, and the only nameserver left is the
// internal resolver, use the defaults as ext nameservers.
if len(rc.md.ExtNameServers) == 0 && len(rc.nameServers) == 1 {
log.G(context.TODO()).Info("No non-localhost DNS nameservers are left in resolv.conf. Using default external servers")
for _, addr := range defaultNSAddrs(ipv6) {
rc.md.ExtNameServers = append(rc.md.ExtNameServers, ExtDNSEntry{Addr: addr})
}
rc.md.UsedDefaultNS = true
}

// For each option required by the nameserver, add it if not already present. If
// the option is already present, don't override it. Apart from ndots - if the
// ndots value is invalid and an ndots option is required, replace the existing
Expand Down
17 changes: 1 addition & 16 deletions libnetwork/internal/resolvconf/resolvconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,24 +432,9 @@ func TestRCTransformForIntNS(t *testing.T) {
},
},
{
name: "No host nameserver, no iv6",
input: "",
ipv6: false,
expExtServers: []ExtDNSEntry{
mke("8.8.8.8", false),
mke("8.8.4.4", false),
},
},
{
name: "No host nameserver, iv6",
name: "No host nameserver",
input: "",
ipv6: true,
expExtServers: []ExtDNSEntry{
mke("8.8.8.8", false),
mke("8.8.4.4", false),
mke("2001:4860:4860::8888", false),
mke("2001:4860:4860::8844", false),
},
},
{
name: "ndots present and required",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
nameserver 127.0.0.11

# Based on host file: '/etc/resolv.conf' (internal resolver)
# Used default nameservers.
# ExtServers: [8.8.8.8 8.8.4.4]
# Overrides: []

0 comments on commit d365702

Please sign in to comment.