TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
4.47k stars 431 forks source link

Primary DNS zone transfer over different port issue #956

Closed LilyTheOtter closed 1 month ago

LilyTheOtter commented 4 months ago

Based on the following reddit post: https://www.reddit.com/r/technitium/comments/1do6mxu/primary_dns_zone_transfer_over_different_port/

Summary: For corporate reasons we need 3 servers in 3 locations, 1 location will have Primary DNS zone and can't go over port 53 so 8053 has been chosen. Zone transfers with port 53 work fine but when changing to port 8053 self initiated zone transfers from notify etc. stop working but clicking resync in the GUI works fine.

Test setup:

1 Primary server running on Debian 12.5 with IP 10.13.10.65 1 Secondary server also running Debian 12.5 with IP 10.13.10.66

Primary zone settings corp.test: Port of DNS server: 53 Zone Transfer: Only specified name servers with 10.13.10.66 specified Notify: Only specified name servers with 10.13.10.66 specified

Primary zone settings corp2.test: Port of DNS server: 8053 Zone Transfer: Only specified name servers with 10.13.10.66 specified Notify: Only specified name servers with 10.13.10.66 specified

First test: So in the first test when the Primary server port was still 53 I added the Primary zone test.corp on the Primary server 10.13.10.65, in the zone settings I allow zone transfers from 10.13.10.66 and also notify 10.13.10.66. I go on the Secondary server 10.13.10.66 and add the secondary zone test.corp pointing to 10.13.10.65. This works perfectly and when I create a record on the primary DNS it gets updated on the secondary. Perfect.

Second test: In the second test I changed the port of the DNS listener to 8053 and added the Primary zone test2.corp on the Primary server 10.13.10.65, in the zone settings I allow zone transfers from 10.13.10.66 and also notify 10.13.10.66. I go on the Secondary server 10.13.10.66 and add the secondary zone test2.corp pointing to 10.13.10.65:8053. It adds the secondary zone just fine, but when I add a record on the Primary zone it doesn't update on the secondary server and eventually gives a "sync failed" status instead of "enabled". Clicking the resync button gives a successful zone transfer but goes back to the same problem. Logs are as follows:

[2024-06-25 13:42:08 UTC] [10.13.10.65:58946] [UDP] DNS Server received a NOTIFY request for secondary zone: test2.corp
[2024-06-25 13:42:13 UTC] DNS Server has started zone refresh for secondary zone: test2.corp
[2024-06-25 13:42:13 UTC] DNS Server failed to refresh 'test.corp' secondary zone from: 10.13.10.65
TechnitiumLibrary.Net.Dns.DnsClientNoResponseException: DnsClient failed to resolve the request 'test.corp. SOA IN': request timed out.
 ---> System.Net.Sockets.SocketException (110): Connection timed out
   at TechnitiumLibrary.Net.SocketExtensions.UdpQueryAsync(Socket socket, ArraySegment`1 request, ArraySegment`1 response, IPEndPoint remoteEP, Int32 timeout, Int32 retries, Boolean expBackoffTimeout, Func`2 isResponseValid, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\SocketExtensions.cs:line 143
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 271
   --- End of inner exception stack trace ---
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 280
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4412
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4590
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4327
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4689
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalNoDnssecResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4706
   at DnsServerCore.Dns.Zones.SecondaryZone.RefreshZoneAsync(IReadOnlyList`1 primaryNameServers, DnsTransportProtocol zoneTransferProtocol, TsigKey key) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dns\Zones\SecondaryZone.cs:line 333
[2024-06-25 13:43:03 UTC] DNS Server failed to refresh 'test2.corp' secondary zone from: 10.13.10.65:8053
TechnitiumLibrary.Net.Dns.DnsClientNoResponseException: DnsClient failed to resolve the request 'test2.corp. SOA IN': request timed out.
 ---> System.Net.Sockets.SocketException (110): Connection timed out
   at TechnitiumLibrary.Net.SocketExtensions.UdpQueryAsync(Socket socket, ArraySegment`1 request, ArraySegment`1 response, IPEndPoint remoteEP, Int32 timeout, Int32 retries, Boolean expBackoffTimeout, Func`2 isResponseValid, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\SocketExtensions.cs:line 143
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 271
   --- End of inner exception stack trace ---
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 280
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4412
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4590
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4327
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4689
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalNoDnssecResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4706
   at DnsServerCore.Dns.Zones.SecondaryZone.RefreshZoneAsync(IReadOnlyList`1 primaryNameServers, DnsTransportProtocol zoneTransferProtocol, TsigKey key) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dns\Zones\SecondaryZone.cs:line 333[2024-06-25 13:42:08 UTC] [10.13.10.65:58946] [UDP] DNS Server received a NOTIFY request for secondary zone: test2.corp
