Closed PonchoPowers closed 4 years ago
The following suggests that the domain if empty is the root zone, but in this cause the same method is being used to test hostnames for devices.
if (domain.Length == 0)
return true; //domain is root zone
So I'm not really sure how you want to fix this as I'm not sure the following is really valid either.
if (domain == null)
return **???**;
Setting HostName
to an empty string would be a hack as it is null as there is no hostname.
So I propose the following fixes:
Change:
_authoritativeZoneRoot.SetRecords(lease.HostName, DnsResourceRecordType.A, scope.DnsTtl, new DnsResourceRecordData[] { new DnsARecord(lease.Address) });
to:
if (lease.HostName != null)
_authoritativeZoneRoot.SetRecords(lease.HostName, DnsResourceRecordType.A, scope.DnsTtl, new DnsResourceRecordData[] { new DnsARecord(lease.Address) });
And change:
_authoritativeZoneRoot.SetRecords(Scope.GetReverseZone(lease.Address, 32), DnsResourceRecordType.PTR, scope.DnsTtl, new DnsResourceRecordData[] { new DnsPTRRecord(lease.HostName) });
to:
if (lease.HostName != null)
_authoritativeZoneRoot.SetRecords(Scope.GetReverseZone(lease.Address, 32), DnsResourceRecordType.PTR, scope.DnsTtl, new DnsResourceRecordData[] { new DnsPTRRecord(lease.HostName) });
You might want to check this first to make sure it doesn't break anything as my knowledge of network technology is rubbish.
Thanks for the debugging. This can be fixed in UpdateDnsAuthZone() with below check:
if (string.IsNullOrEmpty(lease.HostName))
return;
Just tested, the fix you proposed works for me, much simpler than my solution.
Technitium DNS Server v4.1 is now available that fixes this issue.
An exception is thrown when enabling the default scope after a reboot of the physical server when devices with no hostname have already been offered a lease that is now saved to the config.
I've tracked it down to the following:
The lease hostname is null when saved...
As you can see in the following, I have two devices on my network which don't have a hostname, not sure if this is normal or not: