gclayburg/synology-diskstation-scripts

Suggestion for improvement: Keep all manual added entries intact

Closed this issue · 1 comments

Hello,

Thank you for working on this script. I started using it myself and ran into the problem that I want to keep adding A Records myself. The script only prints them when they are in the range of static leases but that ended with multiple lines of the same host whenever the host releases and renews it's IP.

I fixed that with a way that is (in my opinion) way better then keeping out every A Record or PTR record.
I changed the printDhcpAsRecords Function to add a ";dynamic" comment at the end of every line that is dynamicly added:

           if (RecordType == "PTR") {print 1000 + arr[4] "\t" ReverseIP ".in-addr.arpa. " RENEW " PTR " NAME "." YourNetworkName ". ;dynamic"}
           if (RecordType == "A") print 2000 + arr[4] "\t" NAME "." YourNetworkName ". " RENEW " A " IP " ;dynamic"

After that I changed the printPartialDNSFile to include that check like that:

       if( $3 == "A"){
          # Do not print dynamic entries. They will be added afterwards from the lease files.
          if ($5 != ";dynamic") {
            PrintThis=1;
          } else{
            PrintThis=0;
          }
        } else if($3 == "PTR" ){
          if ($5 != ";dynamic") {
            PrintThis=1;
          } else{
            PrintThis=0;
          }
        } else
          PrintThis=1;

The DSM UI will not remove this comment if you add new entries as well as it doesn't seem to care about the comment. The only time it is removed is if you manually edit a dynamic A entry which will make it to a static one.

Thought I will share this change here. Maybe you'd like to include it into the script.

@WolfspiritM I haven't seen the problem that you describe on my system. Perhaps your environment is different than mine. Could you generate a pull request for this change? Maybe your solution is a more general solution to the problem.