-
Notifications
You must be signed in to change notification settings - Fork 126
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
Follow CNAMES on all lookups by default #397
Conversation
@zakird I hit the |
src/cli/cli.go
Outdated
@@ -159,6 +160,7 @@ func init() { | |||
rootCmd.PersistentFlags().BoolVar(&GC.CheckingDisabled, "checking-disabled", false, "Sends DNS packets with the CD bit set") | |||
rootCmd.PersistentFlags().BoolVar(&GC.RecycleSockets, "recycle-sockets", true, "Create long-lived unbound UDP socket for each thread at launch and reuse for all (UDP) queries") | |||
rootCmd.PersistentFlags().BoolVar(&GC.NameServerMode, "name-server-mode", false, "Treats input as nameservers to query with a static query rather than queries to send to a static name server") | |||
rootCmd.PersistentFlags().BoolVar(&GC.ShouldFollowCNAMEs, "follow-cnames", true, "Follow CNAMEs/DNAMEs in the iterative lookup process, not applicable to non-iterative lookups") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this applicable to non-iterative lookups? Shouldn't we follow the name there too if that's what we get back? You could use alookup
in non-iterative mode, so I think this is a step backwards in terms of functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that in non-iterative mode we leave all resolution decisions up to the name server in question. We just return whatever it gives us.
But what you're describing sounds valid as well, and the user could figure out what queries we made (if we followed a CNAME) by looking at the trace, so this does seem like strictly better functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent of the alookup
module was that it did do that unlike the plain A
lookup, which returns the raw response.
src/cli/worker_manager.go
Outdated
@@ -172,6 +176,7 @@ func populateResolverConfig(gc *CLIConf, flags *pflag.FlagSet) *zdns.ResolverCon | |||
// copy nameservers to resolver config | |||
config.ExternalNameServers = gc.NameServers | |||
config.LookupAllNameServers = gc.LookupAllNameServers | |||
config.ShouldFollowCNAMEs = gc.ShouldFollowCNAMEs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is named inconsistent with other options, would remove the "Should" prefix
While many servers do support CNAME Synthesis, I think it would be best to directly support DNAME's since synthesis was primarily designed for backwards compatibility and I think that researchers will want to know if they were actually just following a DNAME. |
Sounds good, I'll add DNAME support and CNAME following on non-iterative queries! |
@zakird When you have a chance, this is ready for review. I've updated the PR description, we're following DNAMEs now and I've tested external lookups. |
I figure I'll wait to get rid of |
It looks like
Are empty in the new code, despite being there in the old one. Can you look into? |
@zakird This definitely was the case with an older version of the code in this branch, but I believe I fixed it. Can you run
|
I'm not sure that I follow. This is what's in the body of the PR:
which does have this? If mainline doesn't do this, I don't follow how we ended up with that output. |
Ohhhh, thought you were seeing this behavior on the branch. You're correct, I forgot to update the PR description. Just updated! |
Resolves #347
Description
--follow-cnames=false
Testing
I found 3 domains that use CNAMES. I couldn't add a CNAME chain to
zdns-testing.com
for repeatable tests because Google Cloud "packs" the CNAME's + A records into a single answer to reduce round trips on resolution:Therefore, testing with Google Cloud doesn't work.
echo "www.wwno.org\nwww.wander-plus.com\nwww.microjpm.com" | ./zdns A --iterative
main Repo - Note how only CNAMES are returned, no A records
Phillip/347-cnames
CNAME with External Resolver
Most recursive resolvers will handle CNAMES for us:
But to prove that we're handling the CNAME traversal, we can point ZDNS to an authoritative nameserver for
wander-plus
and watch the logs:We can see that when the authoritative name server returned the CNAME, we attempted to follow it. Unfortunately, that nameserver isn't authoritative for the domain pointed to by the CNAME, but it shows the logic works. You can also see we return the last good status/result, similar to
dig
.DNAME Testing
See integration test
Turns out that DNS nameservers will perform CNAME Synthesis with DNAMES (for backwards compatibility for devices that don't support it) and our coreDNS resolver at
esrg.stanford.edu
is no different.To test the DNAME following, I inserted code to drop all CNAME answers manually. In this way, we'd only get the correct output if DNAMES were being followed.
I couldn't think of a reliable way to automate this testing, it doesn't seem that CoreDNS supports turning off CNAME Synthesis for DNAME's.
External Lookups
Here we can see when doing an external lookup against
dns-01.esrg.stanford.edu
, DNAMEs are being followed.(We first lookup a.zdns-dname.esrg.stanford.edu, and then query for
a.zdns-testing.com
, which the name server isn't authoritative for but it tests we're following it correctly.