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
789 stars 137 forks source link

AXFR Request - Cannot read IPv6 address #157

Closed ahartgit closed 2 years ago

ahartgit commented 2 years ago

I'm running AXFR requests on multiple domains. All of them work except one, where I'm getting an exception on the lookup query (it's thrown regardless of if ThrowDnsErrors is set to true or false cause it's an error on the parser, not from DNS).

The code:

LookupClientOptions lcOpt = new LookupClientOptions(domainIps);
lcOpt.UseTcpOnly = true; // required for AXFR requests
lcOpt.UseCache = false;
//lcOpt.ThrowDnsErrors = true;

LookupClient lookup = new LookupClient(lcOpt);
IDnsQueryResponse records = lookup.Query(domainName, QueryType.AXFR);

The error:

DnsClient.DnsResponseParseException: 'Response parser error, 16356 bytes available, tried to read 16 bytes at index 16343.
Cannot read IPv6 address, expected 16 bytes.
[ZByBgAABAiAAAAAABUFQQzA1A2NvbQAA/AABD0FEUy01NDM3MDY3NS0wMcAMABwAAQAABLAAECYgASOQAAUQAAAA....[continues for a long time]

Any idea why this might be happening? Not sure if it's a bug or something off in my DNS. I can't see the records it's working with because the exception is thrown on the lookup itself. I've gone through the DNS zone looking for any malformed records, but haven't found anything so far.

ahartgit commented 2 years ago

Looks like I found the problem, there was a record with a hostname that was 16 characters long. Normally, hostnames are limited to 15 chars in Windows, but you can make them longer in DNS.

I deleted that record and the error went away. Still could be an issue that comes up again though.

MichaCo commented 2 years ago

Hi, the error means that the DNS Server sent invalid data, probably some non existing pointer or an invalid length prefix for some names. There is not much the library can do if the data is wrong.

If you can replicate that easily with a well known DNS server, then let me know how. Until then I'll /close the issues