Skip to content

[Bug]: using system dns occasionally causes all network egress to fail #1241

Closed

Description

@ptone

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Apologies for not having a solid repro

Current behavior

I'm setting the network route for containers to reach localhost servers with:
sudo container system dns create host.containers.internal --localhost 203.0.113.113

But occasionally, and randomly, this puts the network into a state where all DNS breaks and I can not egress from the containers. ('curl google.com' fails)

Sometimes this is transient and will start working again

More often than not I have to stop/start the services and then delete and recreate the DNS entry in the container system.

I'm realizing I need to try pinging an external IP address to check whether it is just DNS or actual packet egress

Note - a small difference which may be a docs issue

As I'm working with both podman and apple-container, I use "host.containers.internal" (note the plural) which is what podman sets up by default. The docs for this project use singular: "host.container.internal"

I caught this quickly - but could lead to confusion

Expected behavior

egress to work

Happy to get some suggested commands when this happens to provide more info

Environment

- OS: 
- Xcode: 
- Container:

Relevant log output

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added theissue type on Feb 21, 2026
  2. ptone commented on Feb 21, 2026

    @ptone
    Author

    I don't have all the unix network debugging tools in my container - can add some

    however curl to IP address does fail

    dig is there, and resolves DNS

    Don't have ping, netstat :/

  3. Ronitsabhaya75 commented on Feb 21, 2026

    @Ronitsabhaya75
    Contributor

    I think the issue is with the killall -HUP mDNSResponder call that happens after creating the DNS entry restarting mDNSResponder is racy and can occasionally leave it in a broken state where DNS fails more broadly than just the scoped domain.

    When it happens, scutil --dns would show whether the resolver got picked up correctly, and dig @127.0.0.1 -p 1053 google.com would confirm whether it's the embedded DNS server or mDNSResponder at fault.

    Also worth noting Podman uses host.containers.internal (plural) and this project's docs use host.container.internal (singular). Would be good to document which is officially supported to avoid confusion for folks switching between tools.

  4. JaewonHur commented on Feb 23, 2026

    @JaewonHur
    Contributor

    Is it triggered only when added --localhost on DNS creation?

    When the bug happens, could you share the result followings?

    ls /etc/resolver
    cat /etc/pf.conf
    cat /etc/pf.anchors/com.apple.container
    
  5. ptone commented on Jul 2, 2026

    @ptone
    Author

    Sadly this is still happening for me on 1.0

    /etc/pf.conf is managed by corp puppet (Google) - and may be the issue, I have an old email thread to meet with the team- but this is likely an issue only for googlers on corp gMac

  6. paulcdejean commented on Aug 1, 2026

    @paulcdejean

    Could this issue be related to this? #2051

  7. drewbroadley commented on Aug 16, 2026

    @drewbroadley

    I'm constantly fighting this issue, and here's some debugging and digging I've found (caveat, i've had AI support and do further research than I was able on the problem to understand it further)

    Deterministic repro, and the mechanism — this is not intermittent and it is not DNS.

    container system dns create <name> --localhost <ip> removes the
    com.apple.internet-sharing nat-anchor from the live pf ruleset. That is the anchor vmnet
    NATs containers through, so every container immediately loses outbound internet.

    Environment: container 1.2.2, macOS 26.3.1, Apple silicon, apiserver as a root LaunchDaemon.

    pfctl -sn, either side of one container system dns create host.usable --localhost 203.0.113.1:

    BEFORE (egress OK)                            AFTER (egress DEAD)
      nat-anchor "com.apple.container" all          nat-anchor "com.apple.container" all
      nat-anchor "com.apple/*" all                  nat-anchor "com.apple/*" all
      nat-anchor "com.apple.internet-sharing" all   ← removed
      rdr-anchor "com.apple.container" all          rdr-anchor "com.apple.container" all
      rdr-anchor "com.apple/*" all                  rdr-anchor "com.apple/*" all
      rdr-anchor "com.apple.internet-sharing" all   ← removed
    

    The anchor file itself is fine — /etc/pf.anchors/com.apple.container contains exactly
    rdr inet from any to 203.0.113.1 -> 127.0.0.1 # host.usable. The problem is the pf reload,
    not the rule.

    Repro (raw-IP probe so DNS is not a variable — curl -k https://1.1.1.1/ from a container):

    step state egress
    1 rebuild the container network, 0 containers OK (301)
    2 + 6 containers OK
    3 + 10 containers OK
    4 container system dns create host.usable --localhost 203.0.113.1 timeout

    Container count is irrelevant. The single command flips it, every time.

    Two corrections to the thread:

    1. It is not DNS. In the broken state getent hosts pypi.org resolves fine inside the
      container; only packets fail. A hostname-based probe conflates the two.
    2. container system dns delete does NOT repair it — the anchor reference is already gone
      from the kernel ruleset. The only recovery I found is rebuilding the container network:
      stop all containers, stop the apiserver, remove the persisted networks directory under the
      app root, start again. A host reboot also works. Neither container system stop/start nor
      restarting the apiserver is sufficient, which I suspect is why the "delete and recreate the
      DNS entry" workaround in this thread is unreliable.

    Since --localhost exists to install one rdr rule, it presumably shouldn't be rewriting and
    reloading the whole ruleset — appending to the anchor and reloading only that anchor would
    avoid clobbering anchors installed by other subsystems.

  8. added
    reliability
    on Aug 26, 2026
  9. self-assigned this
    on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

reliability

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions