[GH-ISSUE #2253] DNS issue inside a docker container #4497

Open
opened 2026-08-05 00:58:01 -04:00 by saavagebueno · 7 comments
Owner

Originally created by @wgfilho on GitHub (Jul 10, 2024).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/2253

Originally assigned to: @nazarewk on GitHub.

Hi,

Consider the following case:

  • Computer 1 (C1) running Debian with Netbird installed directly bare metal. This computer runs docker with a container D1.

  • Computer 2 (C2) running Debian with Netbird installed directly bare metal.

  • From C1 I can ping c2.netbird.cloud and the c2's Netbird ip without problems, everything works as expected.

  • From D1 I can ping the IP of C2 (the Netbird ip); I can nslookup c2.netbird.cloud, it resolves correctly; but I can't ping c2.netbird.cloud. This returns "bad address". If I try to access c2.netbird.cloud in any way other than nslookup, it fails.

What am I doing wrong? Is there any way to make it work? Do you need any more information to be able to better understand the issue?

Thanks!

Originally created by @wgfilho on GitHub (Jul 10, 2024). Original GitHub issue: https://github.com/netbirdio/netbird/issues/2253 Originally assigned to: @nazarewk on GitHub. Hi, Consider the following case: - Computer 1 (C1) running Debian with Netbird installed directly bare metal. This computer runs docker with a container D1. - Computer 2 (C2) running Debian with Netbird installed directly bare metal. - From C1 I can ping c2.netbird.cloud and the c2's Netbird ip without problems, everything works as expected. - From D1 I can ping the IP of C2 (the Netbird ip); I can nslookup c2.netbird.cloud, it resolves correctly; but I can't ping c2.netbird.cloud. This returns "bad address". If I try to access c2.netbird.cloud in any way other than nslookup, it fails. What am I doing wrong? Is there any way to make it work? Do you need any more information to be able to better understand the issue? Thanks!
saavagebueno added the triage-needed label 2026-08-05 00:58:01 -04:00
Author
Owner

@codingCoffee commented on GitHub (Apr 4, 2025):

Hey! I'm facing the same issue. Did you figure out a fix for this by any chance?

<!-- gh-comment-id:2778632493 --> @codingCoffee commented on GitHub (Apr 4, 2025): Hey! I'm facing the same issue. Did you figure out a fix for this by any chance?
Author
Owner

@nazarewk commented on GitHub (Apr 7, 2025):

I know for a fact that Podman's iptables/nftables integration can interfere with Netbird client rules. It might be a similar case for Docker.

I can try to reproduce and see what's going on, but I can't give you any estimate on when that would happen.

If you have the technical capabilities to figure out below, it would help tremendously to:

  • figure out what kind of routing table and firewall rules:
    • the container has
    • the host has (in context of Docker/Netbird interactions)
  • run tcpdump to see where the packet gets dropped
  • try to figure out which firewall rules are responsible for the packets not arriving to the host
<!-- gh-comment-id:2782808278 --> @nazarewk commented on GitHub (Apr 7, 2025): I know for a fact that Podman's `iptables`/`nftables` integration can interfere with Netbird client rules. It might be a similar case for Docker. I can try to reproduce and see what's going on, but I can't give you any estimate on when that would happen. If you have the technical capabilities to figure out below, it would help tremendously to: - figure out what kind of routing table and firewall rules: - the container has - the host has (in context of Docker/Netbird interactions) - run `tcpdump` to see where the packet gets dropped - try to figure out which firewall rules are responsible for the packets not arriving to the host
Author
Owner

@hakansa commented on GitHub (Apr 7, 2025):

can you try ping -4 <domain> ?
if it works docker run --sysctl net.ipv6.conf.all.disable_ipv6=1 ...might be a workaround.

<!-- gh-comment-id:2782835703 --> @hakansa commented on GitHub (Apr 7, 2025): can you try `ping -4 <domain>` ? if it works `docker run --sysctl net.ipv6.conf.all.disable_ipv6=1 ...`might be a workaround.
Author
Owner

@folivaud-raliance commented on GitHub (Sep 9, 2025):

Hello, i have the same issue.
@hakansa the ping -4 <domain> works on my side, but your workaround does not

<!-- gh-comment-id:3269788104 --> @folivaud-raliance commented on GitHub (Sep 9, 2025): Hello, i have the same issue. @hakansa the `ping -4 <domain>` works on my side, but your workaround does not
Author
Owner

@nmapx commented on GitHub (Sep 23, 2025):

@folivaud-raliance @hakansa
This is actually not a Netbird issue but how Docker and systemd-resolved interact.
If you want more details please dig into it - there are some docs describing dns inheritance in Docker.
As a quick fix I can recommend you:

  • edit /etc/systemd/resolved.conf and add DNSStubListenerExtra=172.17.0.1 - make sure to use your docker0 ip addr
  • restart systemd-resolved service systemd-resolved restart
  • add { "dns": ["172.17.0.1"] } to your /etc/docker/daemon.json
  • restart docker service service docker restart

Simple as that, containers will now use your host dns resolver.

<!-- gh-comment-id:3325369565 --> @nmapx commented on GitHub (Sep 23, 2025): @folivaud-raliance @hakansa This is actually not a Netbird issue but how Docker and systemd-resolved interact. If you want more details please dig into it - there are some docs describing dns inheritance in Docker. As a quick fix I can recommend you: - edit `/etc/systemd/resolved.conf` and add `DNSStubListenerExtra=172.17.0.1` - make sure to use your docker0 ip addr - restart systemd-resolved `service systemd-resolved restart` - add `{ "dns": ["172.17.0.1"] }` to your `/etc/docker/daemon.json` - restart docker service `service docker restart` Simple as that, containers will now use your host dns resolver.
Author
Owner

@jfrconley commented on GitHub (Jan 22, 2026):

@folivaud-raliance @hakansa This is actually not a Netbird issue but how Docker and systemd-resolved interact. If you want more details please dig into it - there are some docs describing dns inheritance in Docker. As a quick fix I can recommend you:

* edit `/etc/systemd/resolved.conf` and add `DNSStubListenerExtra=172.17.0.1` - make sure to use your docker0 ip addr

* restart systemd-resolved `service systemd-resolved restart`

* add `{ "dns": ["172.17.0.1"] }` to your `/etc/docker/daemon.json`

* restart docker service `service docker restart`

Simple as that, containers will now use your host dns resolver.

This solution does not seem to work, perhaps due to changes in local resolver config with more recent netbird versions. I am not able to access DNS at all from any docker container on linux systems with systemd-resolve. I have verified that the host ip is reachable in the container and that cloudflare dns does work (1.1.1.1). I have also tried the ports 53, 5353, and 22053 to no avail.

The only current fixes I can get working are:

  1. disabling netbird from the host (not great)
  2. host networking (even worse)
  3. explicitly specifying a dns server when starting the container
<!-- gh-comment-id:3786943579 --> @jfrconley commented on GitHub (Jan 22, 2026): > [@folivaud-raliance](https://github.com/folivaud-raliance) [@hakansa](https://github.com/hakansa) This is actually not a Netbird issue but how Docker and systemd-resolved interact. If you want more details please dig into it - there are some docs describing dns inheritance in Docker. As a quick fix I can recommend you: > > * edit `/etc/systemd/resolved.conf` and add `DNSStubListenerExtra=172.17.0.1` - make sure to use your docker0 ip addr > > * restart systemd-resolved `service systemd-resolved restart` > > * add `{ "dns": ["172.17.0.1"] }` to your `/etc/docker/daemon.json` > > * restart docker service `service docker restart` > > > Simple as that, containers will now use your host dns resolver. This solution does not seem to work, perhaps due to changes in local resolver config with more recent netbird versions. I am not able to access DNS at all from any docker container on linux systems with systemd-resolve. I have verified that the host ip is reachable in the container and that cloudflare dns does work (1.1.1.1). I have also tried the ports 53, 5353, and 22053 to no avail. The only current fixes I can get working are: 1. disabling netbird from the host (not great) 2. host networking (even worse) 3. explicitly specifying a dns server when starting the container
Author
Owner

@jfrconley commented on GitHub (Mar 12, 2026):

I was able to fix this by adding a rule to ufw that allows traffic from the docker bridge on port 53

sudo ufw allow in on docker0 to 172.17.0.1 port 53

<!-- gh-comment-id:4049556133 --> @jfrconley commented on GitHub (Mar 12, 2026): I was able to fix this by adding a rule to ufw that allows traffic from the docker bridge on port 53 ` sudo ufw allow in on docker0 to 172.17.0.1 port 53`
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#4497