gclayburg / synology-diskstation-scripts

Update Synology DNS records from DHCP IP address reservation
169 stars 41 forks source link

Creates duplicates IPs in DNS #43

Open marioja opened 1 year ago

marioja commented 1 year ago

If you have existing A records in DNS then the diskstation_dns_modify.sh script when run for the first time will create duplicate A records in DNS. The problem is that those records cannot be deleted using the GUI. I had to do surgery to correct this.

gclayburg commented 1 year ago

Ok, so in your case you already manually added a DNS record for one or more of the hosts that have been given a dynamic address by DHCP? This script does not consider that case. Like you said, this script just adds an A record for each dymanic address it finds. Should this script do something different? How would it know which existing names in DNS should not be added?

Gandulf78 commented 1 year ago

Ok, so in your case you already manually added a DNS record for one or more of the hosts that have been given a dynamic address by DHCP? This script does not consider that case. Like you said, this script just adds an A record for each dymanic address it finds. Should this script do something different? How would it know which existing names in DNS should not be added?

Hi. I believe I have the same issue. After a reboot all my customized static DHCP configuration has been lost. I had to recreate it manually. In the meantime, the newly random IP attributed by DHCP have been imported in the A records. Now, i have some duplicated A records in the DNS A records (several times the same IP adresses). I would like to have it cleaned up. Is it something doable? Thanks you.

gclayburg commented 1 year ago

So if you use this script, there will basically 2 types of A records.

  1. records created manually in the GUI
  2. records created automatically by this script.

When this script runs again, it will check the dhcp changes and update DNS, but only for the records of type 2. The script tries to not change anything for records of type 1. If your DNS was "misconfigured" to start with, i.e. you had some entries of type 1 that you created to reflect a dynamic address before using this script, it might be possible that things get confused.

The best practice is to start with a DNS that does not have any type 1 records that map to a dynamic address assigned by DHCP - let this script handle that part.

Gandulf78 commented 1 year ago

So if you use this script, there will basically 2 types of A records.

  1. records created manually in the GUI
  2. records created automatically by this script.

When this script runs again, it will check the dhcp changes and update DNS, but only for the records of type 2. The script tries to not change anything for records of type 1. If your DNS was "misconfigured" to start with, i.e. you had some entries of type 1 that you created to reflect a dynamic address before using this script, it might be possible that things get confused.

The best practice is to start with a DNS that does not have any type 1 records that map to a dynamic address assigned by DHCP - let this script handle that part.

On my side, I am pretty sure I didn't create any record manually but yet I have some duplicates. How can I clean it up?

gclayburg commented 1 year ago

what version of DSM are you running?

Gandulf78 commented 1 year ago

what version of DSM are you running?

DSM 7.2.1 update 1

gclayburg commented 1 year ago

ok. I haven't tried this script with DSM 7 and I have no ability to test it either. Maybe someone else that is running DSM 7 can help?