You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nslookup fails inside a container using the default DNS server #216
The second article notes that ping is a better basic test of DNS.
Benjamin Berman (@doctorpangloss) Just so that we can understand severity, is this a blocking issue for you or are you noting an unexpected behavior that is not blocking? Thanks!
On Windows, there are multiple DNS resolvers that can be used. As these come with slightly different behaviors, using the Resolve-DNSName powershell cmdlet for name query resolutions is recommended.
The primary dns server is defaulting to the default gateway, by any chance did you intend to do that? The secondary dns servers will resolve. However a work around that will allow this to work is:
Create a new docker nat network:
docker network create -d "nat" --subnet "10.240.0.0/24" -o com.docker.network.windowsshim.disable_gatewaydns=true natgw
docker run -it --rm --net=natgw mcr.microsoft.com/windows/servercore:ltsc2022
You could possibly try deleting the nat network and creating it with the options above as well. Let me know if this works!
Unfortunately the approach of disabling the default gateway resolves the issue with resolving DNS queries however it breaks the internal docker DNS that resolves the containers ip by the container name.
A lot of this is mentioned in bits and pieces above, but here is what's going on, which I confirmed in our lab:
The Windows implementation of nslookup uses its own internal implementation of the DNS protocol and will only query one DNS server. By default this is the first DNS server in the list. This differs from nslookup on Linux which will retry with other servers in the resolv.conf file.
For containers the first DNS server in the list and the one used by nslookup by default is the Docker DNS resolver. This is required in order to resolve container IPs by their name. Unfortunately due to the Docker DNS issue Zappa linked up above the Docker resolver does not currently forward requests to an external DNS server. This is in the process of being fixed in the Moby repo.
Given the above, our general recommendation is to use the Resolve-DnsName cmdlet instead. Resolve-DnsName uses the built-in DNS client for the OS which will retry with all of the available DNS servers and unlike nslookup also works with configurations that use newer DNS technologies such as DNSSEC, DNS-over-HTTP (DoH) and DNS-over-TLS (DoT). This is the best way to determine if DNS is functioning within the container. Any application that relies on Windows to do the DNS lookup will get the same behavior as Resolve-DNSName.
If you really want to use nslookup you can, but be aware of the above limitations.
You may also be having DNS connection issues outside of the container host. To narrow that down, use pktmon to trace the packet to see if it leaves the container host in the correct format. In my environment 8.8.8.8 is blocked somewhere on the network. I can confirm it is not an issue with the Windows Container host by doing the following:
PS C:\> nslookup bing.com 8.8.8.8
DNS request timed out.
timeout was 2 seconds.
Server: UnKnown
Address: 8.8.8.8
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to UnKnown timed-out
In notepad I can look at the Appearance # to find the last appearance of the DNS request packet, check which component it was last seen on, and confirm that the packet looks correct:
Whenever the last appearance is the ethernet adapter it's safe to assume the packet left the machine. I verified that the IP addresses are correct, and that the destination MAC address is the physical ethernet switch. Since I never see a response in the pktmon log I know that I never received a reply on the container host.
I will leave this issue open for a few days longer, if anyone can show a pktmon log that suggests the container host dropped the packet incorrectly (not including the Moby issue above), I can look into that. If not, I'll close this issue.
Reacted by Paul "TBBle" Hampson, Benjamin Berman, Fady Azmy and Huy Z
Activity
cwilhit commentedon Mar 31, 2022
Thanks for opening this and providing repro steps. I've confirmed the repro and have opened MSFT internal 38776581 for reference.
michbern-ms commentedon Apr 1, 2022
There are a few articles about how Windows nslookup fails if the primary DNS fails, even when the second DNS is working fine:
https://defaultroot.com/index.php/2019/10/08/nslookup-default-behaviour-during-failover-of-primary-dns/#:~:text=Windows%20nslookup%20will%20always%20use%20the%20primary%20DNS,in%20the%20nslookup%20command%3A%20So%20all%20is%20well%21
https://social.technet.microsoft.com/Forums/en-US/b1977a50-c482-4daf-b113-63e87b9430d3/secondary-dns-does-not-resolve-160-the-nslookup-requests-windows-customer-160-when-the-primary
The second article notes that ping is a better basic test of DNS.
Benjamin Berman (@doctorpangloss) Just so that we can understand severity, is this a blocking issue for you or are you noting an unexpected behavior that is not blocking? Thanks!
doctorpangloss commentedon Apr 3, 2022
Sounds good if this is a general Windows issue...
doctorpangloss commentedon Feb 1, 2023
I am reopening this because it seems almost every Windows container user encounters it
lippertmarkus commentedon Feb 3, 2023
I'm having this issue since the last Windows Update to 10.0.22621.1105.
jsturtevant commentedon Feb 6, 2023
does
Resolve-DnsNamework? My understanding is thatResolve-DnsNameis the preferred tool for DNS lookups according to the networking team due to a difference in resolvers between the two. We call out usingResolve-DnsNamein the kubernetes docs: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#dns-windowslippertmarkus commentedon Feb 6, 2023
unfortunately not
doctorpangloss commentedon Feb 6, 2023
It's really hard to say. There's a real issue here. For example would a
golangapplication use the same mechanism asnslookuporResolve-DNSName?microsoft-github-policy-service commentedon Apr 21, 2023
This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.
7 remaining items
microsoft-github-policy-service commentedon Jul 23, 2023
This issue has been open for 30 days with no updates.
sbangari, Mike Zappa (@MikeZappa87), please provide an update or close this issue.
microsoft-github-policy-service commentedon Jul 23, 2023
This issue has been open for 30 days with no updates.
sbangari, Mike Zappa (@MikeZappa87), please provide an update or close this issue.
microsoft-github-policy-service commentedon Aug 23, 2023
This issue has been open for 30 days with no updates.
sbangari, Mike Zappa (@MikeZappa87), please provide an update or close this issue.
burkhat commentedon Sep 15, 2023
We've the same behaviour in our Kubernetes Environment with Windows Nodes.
nslookup doesn't work, Resolve-DnsName works without any problem.
sam-sla commentedon Sep 15, 2023
We are also facing name-resolution issues since approximately one week ago. I think these two issues are all related to the same #386 and #420
MikeZappa87 commentedon Oct 23, 2023
The primary dns server is defaulting to the default gateway, by any chance did you intend to do that? The secondary dns servers will resolve. However a work around that will allow this to work is:
Create a new docker nat network:
docker network create -d "nat" --subnet "10.240.0.0/24" -o com.docker.network.windowsshim.disable_gatewaydns=true natgw
docker run -it --rm --net=natgw mcr.microsoft.com/windows/servercore:ltsc2022
You could possibly try deleting the nat network and creating it with the options above as well. Let me know if this works!
MikeZappa87 commentedon Nov 10, 2023
Unfortunately the approach of disabling the default gateway resolves the issue with resolving DNS queries however it breaks the internal docker DNS that resolves the containers ip by the container name.
davhdavh commentedon Dec 11, 2023
Any actual workarounds for this?
Ping 172.17.80.1 => FAIL
Ping 192.168.2.253 => FAIL
Ping 8.8.8.8 => SUCCESS
nslookup using 172.17.80.1 => FAIL
nslookup using 192.168.2.253 => FAIL
nslookup using 8.8.8.8 => SUCCESS
I tried:
florianehmke commentedon Mar 7, 2024
Facing the same issue, any updates here? I have no workaround and for me the issue appeared out of nowhere.
grcusanz commentedon Mar 20, 2024
A lot of this is mentioned in bits and pieces above, but here is what's going on, which I confirmed in our lab:
The Windows implementation of nslookup uses its own internal implementation of the DNS protocol and will only query one DNS server. By default this is the first DNS server in the list. This differs from nslookup on Linux which will retry with other servers in the resolv.conf file.
For containers the first DNS server in the list and the one used by nslookup by default is the Docker DNS resolver. This is required in order to resolve container IPs by their name. Unfortunately due to the Docker DNS issue Zappa linked up above the Docker resolver does not currently forward requests to an external DNS server. This is in the process of being fixed in the Moby repo.
Given the above, our general recommendation is to use the Resolve-DnsName cmdlet instead. Resolve-DnsName uses the built-in DNS client for the OS which will retry with all of the available DNS servers and unlike nslookup also works with configurations that use newer DNS technologies such as DNSSEC, DNS-over-HTTP (DoH) and DNS-over-TLS (DoT). This is the best way to determine if DNS is functioning within the container. Any application that relies on Windows to do the DNS lookup will get the same behavior as Resolve-DNSName.
If you really want to use nslookup you can, but be aware of the above limitations.
You may also be having DNS connection issues outside of the container host. To narrow that down, use pktmon to trace the packet to see if it leaves the container host in the correct format. In my environment 8.8.8.8 is blocked somewhere on the network. I can confirm it is not an issue with the Windows Container host by doing the following:
On the container host:
In the container:
Back on the container host:
In notepad I can look at the Appearance # to find the last appearance of the DNS request packet, check which component it was last seen on, and confirm that the packet looks correct:
Further down in the file I can see that Component 6 is the ethernet adapter:
Whenever the last appearance is the ethernet adapter it's safe to assume the packet left the machine. I verified that the IP addresses are correct, and that the destination MAC address is the physical ethernet switch. Since I never see a response in the pktmon log I know that I never received a reply on the container host.
I will leave this issue open for a few days longer, if anyone can show a pktmon log that suggests the container host dropped the packet incorrectly (not including the Moby issue above), I can look into that. If not, I'll close this issue.
doctorpangloss commentedon Mar 21, 2024
It makes sense to me if there were documentation somewhere that
nslookupshould simply not be used on Windows.grcusanz commentedon Mar 25, 2024
Benjamin Berman (@doctorpangloss) Thanks for the suggestion, I've submitted a PR to the container networking docs with this information.
Forward DNS suffix search list to Windows sidecar containers
Forward DNS suffix search list to Windows sidecar containers