Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pihole reports "DNS resolution is currently unavailable" when host's DNS references Pihole. #342

Closed
3 tasks done
dschaper opened this issue Oct 14, 2018 · 21 comments
Closed
3 tasks done

Comments

@dschaper
Copy link
Member

@jwalton commented on Sun Oct 14 2018

In raising this issue, I confirm the following: {please fill the checkboxes, e.g: [X]}

How familiar are you with the the source code relevant to this issue?:

1


Expected behaviour:

Pihole starts correctly.

Actual behaviour:

Pihole logs:

DNS resolution is currently unavailable.

And then dies.

Steps to reproduce:

It seems that, when starting pihole via docker, if the docker host machine has the pihole listed as a nameserver in resolv.conf, then pihole will fail to start with DNS resolution is currently unavailable., even if other nameservers are listed and the docker host is able to resolve domain names.

Debug token provided by:

I tried pihole -d -a via docker, but I didn't see a debug token anywhere in the output. This is everything from docker logs pihole: https://gist.github.com/jwalton/508fd6041945ba4e4947072c147d0d79

Troubleshooting undertaken, and/or other relevant information:

I have a stock Asus RT-AC68U router at 192.168.0.1 ("the router"). I have a docker host running at 192.168.0.4, which is where pihole runs.

The router runs the DHCP server for the house, and it also is my gateway to the cable modem. The router advertises itself as the DNS lookup (192.168.0.1). In the router config, I can optionally provide another DNS server (the pihole server), in which case the router will advertise the pihole (192.168.0.4) as the primary DNS and itself (192.168.0.1) as the secondary DNS. This works well, as if the pihole dies, I still can resolve things through the router's DNS.

On the docker host, resolv.conf looks like:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.0.4
nameserver 192.168.0.1
search local

If I try to start (or restart) pihole with the resolv.conf looking like this, pihole will start with DNS resolution is currently unavailable, and then kill itself. Note that I am able to resolve hostnames on the docker host (e.g. host github.com returns sensible results). If I remove the nameserver 192.168.0.4 line, the pihole starts correctly (although then the DHCP client on 192.168.0.4 will eventually overwrite resolv.conf, and then if pihole crashes or tries to restart, it will fail).


@jwalton commented on Sun Oct 14 2018

I should also point out my pi-hole configuration for DNS servers includes neither 192.168.0.1 nor 192.168.0.4, so I'm not sure why /etc/resolv.conf even comes into play here.

@josco95
Copy link

josco95 commented Oct 15, 2018

I'm having similar issues as well. Something I am noticing is that my /etc/resolv file has the wrong IP address for the 127 IP:

root@dc08168ef1b1:/# cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0

My pi-hole configurations also do not expressly configure this IP anywhere, so I'm just as confused.

@diginc
Copy link
Collaborator

diginc commented Oct 16, 2018

When you run docker with a dns option/argument it fills in /etc/resolve.conf for you. Docker also manages /etc/hosts so don't expect free control over either one of those files inside a container. You have to use docker arguments to control them.

I opened a pull request (#343) to document the recommendation that everyone add --dns 127.0.0.1 --dns 1.1.1.1 to their docker run commands in order to avoid these types of errors. Various reporters have confirmed this fix works. So basically, hard code your container to be self dependent & have a backup DNS as fallback. This is like having your RasberryPi with a secondary DNS in /etc/resolv.conf in a non docker install.

More thinking out loud at this point about this problem now: The container starts dnsmasq very early in the startup process before lookups happen to avoid any kind of chicken-before-egg (container dns -> docker dns -> router dhcp dns -> container IP) problems so I don't believe it's so simple as that... look in your log for "DNSMasq binding to default interface", that is dnsmasq starting, and you'll see it before the error. Docker provides dns service by default for containers, so perhaps it's at fault here and just hard coding the pi-hole container and a backup external works perfectly since it avoid that.

@josco95
Copy link

josco95 commented Oct 16, 2018

Adding the --dns options to my 'docker run' absolutely resolved my issue. Thanks!

@diginc
Copy link
Collaborator

diginc commented Oct 16, 2018

@jwalton let me know if adding the --dns options works

@jwalton
Copy link

jwalton commented Oct 16, 2018

Yup, fixed it for me! Thanks!

@diginc diginc closed this as completed Oct 17, 2018
@HunterDG
Copy link

HunterDG commented Dec 7, 2019

Why doesn't pi-hole attempt to use the DNS1/DNS2 ENV variables first (or google, since that't the default without the ENV vars) for the initial DNS resolution check? Perhaps fallback to resolv.conf if env var servers don't respond? This would negate the need to specify DNS servers in docker run/compose

@sanbrother
Copy link

This line in /etc/resolv.conf seems to be the magic
nameserver 127.0.0.1

