macOS: container DNS fails under a full-tunnel VPN when the /etc/resolv.conf servers don't answer (relay never tries the Mac's other resolvers)

Open
#1,137 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
macos, rust

Research direction

Start with daemon/dns.rs, especially mac_resolvers and relay_query, then review how #1097 selects resolvers and how #1067 handles supplemental domains. Reproduce with the full-tunnel VPN and an unresponsive /etc/resolv.conf resolver; the issue is done when relay lookups can use the Mac's working resolver and container and build DNS queries succeed.

Written by the indexing model from the issue text.

Description

bug
Kiri version and system

0.3.0 on macOS 27.2.1 (Apple silicon), shared NAT on (default)

What you did

Two VPNs are connected at the same time:

  • OpenVPN Connect, full tunnel (the default route is split into 0/1 + 128.0/1 via a utun interface).
  • Tailscale (macOS standalone build) with MagicDNS on. While the full-tunnel VPN is up, the Tailscale node goes offline and 100.100.100.100 stops answering.

macOS DNS state while both are connected:

$ grep nameserver /etc/resolv.conf
nameserver 100.100.100.100
nameserver fd7a:115c:a1e0::53

$ scutil --dns   (trimmed)
resolver #1
  nameserver[0] : 100.100.100.100
  nameserver[1] : fd7a:115c:a1e0::53
  if_index : (utun, Tailscale)
  flags    : Supplemental, Request A records, Request AAAA records
resolver #2
  nameserver[0] : 8.8.8.8          # pushed by the full-tunnel VPN
  nameserver[1] : 8.8.4.4
  flags    : Request A records

$ dig +time=2 +tries=1 @100.100.100.100 registry-1.docker.io   # times out
$ dig +time=2 +tries=1 @8.8.8.8 registry-1.docker.io           # answers
$ dscacheutil -q host -a name registry-1.docker.io             # answers (macOS falls back)

Then:

docker run --rm alpine nslookup -type=a registry-1.docker.io

printf 'FROM alpine:3\nRUN echo ok\n' > Dockerfile
docker build .
What happened
$ docker run --rm alpine nslookup -type=a registry-1.docker.io
;; connection timed out; no servers could be reached

$ docker build .
#3 [internal] load metadata for docker.io/library/alpine:3
ERROR: failed to solve: alpine:3: failed to resolve source metadata for docker.io/library/alpine:3: docker.io/library/alpine:3: not found

buildkitd log:
fetch failed error="... dial tcp: lookup registry-1.docker.io on 172.17.0.1:53: server misbehaving"

kiri diag logs:
WARN daemon the VM's DNS at its gateway did not answer; container lookups go through the Mac
WARN daemon the VM's NAT network is unreachable, so published ports go over vsock (they still work); a VPN, or Kiri not allowed under Local Network in Privacy & Security, usually causes this

Also from a container: direct UDP DNS times out (nslookup google.com 8.8.8.8), while TCP egress works (wget http://1.1.1.1 gets a 301). docker pull works, since the daemon pulls on the Mac.
What you expected instead

Container and build lookups succeed whenever the Mac itself can resolve the name. On the same Mac with the same two VPNs connected, OrbStack resolved names in containers and builds fine before I switched to Kiri.

Disconnecting the full-tunnel VPN fixes it in Kiri: the gateway DNS works again, Tailscale comes back online, and 100.100.100.100 answers.

Anything else

Happens every time while both VPNs are connected. Workaround: disconnect the full-tunnel VPN before building.

The lookup fails in two places:

  1. The VM gateway resolver (192.168.64.1) doesn't answer while the full-tunnel VPN is up, so the agent falls back to the vsock relay.
  2. The relay (daemon/dns.rs, mac_resolvers → relay_query) asks only the /etc/resolv.conf servers. Here both are Tailscale's, and neither answers. The Mac's working resolver, 8.8.8.8 in scutil --dns, is never tried, so the relay returns SERVFAIL.

This is still the case on main after #1097: select_mac_resolvers falls back to scutil --dns's primary resolvers only when /etc/resolv.conf has no nameservers, not when they don't answer.

Possible fixes:

  • When every /etc/resolv.conf server fails, the relay could try the other non-scoped resolvers from scutil --dns (here 8.8.8.8) before returning SERVFAIL.
  • Or, as a last resort, it could answer A/AAAA through the macOS system resolver (getaddrinfo / DNSServiceGetAddrInfo), as it already does for supplemental domains without a nameserver (#1067). The system resolver handles this fallback itself.

kiri vm set --shared-nat off probably doesn't help, since DNS goes through the same relay and the same resolv.conf servers.

Related: #1071 (TCP egress under a full-tunnel VPN, fixed in 0.3.0) and #1067 (split-DNS via scutil --dns).

Dominant language
Rust
Stars
7.5k
Forks
329
Avg merge
8h 54m
Merged PRs (30d)
426

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libracoder/kiri

All issues in libracoder/kiri

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.