-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
DNS does not work in containers if host uses local server #3277
Comments
@giuseppe This is the issue we were talking about, I hope it has all the information that is related, feel free to ask for any additional info, I will gladly provide it. |
For root containers, if you have |
@mheon Well, clearly slirp4netns, as the userspace process running in the default network namespace, should be able to connect to the same nameservers as other processes in the default net namespace, so I see no reason for having google dns servers in /etc/resolv.conf. I just do not know if that is done by slirp4netns or podman. |
That would most certainly be podman doing the resolv.conf. |
Great! So did I miss any reasoning behind providing default google nameservers with slirp4netns instead of just using 10.0.2.3? |
@giuseppe Any ideas? |
@nertpinx So, to clarify - what does your host system's resolv.conf look like? 127.0.0.1, then 10.0.2.3? And we're dropping 127.0.0.1 in favor of the Google DNS servers, despite 10.0.2.3 being in resolv.conf already? |
No, 10.0.2.3 is the slirp4netns' DNS provided on the emulated network stack that works. On my machine resolvconf has only ::1, on the clean fedora install with systemd-resolved properly applied it has only 127.0.0.53. |
Aha. Alright, I think we're probably seeing a bad interaction between our resolv.conf handling and the handling in slirp4netns, then. |
I think the issue is that we block slirp4netns from accessing the loopback device for security reasons. If you check, you'll see that we are passing an explicit |
I would guess that forbids accessing the host directly (through 10.0.2.2) from the child namespace, not the slirp4netns process. And trying it out it really is the case, if I leave 10.0.2.3 in resolv.conf it works nicely (on the fedora reproducer VM). |
When using slirp4netns, be sure the built-in DNS server is the first one to be used. Closes: containers#3277 Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe Yes it does (at least the main issue), thank you! |
This does not always work. The nameserver is chosen at random (or at least it is not defined how it is chosen), so chances are that a generic nameserver will be chosen instead of This has just hit me. Host
Container
Host is connected to a corporate VPN which provides a custom nameserver that resolves several internal-only domains. The semantics of "try all nameservers" is enforced via systemd-resolved on the host side. However, connections to internal domains from the container can (and do) arbitrarily fail. Manually changing the container's
As far as I can see, this would be the fully correct behavior. Please reconsider. |
Chosen as random? What? That does not sound correct. Per the
Queried in order should be a safe assumption. How are you making DNS queries / what libc are you using? |
Ah, I see. |
No, systemd-resolved is on the host, not in the container, and it's actually doing the right thing here (as tempting as it is to blame systemd for everything). |
If the resolv.conf is properly formatted, their is little podman can do to fix that. |
I'm not quite sure what do you mean by that, but earlier in this thread @giuseppe did something to reorder nameservers in the generated resolv.conf, which means that my suggestion is also possible.
No, the issue is that the processes inside of the container reach the wrong nameserver — instead of contacting systemd-resolved on the host they try to contact upstream nameservers directly. |
if you'd like to have only |
I had the same issue on my setup by I was able to overcome the issue with a simple fix. |
A
As a result podman seems to remove the nameserver line and adds the "upstream" DNS servers directly. Bypassing the host's systemd-resolved has at least the following problems:
So whatever which DNS server I choose by setting How to fix that? [Edit] |
We do have a (limited) ability to do our own DNS via |
That would work, @baude WDYT |
I would love to see a DNS proxy since my upstream DNS servers are DoT-only. Currently I pass |
so on fedora (as the main developer platform for podman people) and also rhel-8 systemd-resolved is the default. so using a properly configured systemd-resolved on host can't be used as a name server for containers run by root!? and the only solution is to use --net host! why did you close this issue??? |
@rhatdan Can this issue be reopened? From what I read above podman is still unreliable when there are non-trivial dns setups on the host. |
Please open a new issue, describing your exact issues. |
So what is the new (still open, since I still see this problem) issue that covers a localhost (127.0.0.1) DNS resolver and rootful containers? |
There is none, best of my knowledge, though I suspect that will be supported from Podman 4.4 onwards via the DNS changes in Aardvark. |
@patrickbkr, @brianjmurrell reported as #17075 |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Steps to reproduce the issue:
Be in a network that prohibits external DNS queries, disable external DNS communication or just use some only-locally available hostname in step 3.
Setup local DNS server/forwarder (e.g.
systemd-resolved
) so that the local address is in /etc/resolv.confStart any container (without
--network host
) and try to resolve a hostname (e.g.podman run --rm -it fedora curl -v ifconfig.me
)Describe the results you received:
curl: (6) Could not resolve host: ifconfig.me
Describe the results you expected:
No error (some IP address)
Additional information you deem important (e.g. issue happens only occasionally):
The contents of
/etc/resolv.conf
are:Which would normally work (although I might not want to send my DNS requests somewhere else because I might have services available in a local network), but I am in a network that prohibits external DNS queries, so that doesn't work.
If I leave just the slirp4netns nameserver there (
echo nameserver 10.0.2.3 >/etc/resolv.conf
) it works in a VM where I am trying to reproduce this issue. However on my original host, where I discovered this,10.0.2.3
is still inaccessible (even though the version and the command-line of slirp4netns is identical, apart from the PID argument).Output of
podman version
:Output of
podman info --debug
:Additional environment details (AWS, VirtualBox, physical, etc.):
I am trying this in a Fedora 30 VM, clean install, as that is the easiest and cleanest reproducer I can get. I cannot reproduce the issue related to my local environment in there.
The text was updated successfully, but these errors were encountered: