mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-24 18:55:55 +03:00
[GH-ISSUE #1057] Replicating hostname -d #593
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#593
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Diggsey on GitHub (Apr 4, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1057
I'm trying to replicate the behaviour of
hostname -d.From looking at the source for this command, it appears to first get the hostname of the computer, and then searches for A records for that hostname. The result of this search is a
hostentcontaining the FQDN from which the domain part can be extracted.When I run
hostname -din WSL I getlocaldomain. The equivalents on windows report either no domain or WORKGROUP. I would want to get something similar when I use trust-dns in the two environments.This is my first attempt:
However, when I run this on windows, I get:
If I run it in WSL, it completes instantly but I get this:
Now, the windows results I'm not too fussed about - there's not a clear equivalent to
hostname -d, although I would like it to not take 30 seconds, and not give something completely crazy like that. However, I believe my ISP is mostly to blame as it seems to be spoofing DNS results in order to direct me to adverts when the domain doesn't exist...However, the WSL results are confusing to me. My
/etc/hostsfile (in WSL) looks like this:So it seems pretty clear to me that the IP 127.0.1.1 should correspond to the FQDN
DESKTOP-SBVU0O9.localdomain, from which I could correctly determine the domain name, and yet trust-dns is still returninglocalhost?@Diggsey commented on GitHub (Apr 4, 2020):
I've tried doing the same thing with
getaddrinfoandgetnameinfo, and they work as expected on both windows and WSL.There are three parts of trust-dns that are not working as expected:
lookup_ipproduces a different result fromgetaddrinfowith the same hostname.reverse_lookupfinds no records for my LAN IP wheregetnameinfocorrectly returnsDESKTOP-SBVU0O9.reverse_lookupdoes not use the/etc/hostsfile and somehow resolves the IP tolocalhostwhengetnameinfoinstead resolves it toDESKTOP-SBVU0O9.localdomain.@bluejekyll commented on GitHub (Apr 5, 2020):
On linux/wsl, could you show what's in your
/etc/resolv.conf?@bluejekyll commented on GitHub (Apr 5, 2020):
FYI, I just reviewed the code quickly. I'm fairly certain we don't currently evaluate the
hostsfile for reverse mappings today. The reason you're gettinglocalhostfor the reverse of the127.0.1.1is that there is a static rule to bind127/8to localhost, that happens here: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup_state.rs#L133.I think if we want to support reverse mappings from the hosts file, it might be as simple as adding the logic with the reverse mapping here: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/hosts.rs#L42. This would need a reverse mapping stored as well, right now there is
by_name, so we'd need aby_ipas well.In addition to that, the hosts file is only referenced in the lookup_ip methods. So we'd want to consider adding that to all lookups, possibly, it would need to be queried here: https://github.com/bluejekyll/trust-dns/blob/master/crates/resolver/src/lookup.rs#L244
I think that would address the issue you're asking about.
@Diggsey commented on GitHub (Apr 5, 2020):
Yeah, that sounds like it would fix the WSL problem. I could put in a PR to support the reverse mapping, but I'm not exactly sure what would need doing to support the other lookups you mentioned.
I think it's still a little weird that
getaddrinfoon windows returns the expected IP forDESKTOP-SBVU0O9- it must be doing something other than a DNS lookup...One other thing: it seems like it should be possible to go from a hostname to a FQDN without having to do the additional reverse search? I'm really only interested in the specific result for the hostname, and it seems like going back via the IP could potentially return other results?
@JessicaBlunt commented on GitHub (Apr 23, 2020):
I came across this on my system, but I don't even have trust-dns installed. Sorry if this is silly - I don't have a strong networking background.
Could this be a WSL issue? If someone here thinks so, I'll try to report it to Microsoft.