[2024-06-25 13:42:13 UTC] DNS Server has started zone refresh for secondary zone: test2.corp
[2024-06-25 13:42:13 UTC] DNS Server failed to refresh 'test.corp' secondary zone from: 10.13.10.65
TechnitiumLibrary.Net.Dns.DnsClientNoResponseException: DnsClient failed to resolve the request 'test.corp. SOA IN': request timed out.
 ---> System.Net.Sockets.SocketException (110): Connection timed out
   at TechnitiumLibrary.Net.SocketExtensions.UdpQueryAsync(Socket socket, ArraySegment`1 request, ArraySegment`1 response, IPEndPoint remoteEP, Int32 timeout, Int32 retries, Boolean expBackoffTimeout, Func`2 isResponseValid, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\SocketExtensions.cs:line 143
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 271
   --- End of inner exception stack trace ---
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 280
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4412
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4590
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4327
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4689
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalNoDnssecResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4706
   at DnsServerCore.Dns.Zones.SecondaryZone.RefreshZoneAsync(IReadOnlyList`1 primaryNameServers, DnsTransportProtocol zoneTransferProtocol, TsigKey key) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dns\Zones\SecondaryZone.cs:line 333
[2024-06-25 13:43:03 UTC] DNS Server failed to refresh 'test2.corp' secondary zone from: 10.13.10.65:8053
TechnitiumLibrary.Net.Dns.DnsClientNoResponseException: DnsClient failed to resolve the request 'test2.corp. SOA IN': request timed out.
 ---> System.Net.Sockets.SocketException (110): Connection timed out
   at TechnitiumLibrary.Net.SocketExtensions.UdpQueryAsync(Socket socket, ArraySegment`1 request, ArraySegment`1 response, IPEndPoint remoteEP, Int32 timeout, Int32 retries, Boolean expBackoffTimeout, Func`2 isResponseValid, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\SocketExtensions.cs:line 143
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 271
   --- End of inner exception stack trace ---
   at TechnitiumLibrary.Net.Dns.ClientConnection.UdpClientConnection.QueryAsync(DnsDatagram request, Int32 timeout, Int32 retries, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\ClientConnection\UdpClientConnection.cs:line 280
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4412
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4590
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.<>c__DisplayClass87_0.<<InternalResolveAsync>g__DoResolveAsync|1>d.MoveNext() in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4327
--- End of stack trace from previous location ---
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4689
   at TechnitiumLibrary.Net.Dns.DnsClient.InternalNoDnssecResolveAsync(DnsDatagram request, CancellationToken cancellationToken) in Z:\Technitium\Projects\TechnitiumLibrary\TechnitiumLibrary.Net\Dns\DnsClient.cs:line 4706
   at DnsServerCore.Dns.Zones.SecondaryZone.RefreshZoneAsync(IReadOnlyList`1 primaryNameServers, DnsTransportProtocol zoneTransferProtocol, TsigKey key) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dns\Zones\SecondaryZone.cs:line 333
ShreyasZare commented 4 months ago

Thanks for posting here. Will get this fixed and let you know when the update is available.

siaush commented 4 months ago

I am facing the same issue as well, but what's interesting is, I only face this on a new zone that I have created recently, while an old zone that I have created with the earlier versions of Technitium DNS is still syncing without any issues.

After spending a few hours trying to troubleshoot, I noticed that newer versions of Technitium DNS (11.0 and above) saves the Primary Name Server Addresses in the Secondary Zone SOA record a little differently, please allow me to illustrate.

Current setup:

I noticed that the Primary Name Server Addresses in the Secondary Zone SOA record that I am trying to create on v11.0 and above is changed slightly when I save the record, i.e. inputted as primary.technitium-dns (10.0.0.1:5335) but saved as primary.technitium-dns:5335 (10.0.0.1). While on v10.0, it was saved exactly as inputted.

My current workaround was to spin up a temporary third node pinned to v10.0, create and configure the Secondary Zone there, and then copy the .zone file from the third node to the secondary node. For some reason, this will allow the sync to work.

I know this is a long shot as the config files are binary files, but prior to using a third node, I attempted to edit the Primary Name Server Address in .zone file manually using a text editor, to the format in v10.0, but it does not work.

I am resorting to using a manual sync as Notify does not allow the use of a custom port in the IP addresses of the name servers to notify.

By any chance this will be fixed? Or if it is not too much of an ask, to support custom ports for the Notify feature as well?

Thanks and have a nice day!

ShreyasZare commented 4 months ago

@siaush Yes, you have correctly found the issue. This has been fixed in the development code and the fix will be available in the next update.

siaush commented 4 months ago

@ShreyasZare Cool! That's great to hear, and thanks for the awesome software!

MrZoidberg commented 3 months ago

@ShreyasZare Would be great to get it fixed. Is there way to get dev version of docker image? Btw, I think macvlan fixes this problems as than ports are no longer occupied, but it's not an easy setyp

ShreyasZare commented 3 months ago

@ShreyasZare Would be great to get it fixed. Is there way to get dev version of docker image? Btw, I think macvlan fixes this problems as than ports are no longer occupied, but it's not an easy setyp

Thanks for asking. The next being a major update is taking a bit more time than expected. The dev version is not in shape to be used in production and may cause compatibility issues when the update is available. I am trying to get the update available soon. Please bear with this issue for time being.

ShreyasZare commented 1 month ago

Technitium DNS Server v13 is now available that fixes this issue. Do update and let me know your feedback.