Well, I am running armbian, the essential cause is that, pi-hole assigns static ip address in a 'old' way. I manually configured static ip and name server by 'nmtui' command. And then reboot, the problem is gone.

@dschaper
Copy link
Member Author

This is the repository for our docker images.

@dcharbonnier
Copy link

For the compose file:

pihole:
    container_name: pihole
    image: pihole/pihole:latest
    dns:
      - 127.0.0.1
      - 8.8.8.8

@fallenreaper
Copy link

Trying to get this running in k8s as well, and it was seemingly having this issue. Is there a way to use this DNS flag in k8s for a yaml file?

@uglymagoo
Copy link

uglymagoo commented Dec 4, 2020

Why is this issue closed? Solved by above described --dns options. You should add this as a must-have to the documentation. I only saw there are default values for DNS1 and DNS2 and never even considered that there is a problem when restarting the container.

@fabiosoft
Copy link

For the compose file:

pihole:
    container_name: pihole
    image: pihole/pihole:latest
    dns:
      - 127.0.0.1
      - 8.8.8.8

Thanks so much! it solved my issue in compose (portainer)

@fnkh
Copy link

fnkh commented Feb 1, 2022

For the compose file:

pihole:
    container_name: pihole
    image: pihole/pihole:latest
    dns:
      - 127.0.0.1
      - 8.8.8.8

The above is not working for me. Receiving the following error message

ignoring nameserver 127.0.0.1 - local interface

@vPeteWalker
Copy link

Dude, thank you so much. This was perfect, and resolved my issue! Super happy! Much appreciated! Have a fantastic day!

@jordrok
Copy link

jordrok commented Sep 24, 2022

Fantastic! This did the trick for me!

Everything looked dandy in resolve.conf but no name resolution worked whatsoever. Nothing I did seemed to work. Tried this trick of adding it in docker-compose for the specific docker container and it worked like a charm.

Much appreciated!

@chepe263
Copy link

If you are using portainer, you can edit the container for pihole and check in the last section, there's a tab named "Network". In the last few fields, you can set "Primary DNS Server" and "Secondary DNS Server"

@myrison
Copy link

myrison commented Mar 4, 2023

If you are using portainer, you can edit the container for pihole and check in the last section, there's a tab named "Network". In the last few fields, you can set "Primary DNS Server" and "Secondary DNS Server"

Thanks @chepe263 ... this solved it for me. Appreciate you sharing your solution.

@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/dns-and-dhcp-arent-working-android-devices-seem-to-also-be-not-able-to-access-internet/62670/2

@TheWalkingDadNL
Copy link

For the compose file:

pihole:
    container_name: pihole
    image: pihole/pihole:latest
    dns:
      - 127.0.0.1
      - 8.8.8.8

Thanks, this work for me! I didnt include de 8.8.8.8, because i dont want to use google DNS servers. I have only included 127.0.0.1 and that solved the problem for me.

@wolkenschieber
Copy link

wolkenschieber commented Feb 27, 2024

Google finally brought me here.

I was seeing Gravity update error DNS resolution is not available.

The container's log was giving me on startup:

pihole  |   [i] Existing DNS servers detected in setupVars.conf. Leaving them alone
pihole  |   [i] Applying pihole-FTL.conf setting LOCAL_IPV4=192.168.178.3
pihole  |   [i] FTL binding to default interface: eth0
pihole  |   [i] Enabling Query Logging
pihole  |   [i] Testing lighttpd config: Syntax OK
pihole  |   [i] All config checks passed, cleared for startup ...
pihole  |   [i] Docker start setup complete
pihole  | 
pihole  |   [i] pihole-FTL (no-daemon) will be started as pihole
pihole  | 
pihole  | s6-rc: info: service _startup successfully started
pihole  | s6-rc: info: service pihole-FTL: starting
pihole  | s6-rc: info: service pihole-FTL successfully started
pihole  | s6-rc: info: service lighttpd: starting
pihole  | s6-rc: info: service lighttpd successfully started
pihole  | s6-rc: info: service _postFTL: starting
pihole  |   Checking if custom gravity.db is set in /etc/pihole/pihole-FTL.conf
pihole  | s6-rc: info: service _postFTL successfully started
pihole  | s6-rc: info: service legacy-services: starting
pihole  | s6-rc: info: service legacy-services successfully started
pihole  |   [✗] DNS resolution is currently unavailable

@diginc and @dcharbonnier posts provide both an explanation and a solution.

I'd vote to mention this configuration option within Readme.md as this might prevent issues like #1364.

@PromoFaux
Copy link
Member

I'd vote to mention this configuration option within Readme.md

This issue was closed 5 years ago, with the following lines in the readme being added in by #343

image

@pi-hole pi-hole locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests