TechnitiumSoftware / DnsServer

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

[bug / feature request] Don't lose DHCP Scope on crash, and provide backup functionality #204

Closed MartijnDekkers closed 3 years ago

MartijnDekkers commented 3 years ago

Hi! First of all, thanks for open sourcing such a great piece of software!

I encountered a bug recently, where the Pi I'm running this on switched off unexpectedly, due to me pulling out the wrong power plug....

On restart, I lost all my DHCP config - the scope as well as all the static reservations. There was the following error in the logs:

[2020-12-04 04:17:15 UTC] DHCP Server failed to load scope file: /etc/dns/config/scopes/Vanaheimr.scope

System.IO.InvalidDataException: DhcpServer scope file format is invalid.
   at DnsServerCore.Dhcp.Scope..ctor(BinaryReader bR) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dhcp\Scope.cs:line 100
   at DnsServerCore.Dhcp.DhcpServer.LoadScopeFileAsync(String scopeFile) in Z:\Technitium\Projects\DnsServer\DnsServerCore\Dhcp\DhcpServer.cs:line 971

It would be great if we could backup and restore the config in a simple way. I see we can use API calls (which is great) but a simple backup/restore CLI command would make this a simple thing for when you just want a simple solution.

ShreyasZare commented 3 years ago

Thanks for the compliments and feedback. The scope file in this case seems to have gotten corrupt due to power loss. I will look into adding automatic file backup mechanism to restore last known good config.

For backup & restore, there is already a feature request for backing up all config. This feature will be available soon as I have already planned its implementation.

ShreyasZare commented 3 years ago

DNS server version 5.6 fixes this issue with backup zip option. There is no proper way to fix file corruption caused due to power loss so its recommended to take backup and use UPS for reliability.