MichaCo / DnsClient.NET

DnsClient.NET is a simple yet very powerful and high performant open source library for the .NET Framework to do DNS lookups
https://dnsclient.michaco.net
Apache License 2.0
781 stars 137 forks source link

Question: Query on host name (excl. domain) #137

Closed engstrumpan closed 2 years ago

engstrumpan commented 2 years ago

Hi, As the title suggests, this is a question rather than a issue and I hope this is the way to do it.

For the record, this whole thing with DNS lookups and networking in general is not my area of expertise with little knowledge about it in general. So with that said, here's what I'm trying to accomplish.

I have a bunch of host names, i.e MY-AS-TE-ME500, that I'd like to resolve into A record IP Addresses. Doing this command line nslookup MY-AS-TE-ME500 gives me what I'm after like below (address deducted)

Name:    my-as-te-me500.my.domain.net
Address:  0.0.0.0

But, when trying out DnsClient.NET, which by the way is an awesome product and I much appreciate the effort you've put in to this, I can't query said host name and resolve the IP Address whithout specifying the full domain name.

This fails

var rs = await _lookupClient.QueryAsync("MY-AS-TE-ME500", QueryType.A);

This works

var rs = await _lookupClient.QueryAsync("MY-AS-TE-ME500.my.domain.net", QueryType.A);

Failing to do so, the query reaches a timeout. Clearly there is a discrepancy between nslookup and Dnsclient.NET, probably for obvious reasons I don't know due to my lack of understanding of this domain.

So:

Can this be accomplished, querying without specifying the full domain name? I've tried with specific name servers to the instantiation of the client but maybe there's other options I need to configure as well to get this to work?

edit: The reason for not wanting to specify the full domain name of the host is because I can't guarantee all server names in the list is from the same domain so can't really hard code it.