NameServer changes in v1.5 #122
MichaCo
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, the changes to the NameServer type coming in v1.5 of DnsClient are non-breaking!
Respecting NRPT policies
In the upcoming version 1.5 of DnsClient with the help of @SteveSyfuhs we added support to get nameserver settings from NRPT policies (see #114) in addition to the already existing scanning of network interfaces.
NRPT policies might be setup in your organization and/or when you are connected via a VPN to your organization's network.
All this is not working on non-windows systems because the policies are stored in the windows registry.
Although this is probably a niche feature, I had to add a dependency to the
Microsoft.Win32.Registry
NuGet package.If you have any concerns/questions about this, let me know.
DnsSuffix
I got a bunch of questions in the past years about making DnsClient also able to resolve hostnames without a DnsSuffix, and to respect DnsSuffix while doing queries.
For now, I added a DnsSuffix property to the
NameServer
type, which can be populated if you construct an instance yourself, or will be set by the build in nameserver resolution, if your network adapter(s) or your NRPT policies have a DnsSuffix configured.DnsClient queries will NOT use that suffix yet though, and I'm not really sure how to best implement this to be honest, so I'm asking for some feedback here ;)
I have an example implementation of how you could use the suffix.
The code basically implements the logic of nslookup, which does append the suffix if the query only has one label AND the query does not end with a dot.
See: https://github.com/MichaCo/DnsClient.NET/blob/dev/samples/MiniDig/DigCommand.cs#L116
I also added the
+
operator to DnsString for convinience, so that you can just concatenate the 2 values without having to deal with dots at the beginning or end... e.g.:var newQuery = query + server.DnsSuffix;
In my opinion, this is enough to conditionally use DnsClient to do hostname lookups.
The logic above is pretty opinionated and I don't really want to add that to the default query interface of
LookupClient
.Thoughts?
Thanks,
Michael
Beta Was this translation helpful? Give feedback.
All reactions