Repository navigation
fix: resolve github.com reliably via explicit DNS upstreams - #34
Merged
Merged
Conversation
On Docker Desktop the embedded resolver (127.0.0.11) forwards through the host OS resolver, which on a lossy link caches dropped upstream queries as NXDOMAIN. github.com (60s TTL, re-queried constantly) then fails with "Could not resolve host" while long-TTL GitHub hosts keep working. Measured: 0/40 container lookups succeeded, while 8.8.8.8 queried directly never returned NXDOMAIN (0/160), only ~10-15% timeouts. - compose: set dns: [8.8.8.8, 8.8.4.4] on claude-code so the embedded resolver queries Google directly instead of the host resolver cache. - init-firewall.sh: explicit upstreams are dialed from inside the container netns, so strict mode's OUTPUT DROP turned every lookup into SERVFAIL. Allow udp+tcp/53 to the plain (non-host()) ExtServers Docker records in resolv.conf; DNS to any other destination stays dropped. Add a post-clamp DNS check so a resolver failure isn't misreported as missing GitHub ranges. - Document the invariant (.devcontainer/CLAUDE.md) and the symptom (README). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Inside
claude-code,github.comfailed to resolve (Could not resolve host) while every other GitHub host (api.,codeload.,objects.githubusercontent.com, …) worked. The firewall log showed the same thing at boot:could not resolve github.com.Root cause
On Docker Desktop, the embedded resolver forwards to
host(192.168.65.7), which goes through the macOS system resolver (mDNSResponder). On a lossy link, that layer caches dropped upstream queries as negative answers:dns-sd -G v4 github.comon the host flipped between real A records andNo Such Record. The bad answer comes from the resolver layer, not from the network.github.comhas a 60s TTL and is re-queried constantly, so it hits this far more than long-TTL hosts. A timeout gets retried; a cached NXDOMAIN fails immediately.Fix
compose.yaml:dns: [8.8.8.8, 8.8.4.4]onclaude-code, so the embedded resolver queries Google directly instead of the host resolver cache.127.0.0.11stays the container's nameserver.init-firewall.sh: explicit upstreams are dialed from inside the container netns (unlikehost(x)upstreams). Without an allow, strict mode'sOUTPUT DROPturned every lookup into SERVFAIL (reproduced). The script now allows udp+tcp/53 to the plain# ExtServers:entries Docker writes intoresolv.conf. DNS to any other destination stays dropped, and these are the same recursive resolvers127.0.0.11already forwards to, so there's no new tunnel surface. It also adds a post-clamp DNS check, so a resolver failure isn't misreported as "GitHub ranges may have failed to load"..devcontainer/CLAUDE.md; the symptom in README troubleshooting.Testing
--dns 8.8.8.8 --dns 8.8.4.4:getent github.com60/60 (was 0/10);git ls-remote https://github.com/...OK;example.comand direct DNS to1.1.1.1still blocked; re-run is idempotent.host()upstream): no extra rules added, behavior unchanged.make boot-checkOK, healthy,ExtServers: [8.8.8.8 8.8.4.4],getent github.com40/40, git over HTTPS and SSH to GitHub OK.make lintgates: shellcheck, hadolint, yamllint (viauvx),docker compose config— all pass. The one yamllint warning (mem_limitcomment) predates this change.Notes
git pushwhile opening this PR). This fixes the container only.🤖 Generated with Claude Code